Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mythril/ether/evm.py

28 lines
710 B

from ethereum import vm, messages, transactions
from ethereum.state import State
from ethereum.slogging import get_logger
from logging import StreamHandler
import sys
import codecs
def trace(code):
logHandlers = ['eth.vm.op', 'eth.vm.op.stack', 'eth.vm.op.memory', 'eth.vm.op.storage']
streamHandler = StreamHandler(sys.stdout)
for handler in logHandlers:
log_vm_op = get_logger(handler)
log_vm_op.setLevel("TRACE")
log_vm_op.addHandler(streamHandler)
addr = codecs.decode('0123456789ABCDEF0123456789ABCDEF01234567', 'hex_codec')
state = State()
ext = messages.VMExt(state, transactions.Transaction(0, 0, 21000, addr, 0, addr))
msg = vm.Message(addr, addr)
vm.vm_execute(ext, msg, code)