Fix encoding issues in trace function

pull/7/head
Bernhard Mueller 7 years ago
parent 8d82553b8d
commit 844d2a32bd
  1. 4
      myth
  2. 10
      mythril/ether/util.py

@ -103,10 +103,10 @@ elif (args.trace):
exitWithError("Disassembler: Provide the input bytecode via -c BYTECODE or --id ID") exitWithError("Disassembler: Provide the input bytecode via -c BYTECODE or --id ID")
if (args.data): if (args.data):
output = evm.trace(util.safe_decode(encoded_bytecode), args.address, args.data) output = evm.trace(encoded_bytecode, args.address, args.data)
else: else:
output = evm.trace(util.safe_decode(encoded_bytecode), args.address) output = evm.trace(encoded_bytecode, args.address)
print(output) print(output)

@ -1,15 +1,19 @@
from mythril.rpc.client import EthJsonRpc from mythril.rpc.client import EthJsonRpc
import codecs
from ethereum.abi import encode_abi, encode_int from ethereum.abi import encode_abi, encode_int
from ethereum.utils import zpad from ethereum.utils import zpad
from ethereum.abi import method_id from ethereum.abi import method_id
def safe_decode(hex_encoded_string): def safe_decode(hex_encoded_string):
# print(type(hex_encoded_string))
if (hex_encoded_string.startswith("0x")): if (hex_encoded_string.startswith("0x")):
return codecs.decode(hex_encoded_string[2:], 'hex_codec') return bytes.fromhex(hex_encoded_string[2:])
# return codecs.decode(, 'hex_codec')
else: else:
return codecs.decode(hex_encoded_string, 'hex_codec') return bytes.fromhex(hex_encoded_string)
# return codecs.decode(hex_encoded_string, 'hex_codec')
def bytecode_from_blockchain(creation_tx_hash, rpc_host='127.0.0.1', rpc_port=8545): def bytecode_from_blockchain(creation_tx_hash, rpc_host='127.0.0.1', rpc_port=8545):

Loading…
Cancel
Save