mirror of
https://github.com/cea-sec/miasm
synced 2026-06-21 13:48:18 +00:00
ed5c3668cc
* API has changed, so old scripts need updates * See example for API usage * Use tcc or llvm for jit emulation * Go to test and run test_all.py to check install Enjoy !
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
# Minimalist Symbol Exec example
|
|
from miasm2.core.bin_stream import bin_stream_str
|
|
from miasm2.arch.x86.arch import mn_x86
|
|
from miasm2.arch.x86.ira import ir_a_x86_32
|
|
from miasm2.arch.x86.regs import all_regs_ids, all_regs_ids_init
|
|
from miasm2.ir.symbexec import symbexec
|
|
from miasm2.arch.x86.disasm import dis_x86_32 as dis_engine
|
|
import miasm2.expression.expression as m2_expr
|
|
|
|
l = mn_x86.fromstring("MOV EAX, EBX", 32)
|
|
asm = mn_x86.asm(l)[0]
|
|
|
|
bin_stream = bin_stream_str(asm)
|
|
|
|
mdis = dis_engine(bin_stream)
|
|
disasm = mdis.dis_multibloc(0)
|
|
|
|
ir = ir_a_x86_32(mdis.symbol_pool)
|
|
for bbl in disasm: ir.add_bloc(bbl)
|
|
|
|
symbols_init = {}
|
|
for i, r in enumerate(all_regs_ids):
|
|
symbols_init[r] = all_regs_ids_init[i]
|
|
symb = symbexec(mn_x86, symbols_init)
|
|
|
|
block = ir.get_bloc(0)
|
|
|
|
cur_addr = symb.emulbloc(block)
|
|
assert(symb.symbols[m2_expr.ExprId("EAX")] == symbols_init[m2_expr.ExprId("EBX")])
|
|
print 'modified registers:'
|
|
symb.dump_id()
|