mythril.mythril package

Submodules

mythril.mythril.mythril_analyzer module

class mythril.mythril.mythril_analyzer.MythrilAnalyzer(disassembler: mythril.mythril.mythril_disassembler.MythrilDisassembler, cmd_args: argparse.Namespace, strategy: str = 'dfs', address: Optional[str] = None)[source]

Bases: object

The Mythril Analyzer class Responsible for the analysis of the smart contracts

dump_statespace(contract: mythril.ethereum.evmcontract.EVMContract = None) → str[source]

Returns serializable statespace of the contract :param contract: The Contract on which the analysis should be done :return: The serialized state space

fire_lasers(modules: Optional[List[str]] = None, transaction_count: Optional[int] = None) → mythril.analysis.report.Report[source]
Parameters:
  • modules – The analysis modules which should be executed
  • transaction_count – The amount of transactions to be executed
Returns:

The Report class which contains the all the issues/vulnerabilities

graph_html(contract: mythril.ethereum.evmcontract.EVMContract = None, enable_physics: bool = False, phrackify: bool = False, transaction_count: Optional[int] = None) → str[source]
Parameters:
  • contract – The Contract on which the analysis should be done
  • enable_physics – If true then enables the graph physics simulation
  • phrackify – If true generates Phrack-style call graph
  • transaction_count – The amount of transactions to be executed
Returns:

The generated graph in html format

mythril.mythril.mythril_config module

class mythril.mythril.mythril_config.MythrilConfig[source]

Bases: object

The Mythril Analyzer class Responsible for setup of the mythril environment

static init_mythril_dir() → str[source]

Initializes the mythril dir and config.ini file :return: The mythril dir’s path

set_api_from_config_path() → None[source]

Set the RPC mode based on a given config file.

set_api_infura_id(id)[source]
set_api_rpc(rpc: str = None, rpctls: bool = False) → None[source]

Sets the RPC mode to either of ganache or infura :param rpc: either of the strings - ganache, infura-mainnet, infura-rinkeby, infura-kovan, infura-ropsten

set_api_rpc_infura() → None[source]

Set the RPC mode to INFURA on Mainnet.

set_api_rpc_localhost() → None[source]

Set the RPC mode to a local instance.

mythril.mythril.mythril_disassembler module

class mythril.mythril.mythril_disassembler.MythrilDisassembler(eth: Optional[mythril.ethereum.interface.rpc.client.EthJsonRpc] = None, solc_version: str = None, solc_settings_json: str = None, enable_online_lookup: bool = False)[source]

Bases: object

The Mythril Disassembler class Responsible for generating disassembly of smart contracts:

  • Compiles solc code from file/onchain
  • Can also be used to access onchain storage data
get_state_variable_from_storage(address: str, params: Optional[List[str]] = None) → str[source]

Get variables from the storage :param address: The contract address :param params: The list of parameters param types: [position, length] or [“mapping”, position, key1, key2, … ]

or [position, length, array]
Returns:The corresponding storage slot and its value
static hash_for_function_signature(func: str) → str[source]

Return function nadmes corresponding signature hash :param func: function name :return: Its hash signature

load_from_address(address: str) → Tuple[str, mythril.ethereum.evmcontract.EVMContract][source]

Returns the contract given it’s on chain address :param address: The on chain address of a contract :return: tuple(address, contract)

load_from_bytecode(code: str, bin_runtime: bool = False, address: Optional[str] = None) → Tuple[str, mythril.ethereum.evmcontract.EVMContract][source]

Returns the address and the contract class for the given bytecode :param code: Bytecode :param bin_runtime: Whether the code is runtime code or creation code :param address: address of contract :return: tuple(address, Contract class)

load_from_solidity(solidity_files: List[str]) → Tuple[str, List[mythril.solidity.soliditycontract.SolidityContract]][source]
Parameters:solidity_files – List of solidity_files
Returns:tuple of address, contract class list

Module contents