about summary refs log tree commit diff stats
path: root/example/disasm_03.py
blob: 72c08c0db59cbb7b9faeedbf8af5c0dbb6c338c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sys
from elfesteem import pe_init
from miasm2.arch.x86.disasm import dis_x86_32
from miasm2.core.asmbloc import bloc2graph
from miasm2.core.bin_stream import bin_stream_pe

if len(sys.argv) != 3:
    print 'Example:'
    print "%s box_upx.exe 0x410f90" % sys.argv[0]
    sys.exit(0)

fname = sys.argv[1]
ad = int(sys.argv[2], 16)
cont = Container.from_stream(open(sys.argv[1]))
mdis = dis_x86_32(cont.bin_stream)
# inform the engine not to disasm nul instructions
mdis.dont_dis_nulstart_bloc = True
blocs = mdis.dis_multibloc(ad)

g = bloc2graph(blocs)
open('graph.txt', 'w').write(g)