diff options
Diffstat (limited to 'example')
| -rwxr-xr-x | example/asm/shellcode.py | 19 | ||||
| -rw-r--r-- | example/asm/simple.py | 6 | ||||
| -rw-r--r-- | example/disasm/callback.py | 4 | ||||
| -rw-r--r-- | example/disasm/full.py | 16 | ||||
| -rw-r--r-- | example/disasm/single_instr.py | 6 | ||||
| -rw-r--r-- | example/expression/access_c.py | 6 | ||||
| -rw-r--r-- | example/expression/asm_to_ir.py | 10 | ||||
| -rw-r--r-- | example/expression/constant_propagation.py | 2 | ||||
| -rw-r--r-- | example/expression/get_read_write.py | 6 | ||||
| -rw-r--r-- | example/expression/graph_dataflow.py | 4 | ||||
| -rw-r--r-- | example/expression/solve_condition_stp.py | 14 | ||||
| -rw-r--r-- | example/ida/ctype_propagation.py | 6 | ||||
| -rw-r--r-- | example/ida/depgraph.py | 10 | ||||
| -rw-r--r-- | example/ida/graph_ir.py | 14 | ||||
| -rw-r--r-- | example/ida/symbol_exec.py | 12 | ||||
| -rw-r--r-- | example/ida/utils.py | 14 | ||||
| -rw-r--r-- | example/jitter/sandbox_call.py | 4 | ||||
| -rw-r--r-- | example/jitter/unpack_upx.py | 2 | ||||
| -rw-r--r-- | example/symbol_exec/depgraph.py | 2 | ||||
| -rw-r--r-- | example/symbol_exec/single_instr.py | 12 |
20 files changed, 84 insertions, 85 deletions
diff --git a/example/asm/shellcode.py b/example/asm/shellcode.py index 0ee32146..331e4d69 100755 --- a/example/asm/shellcode.py +++ b/example/asm/shellcode.py @@ -8,6 +8,7 @@ from elfesteem.strpatchwork import StrPatchwork from miasm2.core import parse_asm, asmblock from miasm2.analysis.machine import Machine from miasm2.core.interval import interval +from miasm2.core.locationdb import LocationDB parser = ArgumentParser("Multi-arch (32 bits) assembler") parser.add_argument('architecture', help="architecture: " + @@ -65,15 +66,15 @@ with open(args.source) as fstream: source = fstream.read() -symbol_pool = asmblock.AsmSymbolPool() +loc_db = LocationDB() -asmcfg, symbol_pool = parse_asm.parse_txt(machine.mn, attrib, source, symbol_pool) +asmcfg, loc_db = parse_asm.parse_txt(machine.mn, attrib, source, loc_db) # Fix shellcode addrs -symbol_pool.set_offset(symbol_pool.getby_name("main"), addr_main) +loc_db.set_offset(loc_db.getby_name("main"), addr_main) if args.PE: - symbol_pool.set_offset(symbol_pool.getby_name_create("MessageBoxA"), + loc_db.set_offset(loc_db.getby_name_create("MessageBoxA"), pe.DirImport.get_funcvirt('USER32.dll', 'MessageBoxA')) # Print and graph firsts blocks before patching it @@ -84,14 +85,14 @@ open("graph.dot", "w").write(asmcfg.dot()) # Apply patches patches = asmblock.asm_resolve_final(machine.mn, asmcfg, - symbol_pool, + loc_db, dst_interval) if args.encrypt: # Encrypt code - loc_start = symbol_pool.getby_name_create(args.encrypt[0]) - loc_stop = symbol_pool.getby_name_create(args.encrypt[1]) - ad_start = symbol_pool.loc_key_to_offset(loc_start) - ad_stop = symbol_pool.loc_key_to_offset(loc_stop) + loc_start = loc_db.getby_name_create(args.encrypt[0]) + loc_stop = loc_db.getby_name_create(args.encrypt[1]) + ad_start = loc_db.loc_key_to_offset(loc_start) + ad_stop = loc_db.loc_key_to_offset(loc_stop) new_patches = dict(patches) for ad, val in patches.items(): diff --git a/example/asm/simple.py b/example/asm/simple.py index 09df8d94..068d3627 100644 --- a/example/asm/simple.py +++ b/example/asm/simple.py @@ -6,7 +6,7 @@ from miasm2.core import parse_asm, asmblock # Assemble code -asmcfg, symbol_pool = parse_asm.parse_txt(mn_x86, 32, ''' +asmcfg, loc_db = parse_asm.parse_txt(mn_x86, 32, ''' main: MOV EAX, 1 MOV EBX, 2 @@ -22,10 +22,10 @@ loop: ''') # Set 'main' loc_key's offset -symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0) +loc_db.set_offset(loc_db.getby_name("main"), 0x0) # Spread information and resolve instructions offset -patches = asmblock.asm_resolve_final(mn_x86, asmcfg, symbol_pool) +patches = asmblock.asm_resolve_final(mn_x86, asmcfg, loc_db) # Show resolved asmcfg for block in asmcfg.blocks: diff --git a/example/disasm/callback.py b/example/disasm/callback.py index a00cf5e5..85090070 100644 --- a/example/disasm/callback.py +++ b/example/disasm/callback.py @@ -3,7 +3,7 @@ from miasm2.core.asmblock import AsmConstraint from miasm2.arch.x86.disasm import dis_x86_32, cb_x86_funcs -def cb_x86_callpop(cur_bloc, symbol_pool, *args, **kwargs): +def cb_x86_callpop(cur_bloc, loc_db, *args, **kwargs): """ 1000: call 1005 1005: pop @@ -27,7 +27,7 @@ def cb_x86_callpop(cur_bloc, symbol_pool, *args, **kwargs): return loc_key = dst.loc_key - offset = symbol_pool.loc_key_to_offset(loc_key) + offset = loc_db.loc_key_to_offset(loc_key) ## The destination must be the next instruction if offset != last_instr.offset + last_instr.l: return diff --git a/example/disasm/full.py b/example/disasm/full.py index b0c34bff..1e5d2334 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -85,7 +85,7 @@ mn, dis_engine = machine.mn, machine.dis_engine ira, ir = machine.ira, machine.ir log.info('ok') -mdis = dis_engine(bs, symbol_pool=cont.symbol_pool) +mdis = dis_engine(bs, loc_db=cont.loc_db) # configure disasm engine mdis.dontdis_retcall = args.dontdis_retcall mdis.blocs_wd = args.blockwatchdog @@ -99,8 +99,8 @@ for addr in args.address: addrs.append(int(addr, 0)) except ValueError: # Second chance, try with symbol - loc_key = mdis.symbol_pool.getby_name(addr) - offset = mdis.symbol_pool.loc_key_to_offset(loc_key) + loc_key = mdis.loc_db.getby_name(addr) + offset = mdis.loc_db.loc_key_to_offset(loc_key) addrs.append(offset) if len(addrs) == 0 and default_addr is not None: @@ -140,10 +140,10 @@ while not finish and todo: instr = block.get_subcall_instr() if not instr: continue - for dest in instr.getdstflow(mdis.symbol_pool): + for dest in instr.getdstflow(mdis.loc_db): if not dest.is_loc(): continue - offset = mdis.symbol_pool.loc_key_to_offset(dest.loc_key) + offset = mdis.loc_db.loc_key_to_offset(dest.loc_key) todo.append((mdis, instr, offset)) if args.funcswatchdog is not None and args.funcswatchdog <= 0: @@ -158,7 +158,7 @@ while not finish and todo: # Generate dotty graph -all_asmcfg = AsmCFG(mdis.symbol_pool) +all_asmcfg = AsmCFG(mdis.loc_db) for blocks in all_funcs_blocks.values(): all_asmcfg += blocks @@ -189,8 +189,8 @@ log.info('total lines %s' % total_l) if args.gen_ir: log.info("generating IR and IR analysis") - ir_arch = ir(mdis.symbol_pool) - ir_arch_a = ira(mdis.symbol_pool) + ir_arch = ir(mdis.loc_db) + ir_arch_a = ira(mdis.loc_db) ir_arch.blocks = {} ir_arch_a.blocks = {} for ad, asmcfg in all_funcs_blocks.items(): diff --git a/example/disasm/single_instr.py b/example/disasm/single_instr.py index 59b81de7..d17e303f 100644 --- a/example/disasm/single_instr.py +++ b/example/disasm/single_instr.py @@ -1,9 +1,9 @@ from miasm2.arch.x86.arch import mn_x86 from miasm2.arch.x86.regs import EDX -from miasm2.core.asmblock import AsmSymbolPool +from miasm2.core.locationdb import LocationDB -symbol_pool = AsmSymbolPool() -l = mn_x86.fromstring('MOV EAX, EBX', symbol_pool, 32) +loc_db = LocationDB() +l = mn_x86.fromstring('MOV EAX, EBX', loc_db, 32) print "instruction:", l print "arg:", l.args[0] x = mn_x86.asm(l) diff --git a/example/expression/access_c.py b/example/expression/access_c.py index 8856f6f8..9b92d201 100644 --- a/example/expression/access_c.py +++ b/example/expression/access_c.py @@ -141,12 +141,12 @@ cont = Container.fallback_container(data, None, addr=0) machine = Machine("x86_64") dis_engine, ira = machine.dis_engine, machine.ira -mdis = dis_engine(cont.bin_stream, symbol_pool=cont.symbol_pool) +mdis = dis_engine(cont.bin_stream, loc_db=cont.loc_db) addr_head = 0 asmcfg = mdis.dis_multiblock(addr_head) -lbl_head = mdis.symbol_pool.getby_offset(addr_head) +lbl_head = mdis.loc_db.getby_offset(addr_head) -ir_arch_a = ira(mdis.symbol_pool) +ir_arch_a = ira(mdis.loc_db) for block in asmcfg.blocks: ir_arch_a.add_block(block) diff --git a/example/expression/asm_to_ir.py b/example/expression/asm_to_ir.py index 36965bfa..421d0884 100644 --- a/example/expression/asm_to_ir.py +++ b/example/expression/asm_to_ir.py @@ -8,7 +8,7 @@ from miasm2.arch.x86.ira import ir_a_x86_32 from miasm2.analysis.data_flow import dead_simp # First, asm code -asmcfg, symbol_pool = parse_asm.parse_txt(mn_x86, 32, ''' +asmcfg, loc_db = parse_asm.parse_txt(mn_x86, 32, ''' main: MOV EAX, 1 MOV EBX, 2 @@ -24,17 +24,17 @@ loop: ''') -symbol_pool.set_offset(symbol_pool.getby_name("main"), 0x0) +loc_db.set_offset(loc_db.getby_name("main"), 0x0) for block in asmcfg.blocks: print block print "symbols:" -print symbol_pool -patches = asmblock.asm_resolve_final(mn_x86, asmcfg, symbol_pool) +print loc_db +patches = asmblock.asm_resolve_final(mn_x86, asmcfg, loc_db) # Translate to IR -ir_arch = ir_a_x86_32(symbol_pool) +ir_arch = ir_a_x86_32(loc_db) for block in asmcfg.blocks: print 'add block' print block diff --git a/example/expression/constant_propagation.py b/example/expression/constant_propagation.py index 3a81d909..b39bcafd 100644 --- a/example/expression/constant_propagation.py +++ b/example/expression/constant_propagation.py @@ -28,7 +28,7 @@ machine = Machine("x86_32") cont = Container.from_stream(open(args.filename)) ira, dis_engine = machine.ira, machine.dis_engine mdis = dis_engine(cont.bin_stream) -ir_arch = ira(mdis.symbol_pool) +ir_arch = ira(mdis.loc_db) addr = int(args.address, 0) diff --git a/example/expression/get_read_write.py b/example/expression/get_read_write.py index 9e3b5caf..1bacb251 100644 --- a/example/expression/get_read_write.py +++ b/example/expression/get_read_write.py @@ -1,9 +1,9 @@ from miasm2.arch.x86.arch import mn_x86 from miasm2.expression.expression import get_rw from miasm2.arch.x86.ira import ir_a_x86_32 -from miasm2.core.asmblock import AsmSymbolPool +from miasm2.core.locationdb import LocationDB -symbol_pool = AsmSymbolPool() +loc_db = LocationDB() print """ @@ -14,7 +14,7 @@ Get read/written registers for a given instruction arch = mn_x86 ir_arch = ir_a_x86_32() -l = arch.fromstring('LODSB', symbol_pool, 32) +l = arch.fromstring('LODSB', loc_db, 32) l.offset, l.l = 0, 15 ir_arch.add_instr(l) diff --git a/example/expression/graph_dataflow.py b/example/expression/graph_dataflow.py index 9b45a52d..d0d5564a 100644 --- a/example/expression/graph_dataflow.py +++ b/example/expression/graph_dataflow.py @@ -97,7 +97,7 @@ def gen_block_data_flow_graph(ir_arch, ad, block_flow_cb): irblock_0 = None for irblock in ir_arch.blocks.values(): loc_key = irblock.loc_key - offset = ir_arch.symbol_pool.loc_key_to_offset(loc_key) + offset = ir_arch.loc_db.loc_key_to_offset(loc_key) if offset == ad: irblock_0 = irblock break @@ -139,7 +139,7 @@ print 'ok' print 'generating dataflow graph for:' -ir_arch = ir_a_x86_32(mdis.symbol_pool) +ir_arch = ir_a_x86_32(mdis.loc_db) for block in asmcfg.blocks: print block diff --git a/example/expression/solve_condition_stp.py b/example/expression/solve_condition_stp.py index 42e6670c..b941f092 100644 --- a/example/expression/solve_condition_stp.py +++ b/example/expression/solve_condition_stp.py @@ -88,23 +88,23 @@ if __name__ == '__main__': symbols_init = dict(machine.mn.regs.regs_init) - ir_arch = machine.ir(mdis.symbol_pool) + ir_arch = machine.ir(mdis.loc_db) symbexec = SymbolicExecutionEngine(ir_arch, symbols_init) - asmcfg, symbol_pool = parse_asm.parse_txt(machine.mn, 32, ''' + asmcfg, loc_db = parse_asm.parse_txt(machine.mn, 32, ''' init: PUSH argv PUSH argc PUSH ret_addr ''', - symbol_pool=mdis.symbol_pool) + loc_db=mdis.loc_db) - argc_lbl = symbol_pool.getby_name('argc') - argv_lbl = symbol_pool.getby_name('argv') - ret_addr_lbl = symbol_pool.getby_name('ret_addr') - init_lbl = symbol_pool.getby_name('init') + argc_lbl = loc_db.getby_name('argc') + argv_lbl = loc_db.getby_name('argv') + ret_addr_lbl = loc_db.getby_name('ret_addr') + init_lbl = loc_db.getby_name('init') argc = ExprLoc(argc_lbl, 32) argv = ExprLoc(argv_lbl, 32) diff --git a/example/ida/ctype_propagation.py b/example/ida/ctype_propagation.py index db324833..9a81baef 100644 --- a/example/ida/ctype_propagation.py +++ b/example/ida/ctype_propagation.py @@ -266,7 +266,7 @@ def analyse_function(): iraCallStackFixer = get_ira_call_fixer(ira) - ir_arch = iraCallStackFixer(mdis.symbol_pool) + ir_arch = iraCallStackFixer(mdis.loc_db) asmcfg = mdis.dis_multiblock(addr) # Generate IR @@ -304,8 +304,8 @@ def analyse_function(): infos_types[expr] = set([objc]) # Add fake head - lbl_real_start = ir_arch.symbol_pool.getby_offset(addr) - lbl_head = ir_arch.symbol_pool.getby_name_create("start") + lbl_real_start = ir_arch.loc_db.getby_offset(addr) + lbl_head = ir_arch.loc_db.getby_name_create("start") first_block = asmcfg.label2block(lbl_real_start) diff --git a/example/ida/depgraph.py b/example/ida/depgraph.py index 4320be8d..8e635203 100644 --- a/example/ida/depgraph.py +++ b/example/ida/depgraph.py @@ -28,7 +28,7 @@ class depGraphSettingsForm(ida_kernwin.Form): self.address = idc.ScreenEA() cur_block = None for block in ira.getby_offset(self.address): - offset = self.ira.symbol_pool.loc_key_to_offset(block.loc_key) + offset = self.ira.loc_db.loc_key_to_offset(block.loc_key) if offset is not None: # Only one block non-generated assert cur_block is None @@ -208,13 +208,13 @@ def launch_depgraph(): bs = bin_stream_ida() mdis = dis_engine(bs, dont_dis_nulstart_bloc=True) - ir_arch = ira(mdis.symbol_pool) + ir_arch = ira(mdis.loc_db) # Populate symbols with ida names for ad, name in idautils.Names(): if name is None: continue - mdis.symbol_pool.add_location(name, ad) + mdis.loc_db.add_location(name, ad) asmcfg = mdis.dis_multiblock(func.startEA) @@ -230,7 +230,7 @@ def launch_depgraph(): # Simplify affectations for irb in ir_arch.blocks.values(): irs = [] - offset = ir_arch.symbol_pool.loc_key_to_offset(irb.loc_key) + offset = ir_arch.loc_db.loc_key_to_offset(irb.loc_key) fix_stack = offset is not None and settings.unalias_stack for assignblk in irb: if fix_stack: @@ -251,7 +251,7 @@ def launch_depgraph(): # Get dependency graphs dg = settings.depgraph graphs = dg.get(loc_key, elements, line_nb, - set([ir_arch.symbol_pool.getby_offset(func.startEA)])) + set([ir_arch.loc_db.getby_offset(func.startEA)])) # Display the result comments = {} diff --git a/example/ida/graph_ir.py b/example/ida/graph_ir.py index dd842281..955dee62 100644 --- a/example/ida/graph_ir.py +++ b/example/ida/graph_ir.py @@ -36,12 +36,12 @@ def label_str(self): def color_irblock(irblock, ir_arch): out = [] - lbl = idaapi.COLSTR(ir_arch.symbol_pool.str_loc_key(irblock.loc_key), idaapi.SCOLOR_INSN) + lbl = idaapi.COLSTR(ir_arch.loc_db.str_loc_key(irblock.loc_key), idaapi.SCOLOR_INSN) out.append(lbl) for assignblk in irblock: for dst, src in sorted(assignblk.iteritems()): - dst_f = expr2colorstr(dst, symbol_pool=ir_arch.symbol_pool) - src_f = expr2colorstr(src, symbol_pool=ir_arch.symbol_pool) + dst_f = expr2colorstr(dst, loc_db=ir_arch.loc_db) + src_f = expr2colorstr(src, loc_db=ir_arch.loc_db) line = idaapi.COLSTR("%s = %s" % (dst_f, src_f), idaapi.SCOLOR_INSN) out.append(' %s' % line) out.append("") @@ -112,17 +112,17 @@ def build_graph(verbose=False, simplify=False): bs = bin_stream_ida() mdis = dis_engine(bs) - ir_arch = ira(mdis.symbol_pool) + ir_arch = ira(mdis.loc_db) # populate symbols with ida names for addr, name in idautils.Names(): if name is None: continue - if (mdis.symbol_pool.getby_offset(addr) or - mdis.symbol_pool.getby_name(name)): + if (mdis.loc_db.getby_offset(addr) or + mdis.loc_db.getby_name(name)): # Symbol alias continue - mdis.symbol_pool.add_location(name, addr) + mdis.loc_db.add_location(name, addr) if verbose: print "start disasm" diff --git a/example/ida/symbol_exec.py b/example/ida/symbol_exec.py index 0d8c63c2..43100943 100644 --- a/example/ida/symbol_exec.py +++ b/example/ida/symbol_exec.py @@ -37,11 +37,11 @@ class symbolicexec_t(idaapi.simplecustviewer_t): self.AddLine("%s = %s" % ( expr2colorstr( key, - symbol_pool=self.symbol_pool + loc_db=self.loc_db ), expr2colorstr( value, - symbol_pool=self.symbol_pool + loc_db=self.loc_db ) )) @@ -69,12 +69,12 @@ class symbolicexec_t(idaapi.simplecustviewer_t): form.Compile() form.Execute() - def Create(self, equations, machine, symbol_pool, *args, **kwargs): + def Create(self, equations, machine, loc_db, *args, **kwargs): if not super(symbolicexec_t, self).Create(*args, **kwargs): return False self.machine = machine - self.symbol_pool = symbol_pool + self.loc_db = loc_db self.line2eq = sorted(equations.items(), key=operator.itemgetter(0)) self.lines_expanded = set() @@ -141,7 +141,7 @@ def symbolic_exec(): mdis.dont_dis = [end] asmcfg = mdis.dis_multiblock(start) - ira = machine.ira(symbol_pool=mdis.symbol_pool) + ira = machine.ira(loc_db=mdis.loc_db) for block in asmcfg.blocks: ira.add_block(block) @@ -155,7 +155,7 @@ def symbolic_exec(): view = symbolicexec_t() all_views.append(view) - if not view.Create(modified, machine, mdis.symbol_pool, + if not view.Create(modified, machine, mdis.loc_db, "Symbolic Execution - 0x%x to 0x%x" % (start, idc.prev_head(end))): return diff --git a/example/ida/utils.py b/example/ida/utils.py index 5620a881..254617ba 100644 --- a/example/ida/utils.py +++ b/example/ida/utils.py @@ -79,9 +79,9 @@ class TranslatorIDA(Translator): # Implemented language __LANG__ = "ida_w_color" - def __init__(self, symbol_pool=None, **kwargs): + def __init__(self, loc_db=None, **kwargs): super(TranslatorIDA, self).__init__(**kwargs) - self.symbol_pool = symbol_pool + self.loc_db = loc_db def str_protected_child(self, child, parent): return ("(%s)" % ( @@ -97,8 +97,8 @@ class TranslatorIDA(Translator): return out def from_ExprLoc(self, expr): - if self.symbol_pool is not None: - out = self.symbol_pool.str_loc_key(expr.loc_key) + if self.loc_db is not None: + out = self.loc_db.str_loc_key(expr.loc_key) else: out = str(expr) out = idaapi.COLSTR(out, idaapi.SCOLOR_REG) @@ -150,13 +150,13 @@ class TranslatorIDA(Translator): -def expr2colorstr(expr, symbol_pool): +def expr2colorstr(expr, loc_db): """Colorize an Expr instance for IDA @expr: Expr instance to colorize - @symbol_pool: AsmSymbolPool instance + @loc_db: LocationDB instance """ - translator = TranslatorIDA(symbol_pool=symbol_pool) + translator = TranslatorIDA(loc_db=loc_db) return translator.from_expr(expr) diff --git a/example/jitter/sandbox_call.py b/example/jitter/sandbox_call.py index 7a9fd946..5fc50a9c 100644 --- a/example/jitter/sandbox_call.py +++ b/example/jitter/sandbox_call.py @@ -15,8 +15,8 @@ sb = Sandbox_Linux_arml(options.filename, options, globals()) with open(options.filename, "rb") as fdesc: cont = Container.from_stream(fdesc) - loc_key = cont.symbol_pool.getby_name("md5_starts") - addr_to_call = cont.symbol_pool.loc_key_to_offset(loc_key) + loc_key = cont.loc_db.getby_name("md5_starts") + addr_to_call = cont.loc_db.loc_key_to_offset(loc_key) # Calling md5_starts(malloc(0x64)) addr = linobjs.heap.alloc(sb.jitter, 0x64) diff --git a/example/jitter/unpack_upx.py b/example/jitter/unpack_upx.py index cd0818ec..6b7b4f50 100644 --- a/example/jitter/unpack_upx.py +++ b/example/jitter/unpack_upx.py @@ -60,7 +60,7 @@ assert(len(leaves) == 1) l = leaves.pop() logging.info(l) -end_offset = mdis.symbol_pool.loc_key_to_offset(l) +end_offset = mdis.loc_db.loc_key_to_offset(l) logging.info('final offset') logging.info(hex(end_offset)) diff --git a/example/symbol_exec/depgraph.py b/example/symbol_exec/depgraph.py index 621e8fca..88540a83 100644 --- a/example/symbol_exec/depgraph.py +++ b/example/symbol_exec/depgraph.py @@ -47,7 +47,7 @@ for element in args.element: raise ValueError("Unknown element '%s'" % element) mdis = machine.dis_engine(cont.bin_stream, dont_dis_nulstart_bloc=True) -ir_arch = machine.ira(mdis.symbol_pool) +ir_arch = machine.ira(mdis.loc_db) # Common argument forms init_ctx = {} diff --git a/example/symbol_exec/single_instr.py b/example/symbol_exec/single_instr.py index 22a48fc6..fd454212 100644 --- a/example/symbol_exec/single_instr.py +++ b/example/symbol_exec/single_instr.py @@ -2,27 +2,25 @@ from miasm2.core.bin_stream import bin_stream_str from miasm2.ir.symbexec import SymbolicExecutionEngine from miasm2.analysis.machine import Machine -from miasm2.core.asmblock import AsmSymbolPool +from miasm2.core.locationdb import LocationDB START_ADDR = 0 machine = Machine("x86_32") - -symbol_pool = AsmSymbolPool() - +loc_db = LocationDB() # Assemble and disassemble a MOV ## Ensure that attributes 'offset' and 'l' are set -line = machine.mn.fromstring("MOV EAX, EBX", symbol_pool, 32) +line = machine.mn.fromstring("MOV EAX, EBX", loc_db, 32) asm = machine.mn.asm(line)[0] # Get back block bin_stream = bin_stream_str(asm) -mdis = machine.dis_engine(bin_stream, symbol_pool=symbol_pool) +mdis = machine.dis_engine(bin_stream, loc_db=loc_db) mdis.lines_wd = 1 asm_block = mdis.dis_block(START_ADDR) # Translate ASM -> IR -ira = machine.ira(mdis.symbol_pool) +ira = machine.ira(mdis.loc_db) ira.add_block(asm_block) # Instanciate a Symbolic Execution engine with default value for registers |