about summary refs log tree commit diff stats
path: root/example/disasm/function.py
blob: a1a9b393a03689c0d54e4b81da0009f923876cac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from miasm2.arch.x86.disasm import dis_x86_32
from miasm2.core.asmbloc import bloc2graph

# MOV        EAX, 0x1337BEEF
# MOV        ECX, 0x4
# loop:
# ROL        EAX, 0x8
# LOOP       loop
# RET
shellcode = '\xb8\xef\xbe7\x13\xb9\x04\x00\x00\x00\xc1\xc0\x08\xe2\xfb\xc3'
mdis = dis_x86_32(shellcode)
blocs = mdis.dis_multibloc(0)

for bloc in blocs:
    print bloc

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