diff options
| -rw-r--r-- | example/asm/shellcode.py | 3 | ||||
| -rw-r--r-- | example/disasm/callback.py | 4 | ||||
| -rw-r--r-- | example/disasm/file.py | 6 | ||||
| -rw-r--r-- | example/disasm/full.py | 10 | ||||
| -rw-r--r-- | example/disasm/function.py | 10 | ||||
| -rw-r--r-- | example/expression/solve_condition_stp.py | 2 | ||||
| -rw-r--r-- | example/ida/graph_ir.py | 3 | ||||
| -rw-r--r-- | example/jitter/unpack_upx.py | 8 |
8 files changed, 18 insertions, 28 deletions
diff --git a/example/asm/shellcode.py b/example/asm/shellcode.py index 9dc5c6bc..11cf9a4d 100644 --- a/example/asm/shellcode.py +++ b/example/asm/shellcode.py @@ -76,8 +76,7 @@ if args.PE: # Print and graph firsts blocs before patching it for bloc in blocs: print bloc -graph = asmbloc.bloc2graph(blocs) -open("graph.dot", "w").write(graph) +open("graph.dot", "w").write(blocs.dot()) # Apply patches patches = asmbloc.asm_resolve_final(machine.mn, diff --git a/example/disasm/callback.py b/example/disasm/callback.py index 6c77023e..4a7507dd 100644 --- a/example/disasm/callback.py +++ b/example/disasm/callback.py @@ -63,5 +63,5 @@ blocks_after = mdis.dis_multibloc(0) print "\n".join(str(block) for block in blocks_after) # Ensure the callback has been called -assert blocks[0].lines[0].name == "CALL" -assert blocks_after[0].lines[0].name == "PUSH" +assert blocks.heads()[0].lines[0].name == "CALL" +assert blocks_after.heads()[0].lines[0].name == "PUSH" diff --git a/example/disasm/file.py b/example/disasm/file.py index 1b9347d8..db5cd96b 100644 --- a/example/disasm/file.py +++ b/example/disasm/file.py @@ -1,6 +1,5 @@ import sys from miasm2.arch.x86.disasm import dis_x86_32 -from miasm2.core.asmbloc import bloc2graph from miasm2.analysis.binary import Container from pdb import pm @@ -14,7 +13,6 @@ cont = Container.from_stream(open(sys.argv[1])) mdis = dis_x86_32(cont.bin_stream) # Inform the engine to avoid disassembling null instructions mdis.dont_dis_nulstart_bloc = True -blocs = mdis.dis_multibloc(addr) +blocks = mdis.dis_multibloc(addr) -graph = bloc2graph(blocs) -open('graph.dot', 'w').write(graph) +open('graph.dot', 'w').write(blocks.dot()) diff --git a/example/disasm/full.py b/example/disasm/full.py index 33b2f41f..25e3a018 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -4,7 +4,7 @@ from argparse import ArgumentParser from pdb import pm from miasm2.analysis.binary import Container -from miasm2.core.asmbloc import log_asmbloc, asm_label, bloc2graph +from miasm2.core.asmbloc import log_asmbloc, asm_label, BasicBlocks from miasm2.expression.expression import ExprId from miasm2.core.interval import interval from miasm2.analysis.machine import Machine @@ -142,15 +142,13 @@ while not finish and todo: # Generate dotty graph -all_blocs = [] +all_blocs = BasicBlocks() for blocs in all_funcs_blocs.values(): all_blocs += blocs - # for b in blocs: - # print b + log.info('generate graph file') -g = bloc2graph(all_blocs, True) -open('graph_execflow.dot', 'w').write(g) +open('graph_execflow.dot', 'w').write(all_blocs.dot(label=True)) log.info('generate intervals') diff --git a/example/disasm/function.py b/example/disasm/function.py index a1a9b393..1fe1754f 100644 --- a/example/disasm/function.py +++ b/example/disasm/function.py @@ -1,5 +1,4 @@ from miasm2.arch.x86.disasm import dis_x86_32 -from miasm2.core.asmbloc import bloc2graph # MOV EAX, 0x1337BEEF # MOV ECX, 0x4 @@ -9,10 +8,9 @@ from miasm2.core.asmbloc import bloc2graph # RET shellcode = '\xb8\xef\xbe7\x13\xb9\x04\x00\x00\x00\xc1\xc0\x08\xe2\xfb\xc3' mdis = dis_x86_32(shellcode) -blocs = mdis.dis_multibloc(0) +blocks = mdis.dis_multibloc(0) -for bloc in blocs: - print bloc +for block in blocks: + print block -graph = bloc2graph(blocs) -open('graph.dot', 'w').write(graph) +open('graph.dot', 'w').write(blocks.dot()) diff --git a/example/expression/solve_condition_stp.py b/example/expression/solve_condition_stp.py index 034a115f..93c17018 100644 --- a/example/expression/solve_condition_stp.py +++ b/example/expression/solve_condition_stp.py @@ -168,7 +168,7 @@ if __name__ == '__main__': ''') - b = blocs[0] + b = list(blocs)[0] print b # add fake address and len to parsed instructions for i, l in enumerate(b.lines): diff --git a/example/ida/graph_ir.py b/example/ida/graph_ir.py index b181f72a..4447cadd 100644 --- a/example/ida/graph_ir.py +++ b/example/ida/graph_ir.py @@ -119,8 +119,7 @@ print hex(ad) ab = mdis.dis_multibloc(ad) print "generating graph" -g = bloc2graph(ab, True) -open('asm_flow.dot', 'w').write(g) +open('asm_flow.dot', 'w').write(ab.graph.dot(label=True)) print "generating IR... %x" % ad diff --git a/example/jitter/unpack_upx.py b/example/jitter/unpack_upx.py index 72a9feb3..d95c5a18 100644 --- a/example/jitter/unpack_upx.py +++ b/example/jitter/unpack_upx.py @@ -3,7 +3,7 @@ import logging from pdb import pm from elfesteem import pe from miasm2.analysis.sandbox import Sandbox_Win_x86_32 -from miasm2.core import asmbloc + filename = os.environ.get('PYTHONSTARTUP') if filename and os.path.isfile(filename): @@ -61,8 +61,7 @@ mdis = sb.machine.dis_engine(sb.jitter.bs) mdis.dont_dis_nulstart_bloc = True ab = mdis.dis_multibloc(sb.entry_point) -bb = asmbloc.basicblocs(ab) -leaves = bb.get_bad_dst() +leaves = list(ab.get_bad_blocks_predecessors()) assert(len(leaves) == 1) l = leaves.pop() logging.info(l) @@ -73,8 +72,7 @@ logging.info(end_label) # Export CFG graph (dot format) if options.graph is True: - g = asmbloc.bloc2graph(ab) - open("graph.dot", "w").write(g) + open("graph.dot", "w").write(ab.graph.dot()) if options.verbose is True: |