From 9206458e0f4b815e4af68f8978d96d14632a087f Mon Sep 17 00:00:00 2001 From: Camille Mougey Date: Sun, 18 Jan 2015 18:44:44 +0100 Subject: Example: Move disasm's examples to a `disasm` directory --- example/disasm/file.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 example/disasm/file.py (limited to 'example/disasm/file.py') diff --git a/example/disasm/file.py b/example/disasm/file.py new file mode 100644 index 00000000..5bae0e89 --- /dev/null +++ b/example/disasm/file.py @@ -0,0 +1,19 @@ +import sys +from miasm2.arch.x86.disasm import dis_x86_32 +from miasm2.core.asmbloc import bloc2graph +from miasm2.analysis.binary import Container + +if len(sys.argv) != 3: + print 'Example:' + print "%s samples/box_upx.exe 0x410f90" % sys.argv[0] + sys.exit(0) + +addr = int(sys.argv[2], 16) +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) + +graph = bloc2graph(blocs) +open('graph.txt', 'w').write(graph) -- cgit 1.4.1