mythril.mythril package
Submodules
mythril.mythril.mythril_analyzer module
- class mythril.mythril.mythril_analyzer.MythrilAnalyzer(disassembler: MythrilDisassembler, cmd_args: Namespace, strategy: str = 'dfs', address: str | None = None)[source]
Bases:
object
The Mythril Analyzer class Responsible for the analysis of the smart contracts
- dump_statespace(contract: EVMContract | None = 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: List[str] | None = None, transaction_count: int | None = None) 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: EVMContract | None = None, enable_physics: bool = False, phrackify: bool = False, transaction_count: int | None = 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
mythril.mythril.mythril_disassembler module
- class mythril.mythril.mythril_disassembler.MythrilDisassembler(eth: EthJsonRpc | None = None, solc_version: str | None = None, solc_settings_json: str | None = None, enable_online_lookup: bool = False, solc_args=None)[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: List[str] | None = 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, 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: str | None = None) Tuple[str, 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[SolidityContract]] [source]
- Parameters:
solidity_files – List of solidity_files
- Returns:
tuple of address, contract class list