Created
June 10, 2019 16:11
-
-
Save icecr4ck/014de8160afa7113e0cdf0e7111f91f7 to your computer and use it in GitHub Desktop.
Disassemble at multiple offsets with Miasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from miasm.analysis.binary import Container | |
from miasm.analysis.machine import Machine | |
from miasm.core.asmblock import AsmCFG | |
cont = Container.from_string("\xff\xe0\x89\xc0\x89\xd8\xeb\x05\x89\xc8\xeb\x01\x90\xc3") | |
bs = cont.bin_stream | |
machine = Machine("x86_32") | |
mn, dis_engine = machine.mn, machine.dis_engine | |
mdis = dis_engine(bs, loc_db=cont.loc_db) | |
todo = [0, 2, 4, 8, 0xD, 0xC] | |
asmcfg = AsmCFG(mdis.loc_db) | |
while todo: | |
ad = todo.pop() | |
asmcfg = mdis.dis_multiblock(ad, asmcfg) | |
for block in asmcfg.blocks: | |
print block | |
open('out.dot', 'w').write(asmcfg.dot()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment