From 80b07d6c668e0671d2bd668bbb84f9052ec64385 Mon Sep 17 00:00:00 2001 From: Joran Honig Date: Tue, 21 Aug 2018 11:40:48 +0200 Subject: [PATCH] Initialize account with contract name --- mythril/analysis/symbolic.py | 2 +- mythril/laser/ethereum/svm.py | 4 ++-- mythril/laser/ethereum/transaction/symbolic.py | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mythril/analysis/symbolic.py b/mythril/analysis/symbolic.py index 04f81787..0a0d03a0 100644 --- a/mythril/analysis/symbolic.py +++ b/mythril/analysis/symbolic.py @@ -33,7 +33,7 @@ class SymExecWrapper: create_timeout=create_timeout) if isinstance(contract, SolidityContract): - self.laser.sym_exec(creation_code=contract.creation_code) + self.laser.sym_exec(creation_code=contract.creation_code, contract_name=contract.name) else: self.laser.sym_exec(address) diff --git a/mythril/laser/ethereum/svm.py b/mythril/laser/ethereum/svm.py index 752dadba..06438c58 100644 --- a/mythril/laser/ethereum/svm.py +++ b/mythril/laser/ethereum/svm.py @@ -61,7 +61,7 @@ class LaserEVM: def accounts(self): return self.world_state.accounts - def sym_exec(self, main_address=None, creation_code=None): + def sym_exec(self, main_address=None, creation_code=None, contract_name=None): logging.debug("Starting LASER execution") self.time = datetime.now() @@ -70,7 +70,7 @@ class LaserEVM: execute_message_call(self, main_address) elif creation_code: logging.info("Starting contract creation transaction") - created_account = execute_contract_creation(self, creation_code) + created_account = execute_contract_creation(self, creation_code, contract_name) logging.info("Finished contract creation, found {} open states".format(len(self.open_states))) if len(self.open_states) == 0: print("No contract was created during the execution of contract creation " diff --git a/mythril/laser/ethereum/transaction/symbolic.py b/mythril/laser/ethereum/transaction/symbolic.py index 81693787..468ec630 100644 --- a/mythril/laser/ethereum/transaction/symbolic.py +++ b/mythril/laser/ethereum/transaction/symbolic.py @@ -26,12 +26,15 @@ def execute_message_call(laser_evm, callee_address): laser_evm.exec() -def execute_contract_creation(laser_evm, contract_initialization_code): +def execute_contract_creation(laser_evm, contract_initialization_code, contract_name=None): """ Executes a contract creation transaction from all open states""" open_states = laser_evm.open_states[:] del laser_evm.open_states[:] new_account = laser_evm.world_state.create_account(0, concrete_storage=True) + if contract_name: + new_account.contract_name = contract_name + for open_world_state in open_states: transaction = ContractCreationTransaction(