From 0d934d4fac7a6a2a70c4799446f0755dace72f8e Mon Sep 17 00:00:00 2001 From: Alex Groce Date: Thu, 14 Dec 2017 11:39:37 -0800 Subject: [PATCH] Attempt at OS X symbol lookup fix --- bin/deepstate/main_angr.py | 16 ++++++++++++---- bin/deepstate/main_manticore.py | 12 ++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/deepstate/main_angr.py b/bin/deepstate/main_angr.py index e8b8dcc..c2020c1 100644 --- a/bin/deepstate/main_angr.py +++ b/bin/deepstate/main_angr.py @@ -319,9 +319,14 @@ def main(): if not setup_ea: raise Exception() except: - L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`".format( + try: + setup_ea = project.kb.labels.lookup('_DeepState_Setup') + if not setup_ea: + raise Exception() + except: + L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`".format( args.binary)) - return 1 + return 1 entry_state = project.factory.entry_state( add_options={angr.options.ZERO_FILL_UNCONSTRAINED_MEMORY, @@ -345,8 +350,11 @@ def main(): # Read the API table, which will tell us about the location of various # symbols. Technically we can look these up with the `labels.lookup` API, # but we have the API table for Manticore-compatibility, so we may as well - # use it. - ea_of_api_table = project.kb.labels.lookup('DeepState_API') + # use it. + try: + ea_of_api_table = project.kb.labels.lookup('DeepState_API') + except: + ea_of_api_table = project.kb.labels.lookup('_DeepState_API') mc = DeepAngr(state=run_state) apis = mc.read_api_table(ea_of_api_table) diff --git a/bin/deepstate/main_manticore.py b/bin/deepstate/main_manticore.py index cab5cfb..5b57450 100644 --- a/bin/deepstate/main_manticore.py +++ b/bin/deepstate/main_manticore.py @@ -327,15 +327,23 @@ def main(): if not setup_ea: raise Exception("Could not find symbol") except: - L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`: {}".format( + try: + setup_ea = m._get_symbol_address('_DeepState_Setup') + if not setup_ea: + raise Exception("Could not find symbol") + except: + L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`: {}".format( args.binary, traceback.format_exc())) - return 1 + return 1 setup_state = m._initial_state mc = DeepManticore(setup_state) ea_of_api_table = m._get_symbol_address('DeepState_API') + if not ea_of_api_table: + ea_of_api_table = m._get_symbol_address('_DeepState_API') + apis = mc.read_api_table(ea_of_api_table) del mc m.add_hook(setup_ea, lambda state: run_tests(args, state, apis))