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_model_call.py | |
| parent | 34bed7068b08935b78aac3a1b3c07d83d072506d (diff) | |
| download | focaccia-miasm-91b16391658eadd16e88c6bc20c06184e5353734.tar.gz focaccia-miasm-91b16391658eadd16e88c6bc20c06184e5353734.zip | |
Change example names
Diffstat (limited to 'example/disasm/dis_binary_lift_model_call.py')
| -rw-r--r-- | example/disasm/dis_binary_lift_model_call.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/example/disasm/dis_binary_lift_model_call.py b/example/disasm/dis_binary_lift_model_call.py new file mode 100644 index 00000000..95b3a70b --- /dev/null +++ b/example/disasm/dis_binary_lift_model_call.py @@ -0,0 +1,42 @@ +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 an IRA converter +# The sub call are modelised by default operators +# call_func_ret and call_func_stack +ir_arch_analysis = machine.lifter_model_call(mdis.loc_db) + +# Get the IR of the asmcfg +ircfg_analysis = ir_arch_analysis.new_ircfg_from_asmcfg(asmcfg) + +# Display each IR basic blocks +for irblock in viewvalues(ircfg_analysis.blocks): + print(irblock) + +# Output ir control flow graph in a dot file +open('bin_lifter_model_call_cfg.dot', 'w').write(ircfg_analysis.dot()) |