Merge branch 'dyd_2' into dld_updates

pull/1344/head
Bernhard Mueller 5 years ago
commit 1d6a8a6767
  1. 2
      mythril/analysis/symbolic.py
  2. 22
      mythril/interfaces/cli.py
  3. 2
      mythril/laser/ethereum/state/account.py
  4. 23
      mythril/mythril/mythril_analyzer.py
  5. 20
      mythril/support/loader.py

@ -178,7 +178,7 @@ class SymExecWrapper:
contract_name=contract.name,
balances=world_state.balances,
concrete_storage=True
if (dynloader is not None and dynloader.storage_loading)
if (dynloader is not None and dynloader.active)
else False,
)
world_state.put_account(account)

@ -442,18 +442,10 @@ def create_analyzer_parser(analyzer_parser: ArgumentParser):
help="The amount of seconds to spend on the initial contract creation",
)
options.add_argument(
"-l",
"--dynld",
"--no-onchain-data",
action="store_true",
help="auto-load dependencies from the blockchain",
help="Don't attempt to retrieve contract code, variables and balances from the blockchain",
)
options.add_argument(
"--no-onchain-storage-access",
"--no-onchain-access",
action="store_true",
help="turns off getting the data from onchain contracts (both loading storage and contract code)",
)
options.add_argument(
"--phrack", action="store_true", help="Phrack-style call graph"
)
@ -546,10 +538,9 @@ def set_config(args: Namespace):
config = MythrilConfig()
if args.__dict__.get("infura_id", None):
config.set_api_infura_id(args.infura_id)
if (
args.command in ANALYZE_LIST
and (args.dynld or not args.no_onchain_storage_access)
) and not (args.rpc or args.i):
if (args.command in ANALYZE_LIST and not args.no_onchain_data) and not (
args.rpc or args.i
):
config.set_api_from_config_path()
if args.__dict__.get("address", None):
@ -676,9 +667,8 @@ def execute_command(
create_timeout=args.create_timeout,
enable_iprof=args.enable_iprof,
disable_dependency_pruning=args.disable_dependency_pruning,
onchain_storage_access=not args.no_onchain_storage_access,
use_onchain_data=not args.no_onchain_data,
solver_timeout=args.solver_timeout,
requires_dynld=not args.no_onchain_storage_access,
enable_coverage_strategy=args.enable_coverage_strategy,
custom_modules_directory=args.custom_modules_directory
if args.custom_modules_directory

@ -40,7 +40,7 @@ class Storage:
and self.address.value != 0
and item.symbolic is False
and int(item.value) not in self.storage_keys_loaded
and (self.dynld and self.dynld.storage_loading)
and (self.dynld and self.dynld.active)
):
try:
storage[item] = symbol_factory.BitVecVal(

@ -33,7 +33,7 @@ class MythrilAnalyzer:
self,
disassembler: MythrilDisassembler,
requires_dynld: bool = False,
onchain_storage_access: bool = True,
use_onchain_data: bool = True,
strategy: str = "dfs",
address: Optional[str] = None,
max_depth: Optional[int] = None,
@ -55,8 +55,7 @@ class MythrilAnalyzer:
self.eth = disassembler.eth
self.contracts = disassembler.contracts or [] # type: List[EVMContract]
self.enable_online_lookup = disassembler.enable_online_lookup
self.dynld = requires_dynld
self.onchain_storage_access = onchain_storage_access
self.use_onchain_data = use_onchain_data
self.strategy = strategy
self.address = address
self.max_depth = max_depth
@ -81,11 +80,7 @@ class MythrilAnalyzer:
contract or self.contracts[0],
self.address,
self.strategy,
dynloader=DynLoader(
self.eth,
storage_loading=self.onchain_storage_access,
contract_loading=self.dynld,
),
dynloader=DynLoader(self.eth, active=self.use_onchain_data),
max_depth=self.max_depth,
execution_timeout=self.execution_timeout,
create_timeout=self.create_timeout,
@ -118,11 +113,7 @@ class MythrilAnalyzer:
contract or self.contracts[0],
self.address,
self.strategy,
dynloader=DynLoader(
self.eth,
storage_loading=self.onchain_storage_access,
contract_loading=self.dynld,
),
dynloader=DynLoader(self.eth, active=self.use_onchain_data),
max_depth=self.max_depth,
execution_timeout=self.execution_timeout,
transaction_count=transaction_count,
@ -155,11 +146,7 @@ class MythrilAnalyzer:
contract,
self.address,
self.strategy,
dynloader=DynLoader(
self.eth,
storage_loading=self.onchain_storage_access,
contract_loading=self.dynld,
),
dynloader=DynLoader(self.eth, active=self.use_onchain_data),
max_depth=self.max_depth,
execution_timeout=self.execution_timeout,
loop_bound=self.loop_bound,

@ -15,18 +15,14 @@ log = logging.getLogger(__name__)
class DynLoader:
"""The dynamic loader class."""
def __init__(
self, eth: Optional[EthJsonRpc], contract_loading=True, storage_loading=True
):
def __init__(self, eth: Optional[EthJsonRpc], active=True):
"""
:param eth:
:param contract_loading:
:param storage_loading:
:param active:
"""
self.eth = eth
self.contract_loading = contract_loading
self.storage_loading = storage_loading
self.active = active
@functools.lru_cache(LRU_CACHE_SIZE)
def read_storage(self, contract_address: str, index: int) -> str:
@ -36,10 +32,8 @@ class DynLoader:
:param index:
:return:
"""
if not self.storage_loading:
raise ValueError(
"Cannot load from the storage when the storage_loading flag is false"
)
if not self.active:
raise ValueError("Loader is disabled")
if not self.eth:
raise ValueError("Cannot load from the storage when eth is None")
@ -69,8 +63,8 @@ class DynLoader:
:param dependency_address:
:return:
"""
if not self.contract_loading:
raise ValueError("Cannot load contract when contract_loading flag is false")
if not self.active:
raise ValueError("Loader is disabled")
if not self.eth:
raise ValueError("Cannot load from the storage when eth is None")

Loading…
Cancel
Save