diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-12-07 17:57:21 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-12-24 17:15:46 +0100 |
| commit | 91b16391658eadd16e88c6bc20c06184e5353734 (patch) | |
| tree | 7bbddf4a4d16c3cdd22948ae86c84114053ff4c1 /example/disasm/dis_binary_lift.py | |
| parent | 34bed7068b08935b78aac3a1b3c07d83d072506d (diff) | |
| download | miasm-91b16391658eadd16e88c6bc20c06184e5353734.tar.gz miasm-91b16391658eadd16e88c6bc20c06184e5353734.zip | |
Change example names
Diffstat (limited to 'example/disasm/dis_binary_lift.py')
| -rw-r--r-- | example/disasm/dis_binary_lift.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/example/disasm/dis_binary_lift.py b/example/disasm/dis_binary_lift.py new file mode 100644 index 00000000..6ad69b05 --- /dev/null +++ b/example/disasm/dis_binary_lift.py @@ -0,0 +1,39 @@ +from __future__ import print_function +import sys +from future.utils import viewvalues +from miasm.analysis.binary import Container +from miasm.analysis.machine import Machine +from miasm.core.locationdb import LocationDB + +##################################### +# Common section from dis_binary.py # +##################################### + +fdesc = open(sys.argv[1], 'rb') +loc_db = LocationDB() + +cont = Container.from_stream(fdesc, loc_db) + +machine = Machine(cont.arch) + +mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db) + +addr = cont.entry_point +asmcfg = mdis.dis_multiblock(addr) + +##################################### +# End common section # +##################################### + +# Get a Lifter +ir_arch = machine.lifter(mdis.loc_db) + +# Get the IR of the asmcfg +ircfg = ir_arch.new_ircfg_from_asmcfg(asmcfg) + +# Display each IR basic blocks +for irblock in viewvalues(ircfg.blocks): + print(irblock) + +# Output ir control flow graph in a dot file +open('bin_ir_cfg.dot', 'w').write(ircfg.dot()) |