mythril.analysis.module package

Submodules

mythril.analysis.module.base module

Mythril Detection Modules

This module includes an definition of the DetectionModule interface. DetectionModules implement different analysis rules to find weaknesses and vulnerabilities.

class mythril.analysis.module.base.DetectionModule[source]

Bases: abc.ABC

The base detection module.

All custom-built detection modules must inherit from this class.

There are several class properties that expose information about the detection modules

Parameters:
  • name – The name of the detection module
  • swc_id – The SWC ID associated with the weakness that the module detects
  • description – A description of the detection module, and what it detects
  • entry_point – Mythril can run callback style detection modules, or modules that search the statespace. [IMPORTANT] POST entry points severely slow down the analysis, try to always use callback style modules
  • pre_hooks – A list of instructions to hook the laser vm for (pre execution of the instruction)
  • post_hooks – A list of instructions to hook the laser vm for (post execution of the instruction)
description = 'Detection module description'
entry_point = 2
execute(target: mythril.laser.ethereum.state.global_state.GlobalState) → Optional[List[mythril.analysis.report.Issue]][source]

The entry point for execution, which is being called by Mythril.

Parameters:target – The target of the analysis, either a global state (callback) or the entire statespace (post)
Returns:List of encountered issues
name = 'Detection Module Name / Title'
post_hooks = []
pre_hooks = []
reset_module()[source]

Resets the storage of this module

swc_id = 'SWC-000'
update_cache(issues=None)[source]

Updates cache with param issues, updates against self.issues, if the param is None :param issues: The issues used to update the cache

class mythril.analysis.module.base.EntryPoint[source]

Bases: enum.Enum

EntryPoint Enum

This enum is used to signify the entry_point of detection modules. See also the class documentation of DetectionModule

CALLBACK = 2
POST = 1

mythril.analysis.module.loader module

class mythril.analysis.module.loader.ModuleLoader[source]

Bases: object

The module loader class implements a singleton loader for detection modules.

By default it will load the detection modules in the mythril package. Additional detection modules can be loaded using the register_module function call implemented by the ModuleLoader

get_detection_modules(entry_point: Optional[mythril.analysis.module.base.EntryPoint] = None, white_list: Optional[List[str]] = None) → List[mythril.analysis.module.base.DetectionModule][source]

Gets registered detection modules

Parameters:
  • entry_point – If specified: only return detection modules with this entry point
  • white_list – If specified: only return whitelisted detection modules
Returns:

The selected detection modules

register_module(detection_module: mythril.analysis.module.base.DetectionModule)[source]

Registers a detection module with the module loader

mythril.analysis.module.module_helpers module

mythril.analysis.module.module_helpers.is_prehook() → bool[source]

Check if we are in prehook. One of Bernhard’s trademark hacks! Let’s leave it to this for now, unless we need to check prehook for a lot more modules.

mythril.analysis.module.util module

mythril.analysis.module.util.get_detection_module_hooks(modules: List[mythril.analysis.module.base.DetectionModule], hook_type='pre') → Dict[str, List[Callable]][source]

Gets a dictionary with the hooks for the passed detection modules

Parameters:
  • modules – The modules for which to retrieve hooks
  • hook_type – The type of hooks to retrieve (default: “pre”)
Returns:

Dictionary with discovered hooks

mythril.analysis.module.util.reset_callback_modules(module_names: Optional[List[str]] = None)[source]

Clean the issue records of every callback-based module.

Module contents