feliam 3a63402ae5
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
2017-11-29 13:22:16 -03:00

56 lines
1.7 KiB
Python

#!/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')