diff --git a/mythril/analysis/symbolic.py b/mythril/analysis/symbolic.py index 4c8885f4..e7667867 100644 --- a/mythril/analysis/symbolic.py +++ b/mythril/analysis/symbolic.py @@ -1,7 +1,7 @@ from mythril.analysis.security import get_detection_module_hooks from mythril.laser.ethereum import svm from mythril.laser.ethereum.state.account import Account -from mythril.solidity.soliditycontract import SolidityContract, ETHContract +from mythril.solidity.soliditycontract import SolidityContract, EVMContract import copy from .ops import get_variable, SStore, Call, VarType from mythril.laser.ethereum.strategy.basic import ( @@ -67,7 +67,7 @@ class SymExecWrapper: self.laser.sym_exec( creation_code=contract.creation_code, contract_name=contract.name ) - elif isinstance(contract, ETHContract) and contract.creation_code: + elif isinstance(contract, EVMContract) and contract.creation_code: self.laser.sym_exec( creation_code=contract.creation_code, contract_name=contract.name ) diff --git a/mythril/ethereum/evmcontract.py b/mythril/ethereum/evmcontract.py index d63f2938..de0b7ae7 100644 --- a/mythril/ethereum/evmcontract.py +++ b/mythril/ethereum/evmcontract.py @@ -4,7 +4,7 @@ import persistent import re -class ETHContract(persistent.Persistent): +class EVMContract(persistent.Persistent): def __init__( self, code="", creation_code="", name="Unknown", enable_online_lookup=False ): diff --git a/mythril/ethereum/interface/leveldb/client.py b/mythril/ethereum/interface/leveldb/client.py index f45883df..68337006 100644 --- a/mythril/ethereum/interface/leveldb/client.py +++ b/mythril/ethereum/interface/leveldb/client.py @@ -10,7 +10,7 @@ from ethereum import utils from ethereum.block import BlockHeader, Block from mythril.ethereum.interface.leveldb.state import State from mythril.ethereum.interface.leveldb.eth_db import ETH_DB -from mythril.ethereum.ethcontract import ETHContract +from mythril.ethereum.evmcontract import EVMContract from mythril.exceptions import AddressNotFoundError # Per https://github.com/ethereum/go-ethereum/blob/master/core/rawdb/schema.go @@ -182,7 +182,7 @@ class EthLevelDB(object): for account in self.reader._get_head_state().get_all_accounts(): if account.code is not None: code = _encode_hex(account.code) - contract = ETHContract(code, enable_online_lookup=False) + contract = EVMContract(code, enable_online_lookup=False) yield contract, account.address, account.balance diff --git a/mythril/mythril.py b/mythril/mythril.py index 4f5687d7..6a8a2578 100644 --- a/mythril/mythril.py +++ b/mythril/mythril.py @@ -18,7 +18,7 @@ from configparser import ConfigParser import platform from mythril.ethereum import util -from mythril.ethereum.ethcontract import ETHContract +from mythril.ethereum.evmcontract import EVMContract from mythril.solidity.soliditycontract import SolidityContract, get_contracts_from_file from mythril.ethereum.interface.rpc.client import EthJsonRpc from mythril.ethereum.interface.rpc.exceptions import ConnectionError @@ -323,7 +323,7 @@ class Mythril(object): address = util.get_indexed_address(0) if bin_runtime: self.contracts.append( - ETHContract( + EVMContract( code=code, name="MAIN", enable_online_lookup=self.enable_online_lookup, @@ -331,7 +331,7 @@ class Mythril(object): ) else: self.contracts.append( - ETHContract( + EVMContract( creation_code=code, name="MAIN", enable_online_lookup=self.enable_online_lookup, @@ -360,7 +360,7 @@ class Mythril(object): ) else: self.contracts.append( - ETHContract( + EVMContract( code, name=address, enable_online_lookup=self.enable_online_lookup, diff --git a/mythril/solidity/soliditycontract.py b/mythril/solidity/soliditycontract.py index 83e5cc32..133a0b24 100644 --- a/mythril/solidity/soliditycontract.py +++ b/mythril/solidity/soliditycontract.py @@ -1,5 +1,5 @@ import mythril.laser.ethereum.util as helper -from mythril.ethereum.ethcontract import ETHContract +from mythril.ethereum.evmcontract import EVMContract from mythril.ethereum.util import get_solc_json from mythril.exceptions import NoContractFoundError @@ -42,7 +42,7 @@ def get_contracts_from_file(input_file, solc_args=None, solc_binary="solc"): raise NoContractFoundError -class SolidityContract(ETHContract): +class SolidityContract(EVMContract): def __init__(self, input_file, name=None, solc_args=None, solc_binary="solc"): data = get_solc_json(input_file, solc_args=solc_args, solc_binary=solc_binary) diff --git a/mythril/support/truffle.py b/mythril/support/truffle.py index 26888f08..cb3a55e2 100644 --- a/mythril/support/truffle.py +++ b/mythril/support/truffle.py @@ -5,7 +5,7 @@ import sys import json import logging from ethereum.utils import sha3 -from mythril.ethereum.ethcontract import ETHContract +from mythril.ethereum.evmcontract import EVMContract from mythril.solidity.soliditycontract import SourceMapping from mythril.analysis.security import fire_lasers from mythril.analysis.symbolic import SymExecWrapper @@ -43,7 +43,7 @@ def analyze_truffle_project(sigs, args): continue get_sigs_from_truffle(sigs, contractdata) - ethcontract = ETHContract(bytecode, name=name) + ethcontract = EVMContract(bytecode, name=name) address = util.get_indexed_address(0) sym = SymExecWrapper( diff --git a/tests/ethcontract_test.py b/tests/evmcontract_test.py similarity index 89% rename from tests/ethcontract_test.py rename to tests/evmcontract_test.py index bd881f87..b8e86bd5 100644 --- a/tests/ethcontract_test.py +++ b/tests/evmcontract_test.py @@ -2,13 +2,13 @@ import unittest from mythril.ethereum.evmcontract import EVMContract -class ETHContractTestCase(unittest.TestCase): +class EVMContractTestCase(unittest.TestCase): def setUp(self): self.code = "0x60606040525b603c5b60006010603e565b9050593681016040523660008237602060003683856040603f5a0204f41560545760206000f35bfe5b50565b005b73c3b2ae46792547a96b9f84405e36d0e07edcd05c5b905600a165627a7a7230582062a884f947232ada573f95940cce9c8bfb7e4e14e21df5af4e884941afb55e590029" self.creation_code = "0x60606040525b603c5b60006010603e565b9050593681016040523660008237602060003683856040603f5a0204f41560545760206000f35bfe5b50565b005b73c3b2ae46792547a96b9f84405e36d0e07edcd05c5b905600a165627a7a7230582062a884f947232ada573f95940cce9c8bfb7e4e14e21df5af4e884941afb55e590029" -class Getinstruction_listTestCase(ETHContractTestCase): +class Getinstruction_listTestCase(EVMContractTestCase): def runTest(self): contract = EVMContract(self.code, self.creation_code) @@ -21,7 +21,7 @@ class Getinstruction_listTestCase(ETHContractTestCase): ) -class GetEASMTestCase(ETHContractTestCase): +class GetEASMTestCase(EVMContractTestCase): def runTest(self): contract = EVMContract(self.code) @@ -33,7 +33,7 @@ class GetEASMTestCase(ETHContractTestCase): ) -class MatchesExpressionTestCase(ETHContractTestCase): +class MatchesExpressionTestCase(EVMContractTestCase): def runTest(self): contract = EVMContract(self.code)