From 91b16391658eadd16e88c6bc20c06184e5353734 Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Mon, 7 Dec 2020 17:57:21 +0100 Subject: Change example names --- example/disasm/dis_binary_lift_model_call.py | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 example/disasm/dis_binary_lift_model_call.py (limited to 'example/disasm/dis_binary_lift_model_call.py') 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()) -- cgit 1.4.1