mirror of
https://github.com/cea-sec/miasm
synced 2026-06-21 13:48:18 +00:00
5dbf046bbe
Use Python's int(s, 0) to allow string "s" to specify its base where addresses and offsets can be supplied. This change makes the situation homogeneous among the various examples and interactive usage.
21 lines
586 B
Python
21 lines
586 B
Python
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
|
|
|
|
if len(sys.argv) != 3:
|
|
print 'Example:'
|
|
print "%s samples/box_upx.exe 0x407570" % sys.argv[0]
|
|
sys.exit(0)
|
|
|
|
addr = int(sys.argv[2], 0)
|
|
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)
|