pull/1344/head
Bernhard Mueller 5 years ago
parent 84dc7998ee
commit 0daa07bd3c
  1. 1
      mythril/analysis/symbolic.py
  2. 7
      mythril/ethereum/interface/rpc/client.py
  3. 4
      mythril/interfaces/cli.py
  4. 10
      mythril/laser/ethereum/state/account.py
  5. 16
      mythril/support/loader.py

@ -176,6 +176,7 @@ class SymExecWrapper:
contract.disassembly, contract.disassembly,
dynamic_loader=dynloader, dynamic_loader=dynloader,
contract_name=contract.name, contract_name=contract.name,
balances=world_state.balances,
concrete_storage=True concrete_storage=True
if (dynloader is not None and dynloader.storage_loading) if (dynloader is not None and dynloader.storage_loading)
else False, else False,

@ -52,12 +52,7 @@ class EthJsonRpc(BaseClient):
:return: :return:
""" """
params = params or [] params = params or []
data = { data = {"jsonrpc": "2.0", "method": method, "params": params, "id": _id}
"jsonrpc": "2.0",
"method": method,
"params": params,
"id": _id,
}
scheme = "http" scheme = "http"
if self.tls: if self.tls:
scheme += "s" scheme += "s"

@ -387,9 +387,7 @@ def create_analyzer_parser(analyzer_parser: ArgumentParser):
action="store_true", action="store_true",
help="analyze a truffle project (run from project dir)", help="analyze a truffle project (run from project dir)",
) )
commands.add_argument( commands.add_argument("--infura-id", help="set infura id for onchain analysis")
"--infura-id", help="set infura id for onchain analysis",
)
options = analyzer_parser.add_argument_group("options") options = analyzer_parser.add_argument_group("options")
options.add_argument( options.add_argument(

@ -112,10 +112,12 @@ class Account:
concrete_storage, address=self.address, dynamic_loader=dynamic_loader concrete_storage, address=self.address, dynamic_loader=dynamic_loader
) )
formatted_address = "{0:#0{1}x}".format(self.address.value, 42);
# Metadata # Metadata
if contract_name is None: if contract_name is None:
self.contract_name = ( self.contract_name = (
"{0:#0{1}x}".format(self.address.value, 40) formatted_address
if not self.address.symbolic if not self.address.symbolic
else "unknown" else "unknown"
) )
@ -127,6 +129,12 @@ class Account:
self._balances = balances self._balances = balances
self.balance = lambda: self._balances[self.address] self.balance = lambda: self._balances[self.address]
if not self.address.symbolic and dynamic_loader is not None:
_balance = dynamic_loader.read_balance(formatted_address)
self.set_balance(
_balance
)
def __str__(self) -> str: def __str__(self) -> str:
return str(self.as_dict) return str(self.as_dict)

@ -47,6 +47,22 @@ class DynLoader:
contract_address, position=index, block="latest" contract_address, position=index, block="latest"
) )
@functools.lru_cache(LRU_CACHE_SIZE)
def read_balance(self, address: str) -> str:
"""
:param address:
:return:
"""
if not self.storage_loading:
raise ValueError(
"Cannot load from the storage when the storage_loading flag is false"
)
if not self.eth:
raise ValueError("Cannot load from the storage when eth is None")
return self.eth.eth_getBalance(address)
@functools.lru_cache(LRU_CACHE_SIZE) @functools.lru_cache(LRU_CACHE_SIZE)
def dynld(self, dependency_address: str) -> Optional[Disassembly]: def dynld(self, dependency_address: str) -> Optional[Disassembly]:
""" """

Loading…
Cancel
Save