EVM assembler/disassembler doc and cleanup (#563)
* Fixes symbolic reentrancy example * Fix coverage Issue# 527 * Remove debug unused code * New solidity biased API and reporting * Updated examples to new api WIP * simple_mapping FIXED. new api * Simple transaction example added. msg.value can be symbolic now * Reentrancy symbolic now updated to new API + bugfixes * Doc and cleanups in evm assembler * EVMInstruction -> Instruction * cleanups * typo * deepcopy in Constant * Better EVM-asm api and doc * some docs * More evm asm docs * Fix import * * typo * newline between text and param * similar phrasing to all the other flags * typo * typo * fix function name in comment * sphinx newline * documentation fixes * documentation fixes * EVMAssembler to EVMAsm * Fix evm @hook signature * EVMAsm * EVMasm refactor
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# EVM disassembler
|
||||
from manticore.platforms.evm import EVMAsm as ea
|
||||
|
||||
def printi(instruction):
|
||||
print 'Instruction: %s'% instruction
|
||||
print '\tdescription:', instruction.description
|
||||
print '\tgroup:', instruction.group
|
||||
print '\taddress:', instruction.offset
|
||||
print '\tsize:', instruction.size
|
||||
print '\thas_operand:', instruction.has_operand
|
||||
print '\toperand_size:', instruction.operand_size
|
||||
print '\toperand:', instruction.operand
|
||||
print '\tsemantics:', instruction.semantics
|
||||
print '\tpops:', instruction.pops
|
||||
print '\tpushes:', instruction.pushes
|
||||
print '\tbytes:', '0x'+instruction.bytes.encode('hex')
|
||||
print '\twrites to stack:', instruction.writes_to_stack
|
||||
print '\treads from stack:', instruction.reads_from_stack
|
||||
print '\twrites to memory:', instruction.writes_to_memory
|
||||
print '\treads from memory:', instruction.reads_from_memory
|
||||
print '\twrites to storage:', instruction.writes_to_storage
|
||||
print '\treads from storage:', instruction.reads_from_storage
|
||||
print '\tis terminator', instruction.is_terminator
|
||||
|
||||
|
||||
instruction = ea.disassemble_one('\x60\x10')
|
||||
printi(instruction)
|
||||
|
||||
instruction = ea.assemble_one('PUSH1 0x10')
|
||||
printi(instruction)
|
||||
|
||||
for instruction in ea.disassemble_all('\x30\x31'):
|
||||
printi(instruction)
|
||||
|
||||
for instruction in ea.assemble_all('ADDRESS\nBALANCE'):
|
||||
printi(instruction)
|
||||
|
||||
|
||||
#High level simple assembler/disassembler
|
||||
print ea.assemble_hex(
|
||||
"""PUSH1 0x60
|
||||
BLOCKHASH
|
||||
MSTORE
|
||||
PUSH1 0x2
|
||||
PUSH2 0x100
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
print ea.disassemble_hex('0x606040526002610100')
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
from seth import *
|
||||
|
||||
seth = ManticoreEVM()
|
||||
seth.verbosity(3)
|
||||
user_account = seth.create_account(balance=1000)
|
||||
|
||||
bytecode = '`'
|
||||
#Initialize contract
|
||||
contract_account = seth.create_contract(owner=user_account,
|
||||
balance=0,
|
||||
init=bytecode)
|
||||
|
||||
def explore(state):
|
||||
pass
|
||||
|
||||
seth.add_hook(None, explore)
|
||||
seth.transaction( caller=user_account,
|
||||
address=contract_account,
|
||||
value=None,
|
||||
data='',
|
||||
)
|
||||
@@ -2,7 +2,6 @@ from manticore import Manticore
|
||||
from manticore.core.smtlib import ConstraintSet, Operators, solver, issymbolic, Array, Expression, Constant
|
||||
from manticore.core.smtlib.visitors import arithmetic_simplifier
|
||||
from manticore.platforms import evm
|
||||
from manticore.platforms.evm import pack_msb
|
||||
from manticore.core.state import State
|
||||
import tempfile
|
||||
from subprocess import Popen, PIPE
|
||||
@@ -371,7 +370,7 @@ class ManticoreEVM(Manticore):
|
||||
assert ty == 'CREATE_CONTRACT'
|
||||
world.create_contract(caller=caller, address=address, balance=value, init=data)
|
||||
|
||||
def will_execute_instruction_callback(self, state, instruction):
|
||||
def will_execute_instruction_callback(self, state, pc, instruction):
|
||||
assert state.constraints == state.platform.constraints
|
||||
assert state.platform.constraints == state.platform.current.constraints
|
||||
|
||||
@@ -473,7 +472,6 @@ class ManticoreEVM(Manticore):
|
||||
else:
|
||||
print "\t", hex(address), account['balance'],"wei"
|
||||
|
||||
|
||||
if state.platform.logs:
|
||||
print "LOGS:"
|
||||
for address, memlog, topics in state.platform.logs:
|
||||
|
||||
Reference in New Issue
Block a user