diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2015-11-09 14:27:16 +0100 |
|---|---|---|
| committer | serpilliere <serpilliere@users.noreply.github.com> | 2015-11-09 14:27:16 +0100 |
| commit | 29a00f31d46e49333df450b85580af152aae2668 (patch) | |
| tree | 5179bbaae19f3d8fe6a2398ca6d0e09b5d923c19 | |
| parent | 7681a432c7c98df9d075701a172df0d5f311f753 (diff) | |
| parent | 4140fa4725a31d7b1f8856c2da30a87a17c80c67 (diff) | |
| download | miasm-29a00f31d46e49333df450b85580af152aae2668.tar.gz miasm-29a00f31d46e49333df450b85580af152aae2668.zip | |
Merge pull request #258 from commial/extension-dot
Extension dot
| -rw-r--r-- | example/asm/shellcode.py | 2 | ||||
| -rw-r--r-- | example/disasm/file.py | 2 | ||||
| -rw-r--r-- | example/disasm/full.py | 6 | ||||
| -rw-r--r-- | example/disasm/function.py | 2 | ||||
| -rw-r--r-- | example/expression/asm_to_ir.py | 4 | ||||
| -rw-r--r-- | example/expression/get_read_write.py | 2 | ||||
| -rw-r--r-- | example/expression/graph_dataflow.py | 6 | ||||
| -rw-r--r-- | example/expression/solve_condition_stp.py | 4 | ||||
| -rw-r--r-- | example/ida/graph_ir.py | 8 | ||||
| -rw-r--r-- | example/jitter/unpack_upx.py | 4 | ||||
| -rw-r--r-- | test/test_all.py | 26 |
11 files changed, 33 insertions, 33 deletions
diff --git a/example/asm/shellcode.py b/example/asm/shellcode.py index 52630e4d..253386b5 100644 --- a/example/asm/shellcode.py +++ b/example/asm/shellcode.py @@ -77,7 +77,7 @@ if args.PE: for bloc in blocs: print bloc graph = asmbloc.bloc2graph(blocs) -open("graph.txt", "w").write(graph) +open("graph.dot", "w").write(graph) # Apply patches patches = asmbloc.asm_resolve_final(machine.mn, diff --git a/example/disasm/file.py b/example/disasm/file.py index 1a22dfe7..1b9347d8 100644 --- a/example/disasm/file.py +++ b/example/disasm/file.py @@ -17,4 +17,4 @@ mdis.dont_dis_nulstart_bloc = True blocs = mdis.dis_multibloc(addr) graph = bloc2graph(blocs) -open('graph.txt', 'w').write(graph) +open('graph.dot', 'w').write(graph) diff --git a/example/disasm/full.py b/example/disasm/full.py index db12c45b..03928e73 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -150,7 +150,7 @@ for blocs in all_funcs_blocs.values(): log.info('generate graph file') g = bloc2graph(all_blocs, True) -open('graph_execflow.txt', 'w').write(g) +open('graph_execflow.dot', 'w').write(g) log.info('generate intervals') @@ -167,7 +167,7 @@ for i, j in done_interval.intervals: all_lines.sort(key=lambda x: x.offset) -open('lines.txt', 'w').write('\n'.join([str(l) for l in all_lines])) +open('lines.dot', 'w').write('\n'.join([str(l) for l in all_lines])) log.info('total lines %s' % total_l) @@ -200,4 +200,4 @@ if args.gen_ir: ir_arch_a.dead_simp() out = ir_arch_a.graph() - open('graph_irflow.txt', 'w').write(out) + open('graph_irflow.dot', 'w').write(out) diff --git a/example/disasm/function.py b/example/disasm/function.py index 0d443c26..a1a9b393 100644 --- a/example/disasm/function.py +++ b/example/disasm/function.py @@ -15,4 +15,4 @@ for bloc in blocs: print bloc graph = bloc2graph(blocs) -open('graph.txt', 'w').write(graph) +open('graph.dot', 'w').write(graph) diff --git a/example/expression/asm_to_ir.py b/example/expression/asm_to_ir.py index ee8a481a..3ed59ffe 100644 --- a/example/expression/asm_to_ir.py +++ b/example/expression/asm_to_ir.py @@ -47,11 +47,11 @@ for lbl, b in ir_arch.blocs.items(): # Dead propagation ir_arch.gen_graph() out = ir_arch.graph() -open('graph.txt', 'w').write(out) +open('graph.dot', 'w').write(out) print '*' * 80 ir_arch.dead_simp() out2 = ir_arch.graph() -open('graph2.txt', 'w').write(out2) +open('graph2.dot', 'w').write(out2) # Display new IR print 'new ir blocs' diff --git a/example/expression/get_read_write.py b/example/expression/get_read_write.py index faa3f9df..f0f48015 100644 --- a/example/expression/get_read_write.py +++ b/example/expression/get_read_write.py @@ -23,4 +23,4 @@ for lbl, b in ir_arch.blocs.items(): print ir_arch.gen_graph() g = ir_arch.graph() -open('graph_instr.txt', 'w').write(g) +open('graph_instr.dot', 'w').write(g) diff --git a/example/expression/graph_dataflow.py b/example/expression/graph_dataflow.py index 1450b33b..e263a40e 100644 --- a/example/expression/graph_dataflow.py +++ b/example/expression/graph_dataflow.py @@ -139,7 +139,7 @@ def gen_bloc_data_flow_graph(ir_arch, ad, block_flow_cb): # from graph_qt import graph_qt # graph_qt(flow_graph) - open('data.txt', 'w').write(flow_graph.dot()) + open('data.dot', 'w').write(flow_graph.dot()) data = open(args.filename).read() @@ -175,8 +175,8 @@ gen_bloc_data_flow_graph(ir_arch, ad, block_flow_cb) print '*' * 40 print """ View with: -dotty dataflow.txt +dotty dataflow.dot or Generate ps with pdf: -dot -Tps dataflow_xx.txt -o graph.ps +dot -Tps dataflow_xx.dot -o graph.ps """ diff --git a/example/expression/solve_condition_stp.py b/example/expression/solve_condition_stp.py index 8c65c83c..034a115f 100644 --- a/example/expression/solve_condition_stp.py +++ b/example/expression/solve_condition_stp.py @@ -228,11 +228,11 @@ if __name__ == '__main__': rez = " AND ".join(all_csts) out.append("QUERY(NOT (%s));" % rez) end = "\n".join(out) - open('out.txt', 'w').write(end) + open('out.dot', 'w').write(end) try: cases = subprocess.check_output(["/home/serpilliere/tools/stp/stp", "-p", - "out.txt"]) + "out.dot"]) except OSError: print "ERF, cannot find stp" break diff --git a/example/ida/graph_ir.py b/example/ida/graph_ir.py index bbb44bbb..c3d88c36 100644 --- a/example/ida/graph_ir.py +++ b/example/ida/graph_ir.py @@ -120,7 +120,7 @@ ab = mdis.dis_multibloc(ad) print "generating graph" g = bloc2graph(ab, True) -open('asm_flow.txt', 'w').write(g) +open('asm_flow.dot', 'w').write(g) print "generating IR... %x" % ad @@ -140,7 +140,7 @@ for irb in ir_arch.blocs.values(): ir_arch.gen_graph() out = ir_arch.graph() -open(os.path.join(tempfile.gettempdir(), 'graph.txt'), 'wb').write(out) +open(os.path.join(tempfile.gettempdir(), 'graph.dot'), 'wb').write(out) # ir_arch.dead_simp() @@ -230,7 +230,7 @@ def gen_bloc_data_flow_graph(ir_arch, in_str, ad): # arch, attrib, pool_bin, bl if n in ir_arch.arch.regs.all_regs_ids: print node - open('data.txt', 'w').write(flow_graph.dot()) + open('data.dot', 'w').write(flow_graph.dot()) return flow_graph @@ -286,7 +286,7 @@ class GraphMiasmIRFlow(GraphViewer): #def node2str(self, n): # return "%s, %s\\l%s" % n #flow_graph.node2str = lambda n: node2str(flow_graph, n) -#open('data_flow.txt', 'w').write(flow_graph.dot()) +#open('data_flow.dot', 'w').write(flow_graph.dot()) # h = GraphMiasmIRFlow(flow_graph, "Miasm IRFlow graph", None) # h.Show() diff --git a/example/jitter/unpack_upx.py b/example/jitter/unpack_upx.py index eb03209b..f1f179b8 100644 --- a/example/jitter/unpack_upx.py +++ b/example/jitter/unpack_upx.py @@ -40,7 +40,7 @@ parser.add_argument("filename", help="PE Filename") parser.add_argument('-v', "--verbose", help="verbose mode", action="store_true") parser.add_argument("--graph", - help="Export the CFG graph in graph.txt", + help="Export the CFG graph in graph.dot", action="store_true") options = parser.parse_args() sb = Sandbox_Win_x86_32(options.filename, options, globals()) @@ -72,7 +72,7 @@ logging.info(end_label) # Export CFG graph (dot format) if options.graph is True: g = asmbloc.bloc2graph(ab) - open("graph.txt", "w").write(g) + open("graph.dot", "w").write(g) if options.verbose is True: diff --git a/test/test_all.py b/test/test_all.py index faae79c5..c7e421e3 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -69,7 +69,7 @@ class SemanticTestAsm(RegressionTest): input_filename, output_filename, self.container_dct.get(container, '')] - self.products = [output_filename, "graph.txt"] + self.products = [output_filename, "graph.dot"] class SemanticTestExec(RegressionTest): @@ -190,8 +190,8 @@ testset += ExampleAssembler(["simple.py"]) class ExampleShellcode(ExampleAssembler): """Specificities: - script: asm/shellcode.py - - @products: graph.txt + 3rd arg - - apply get_sample on each products (!= graph.txt) + - @products: graph.dot + 3rd arg + - apply get_sample on each products (!= graph.dot) - apply get_sample on the 2nd and 3rd arg (source, output) """ @@ -201,7 +201,7 @@ class ExampleShellcode(ExampleAssembler): self.command_line[0]] + \ map(Example.get_sample, self.command_line[1:3]) + \ self.command_line[3:] - self.products = [self.command_line[3], "graph.txt"] + self.products = [self.command_line[3], "graph.dot"] testset += ExampleShellcode(['x86_32', 'x86_32_manip_ptr.S', "demo_x86_32.bin"]) @@ -251,11 +251,11 @@ class ExampleDisassembler(Example): for script, prods in [(["single_instr.py"], []), (["callback.py"], []), - (["function.py"], ["graph.txt"]), + (["function.py"], ["graph.dot"]), (["file.py", Example.get_sample("box_upx.exe"), - "0x407570"], ["graph.txt"]), + "0x407570"], ["graph.dot"]), (["full.py", Example.get_sample("box_upx.exe")], - ["graph_execflow.txt", "lines.txt"]), + ["graph_execflow.dot", "lines.dot"]), ]: testset += ExampleDisassembler(script, products=prods) @@ -264,13 +264,13 @@ class ExampleDisasmFull(ExampleDisassembler): """DisasmFull specificities: - script: disasm/full.py - flags: -g -s - - @products: graph_execflow.txt, graph_irflow.txt, lines.txt, out.txt + - @products: graph_execflow.dot, graph_irflow.dot, lines.dot, out.dot """ def __init__(self, *args, **kwargs): super(ExampleDisasmFull, self).__init__(*args, **kwargs) self.command_line = ["full.py", "-g", "-s", "-m"] + self.command_line - self.products += ["graph_execflow.txt", "graph_irflow.txt", "lines.txt"] + self.products += ["graph_execflow.dot", "graph_irflow.dot", "lines.dot"] testset += ExampleDisasmFull(["arml", Example.get_sample("demo_arm_l.bin"), @@ -315,14 +315,14 @@ for args in [[], ["--symb"]]: testset += ExampleExpression(["graph_dataflow.py", Example.get_sample("sc_connect_back.bin"), "0x2e"] + args, - products=["data.txt"]) + products=["data.dot"]) testset += ExampleExpression(["asm_to_ir.py"], - products=["graph.txt", "graph2.txt"]) + products=["graph.dot", "graph2.dot"]) testset += ExampleExpression(["get_read_write.py"], - products=["graph_instr.txt"]) + products=["graph_instr.dot"]) testset += ExampleExpression(["solve_condition_stp.py", Example.get_sample("simple_test.bin")], - products=["graph_instr.txt", "out.txt"]) + products=["graph_instr.dot", "out.dot"]) for script in [["basic_op.py"], ["basic_simplification.py"], |