diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-08-22 12:47:01 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-08-31 07:50:01 +0200 |
| commit | 80e40a3d2ca735db955807ad0605b43ca22e4e35 (patch) | |
| tree | 4d41d7b53565f833444d3520eb22eed3e8bf26f1 /example/symbol_exec | |
| parent | 5d8beb271d9890241a6d61dd476fab26ca37ebbf (diff) | |
| download | miasm-80e40a3d2ca735db955807ad0605b43ca22e4e35.tar.gz miasm-80e40a3d2ca735db955807ad0605b43ca22e4e35.zip | |
Avoid generate default locationdb
Diffstat (limited to 'example/symbol_exec')
| -rw-r--r-- | example/symbol_exec/depgraph.py | 9 | ||||
| -rw-r--r-- | example/symbol_exec/dse_crackme.py | 6 | ||||
| -rw-r--r-- | example/symbol_exec/dse_strategies.py | 7 |
3 files changed, 14 insertions, 8 deletions
diff --git a/example/symbol_exec/depgraph.py b/example/symbol_exec/depgraph.py index c7b9017f..8285452e 100644 --- a/example/symbol_exec/depgraph.py +++ b/example/symbol_exec/depgraph.py @@ -10,6 +10,7 @@ from miasm.analysis.machine import Machine from miasm.analysis.binary import Container from miasm.analysis.depgraph import DependencyGraph from miasm.expression.expression import ExprMem, ExprId, ExprInt +from miasm.core.locationdb import LocationDB parser = ArgumentParser("Dependency grapher") parser.add_argument("filename", help="Binary to analyse") @@ -33,10 +34,10 @@ parser.add_argument("--json", help="Output solution in JSON", action="store_true") args = parser.parse_args() - +loc_db = LocationDB() # Get architecture with open(args.filename, "rb") as fstream: - cont = Container.from_stream(fstream) + cont = Container.from_stream(fstream, loc_db) arch = args.architecture if args.architecture else cont.arch machine = Machine(arch) @@ -50,8 +51,8 @@ for element in args.element: except KeyError: raise ValueError("Unknown element '%s'" % element) -mdis = machine.dis_engine(cont.bin_stream, dont_dis_nulstart_bloc=True) -ir_arch = machine.ira(mdis.loc_db) +mdis = machine.dis_engine(cont.bin_stream, dont_dis_nulstart_bloc=True, loc_db=loc_db) +ir_arch = machine.ira(loc_db) # Common argument forms init_ctx = {} diff --git a/example/symbol_exec/dse_crackme.py b/example/symbol_exec/dse_crackme.py index 82a7af08..e014ada2 100644 --- a/example/symbol_exec/dse_crackme.py +++ b/example/symbol_exec/dse_crackme.py @@ -21,6 +21,7 @@ from miasm.jitter.csts import PAGE_READ, PAGE_WRITE from miasm.analysis.sandbox import Sandbox_Linux_x86_64 from miasm.expression.expression import * from miasm.os_dep.win_api_x86_32 import get_win_str_a +from miasm.core.locationdb import LocationDB is_win = platform.system() == "Windows" @@ -75,7 +76,8 @@ parser.add_argument("--strategy", options = parser.parse_args() options.mimic_env = True options.command_line = ["%s" % TEMP_FILE.name] -sb = Sandbox_Linux_x86_64(options.filename, options, globals()) +loc_db = LocationDB() +sb = Sandbox_Linux_x86_64(loc_db, options.filename, options, globals()) # Init segment sb.jitter.ir_arch.do_stk_segm = True @@ -238,7 +240,7 @@ strategy = { "branch-cov": DSEPathConstraint.PRODUCE_SOLUTION_BRANCH_COV, "path-cov": DSEPathConstraint.PRODUCE_SOLUTION_PATH_COV, }[options.strategy] -dse = DSEPathConstraint(machine, produce_solution=strategy) +dse = DSEPathConstraint(machine, loc_db, produce_solution=strategy) # Attach to the jitter dse.attach(sb.jitter) diff --git a/example/symbol_exec/dse_strategies.py b/example/symbol_exec/dse_strategies.py index 3f968215..bcea2329 100644 --- a/example/symbol_exec/dse_strategies.py +++ b/example/symbol_exec/dse_strategies.py @@ -26,6 +26,7 @@ from miasm.analysis.machine import Machine from miasm.jitter.csts import PAGE_READ, PAGE_WRITE from miasm.analysis.dse import DSEPathConstraint from miasm.expression.expression import ExprMem, ExprId, ExprInt, ExprAssign +from miasm.core.locationdb import LocationDB # Argument handling parser = ArgumentParser("DSE Example") @@ -41,10 +42,12 @@ strategy = { "path-cov": DSEPathConstraint.PRODUCE_SOLUTION_PATH_COV, }[args.strategy] +loc_db = LocationDB() + # Map the shellcode run_addr = 0x40000 machine = Machine("x86_32") -jitter = machine.jitter("python") +jitter = machine.jitter(loc_db, "python") with open(args.filename, "rb") as fdesc: jitter.vm.add_memory_page( run_addr, @@ -72,7 +75,7 @@ jitter.push_uint32_t(ret_addr) jitter.init_run(run_addr) # Init a DSE instance with a given strategy -dse = DSEPathConstraint(machine, produce_solution=strategy) +dse = DSEPathConstraint(machine, loc_db, produce_solution=strategy) dse.attach(jitter) # Concretize everything except the argument dse.update_state_from_concrete() |