コード例 #1
0
ファイル: asm.py プロジェクト: nbanmp/mythril
def get_opcode_from_name(name):

    for opcode, value in opcodes.items():

        if name == value[0]:

            return opcode

    raise RuntimeError("Unknown opcode")
コード例 #2
0
def get_opcode_from_name(operation_name: str) -> int:
    """Get an op code based on its name.

    :param operation_name:
    :return:
    """
    for op_code, value in opcodes.items():
        if operation_name == value[0]:
            return op_code
    raise RuntimeError("Unknown opcode")
コード例 #3
0
"""This module contains functionality for hooking in detection modules and
executing them."""
from collections import defaultdict
from ethereum.opcodes import opcodes
from mythril.analysis import modules
import pkgutil
import importlib.util
import logging

log = logging.getLogger(__name__)

OPCODE_LIST = [c[0] for _, c in opcodes.items()]


def reset_callback_modules():
    """Clean the issue records of every callback-based module."""
    modules = get_detection_modules("callback")
    for module in modules:
        module.detector.reset_module()


def get_detection_module_hooks(modules, hook_type="pre"):
    hook_dict = defaultdict(list)
    _modules = get_detection_modules(entrypoint="callback",
                                     include_modules=modules)
    for module in _modules:
        hooks = (module.detector.pre_hooks
                 if hook_type == "pre" else module.detector.post_hooks)

        for op_code in map(lambda x: x.upper(), hooks):
            if op_code in OPCODE_LIST:
コード例 #4
0
ファイル: asm.py プロジェクト: norhh/mythril
def get_opcode_from_name(operation_name: str) -> int:
    for op_code, value in opcodes.items():
        if operation_name == value[0]:
            return op_code
    raise RuntimeError("Unknown opcode")