about summary refs log tree commit diff stats
path: root/example/disasm/file.py
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2015-01-26 10:04:24 +0100
committerserpilliere <serpilliere@users.noreply.github.com>2015-01-26 10:04:24 +0100
commitb87f775c1a6a5c78c62beee925eaba6dc337577e (patch)
treecf2650f575971bf8a23655a28c944e9e8a9da561 /example/disasm/file.py
parentc59591a779ac644d1b50a720aea93cd8b36a2ddf (diff)
parent7b9bbe4754db4d1f5229cc5cc5769ad6cf2e0a84 (diff)
downloadmiasm-b87f775c1a6a5c78c62beee925eaba6dc337577e.tar.gz
miasm-b87f775c1a6a5c78c62beee925eaba6dc337577e.zip
Merge pull request #45 from commial/refactor-examples
Refactor examples
Diffstat (limited to 'example/disasm/file.py')
-rw-r--r--example/disasm/file.py19
1 files changed, 19 insertions, 0 deletions
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)