From f0069792c386a6f53d92fa63b908fd563e3fe6be Mon Sep 17 00:00:00 2001 From: Mark Mossberg Date: Wed, 1 Mar 2017 13:47:46 -0500 Subject: [PATCH] Misc cleanup: Rm old script, unused executor hooking functions (#38) * Rm old irrelevant example script * Make this easier to copy and paste * Rm old unused executor hooking --- examples/script/guide_exec.py | 32 -------------------------------- examples/script/state_explore.c | 3 +-- manticore/core/executor.py | 20 -------------------- 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100755 examples/script/guide_exec.py diff --git a/examples/script/guide_exec.py b/examples/script/guide_exec.py deleted file mode 100755 index 97aaa35..0000000 --- a/examples/script/guide_exec.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -from manticore import Manticore - -# This example demonstrates guiding Manticore's analysis -# by ignoring all branches to libc - -def find_lib(m, name): - for vmmap in m.memory: - if vmmap.name == 'libc.so.6': - return vmmap - -if __name__ == '__main__': - path = sys.argv[1] - # Create a new Manticore object - m = Manticore(path) - - # Now that binary is loaded, pull out where libc is mapped - lib = find_lib(m, 'libc') - if lib is None: - sys.exit(1) - - # Ensure that we ignore all possible branches to libc - # This hook returns False if we should abandon exploration - # or True to continue - def fork_hook(state): - _from, _to = lib.start, lib.start + lib.size - return not (_from <= state.cpu.PC < _to) - m.add_fork_hook(fork_hook) - - # Start path exploration. start() returns when Manticore - # finishes - m.run() diff --git a/examples/script/state_explore.c b/examples/script/state_explore.c index ad7a3eb..2edb99d 100644 --- a/examples/script/state_explore.c +++ b/examples/script/state_explore.c @@ -7,8 +7,7 @@ * $ gcc -m32 -static -g state_explore.c -o state_explore * * # Pull out the address of the branch we want to ignore - * $ ADDRESS=0x$(objdump -S state_explore | grep -A 1 'value == 0x41' | - * tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:) + * $ ADDRESS=0x$(objdump -S state_explore | grep -A 1 'value == 0x41' | tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:) * * # Run the analysis * $ python state_explore.py state_explore $ADDRESS diff --git a/manticore/core/executor.py b/manticore/core/executor.py index 3566470..dea2637 100644 --- a/manticore/core/executor.py +++ b/manticore/core/executor.py @@ -627,26 +627,6 @@ class Executor(object): return new_state - def add_hook(self, pc, callback, user_data=None): - '''This setups a hook. - Invokes callback when the specified address pc is reached - Returns an id to reference this specific hook. - ''' - if self.hooks is None: - self.hooks = {} - self.hooks.setdefault(pc, set()).add( (callback, user_data) ) - return hash( (pc, callback, user_data) ) - - def del_hook(self, n): - ''' Deletes the hook by id ''' - for pc, callback, user_data in self.hooks.items(): - if hash((pc, callback, user_data)) == n: - self.hooks[pc].remove((callback, user_data)) - if len(self.hooks[pc]) == 0 : - del self.hooks[pc] - return True - return False - def generate_testcase(self, state, message = 'Testcase generated'): with self._lock: self._test_number.value += 1