Replace --contract-creation option by --bin-runtime

Default bytecode expected is now the contract creation bytecode.
pull/596/head
Maxime Biais 6 years ago
parent fac974080b
commit 957575087b
No known key found for this signature in database
GPG Key ID: F3EA910F71E3C894
  1. 6
      mythril/interfaces/cli.py
  2. 8
      mythril/mythril.py

@ -48,7 +48,7 @@ def main():
metavar='BYTECODEFILE', type=argparse.FileType('r'))
inputs.add_argument('-a', '--address', help='pull contract from the blockchain', metavar='CONTRACT_ADDRESS')
inputs.add_argument('-l', '--dynld', action='store_true', help='auto-load dependencies from the blockchain')
inputs.add_argument('--contract-creation', dest="is_contract_creation", action='store_true', help='Only when -c or -f is used. Consider the input bytecode as contract creation code.')
inputs.add_argument('--bin-runtime', action='store_true', help='Only when -c or -f is used. Consider the input bytecode as binary runtime code, default being the contract creation bytecode.')
outputs = parser.add_argument_group('output formats')
outputs.add_argument('-o', '--outform', choices=['text', 'markdown', 'json'], default='text',
@ -175,10 +175,10 @@ def main():
if args.code:
# Load from bytecode
address, _ = mythril.load_from_bytecode(args.code, args.is_contract_creation)
address, _ = mythril.load_from_bytecode(args.code, args.bin_runtime)
elif args.codefile:
bytecode = ''.join([l.strip() for l in args.codefile if len(l.strip()) > 0])
address, _ = mythril.load_from_bytecode(bytecode, args.is_contract_creation)
address, _ = mythril.load_from_bytecode(bytecode, args.bin_runtime)
elif args.address:
# Get bytecode from a contract address
address, _ = mythril.load_from_address(args.address)

@ -278,12 +278,12 @@ class Mythril(object):
print(self.eth_db.contract_hash_to_address(hash))
def load_from_bytecode(self, code, is_contract_creation=False):
def load_from_bytecode(self, code, bin_runtime=False):
address = util.get_indexed_address(0)
if (is_contract_creation):
self.contracts.append(ETHContract(creation_code=code, name="MAIN", enable_online_lookup=self.enable_online_lookup))
else:
if (bin_runtime):
self.contracts.append(ETHContract(code=code, name="MAIN", enable_online_lookup=self.enable_online_lookup))
else:
self.contracts.append(ETHContract(creation_code=code, name="MAIN", enable_online_lookup=self.enable_online_lookup))
return address, self.contracts[-1] # return address and contract object
def load_from_address(self, address):

Loading…
Cancel
Save