From 957575087ba99540a70727f7f93ffe805225df27 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Fri, 26 Oct 2018 10:05:57 +0200 Subject: [PATCH] Replace --contract-creation option by --bin-runtime Default bytecode expected is now the contract creation bytecode. --- mythril/interfaces/cli.py | 6 +++--- mythril/mythril.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mythril/interfaces/cli.py b/mythril/interfaces/cli.py index feb7777d..7358ce9d 100644 --- a/mythril/interfaces/cli.py +++ b/mythril/interfaces/cli.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) diff --git a/mythril/mythril.py b/mythril/mythril.py index 8097aa18..64243d75 100644 --- a/mythril/mythril.py +++ b/mythril/mythril.py @@ -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):