Skip to content

Commit

Permalink
Minor refactor to check for all sinks in SARecon in a single function
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdoupe committed Feb 26, 2022
1 parent 9b647af commit 3c72d44
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions arbiter/master_chief/sa_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,32 @@ def _is_ret(self, arglist):
def sinks(self):
return self.map.keys()

def _check_callees(self, func, target, callee):
def _check_callees(self, func, target, sinks):
"""
Check the `func` in the `target` for any call to any function name in set `sinks`
"""

for site in sorted(func.get_call_sites()):
name = self._callee_name(func, site)

if callee not in name:
continue
arglist = self.map[callee]

if self._is_ret(arglist):
logger.debug("Finding ret block for %s @ 0x%x" % (callee, site))
site = self._find_ret_block(func)
if site is None:
# No ret instruction
for callee in sinks:
if callee not in name:
continue
arglist = self.map[callee]

if self._is_ret(arglist):
logger.debug("Finding ret block for %s @ 0x%x" % (callee, site))
site = self._find_ret_block(func)
if site is None:
# No ret instruction
continue

target.add_node(site, None, self._cfg, arglist)
target.add_node(site, None, self._cfg, arglist)

def _check_sinks(self, func):
target = SA1_Target(func)

for x in self.sinks:
self._check_callees(func, target, x)
self._check_callees(func, target, self.sinks)

if target.node_count > 0:
self._targets.append(target)
Expand Down

0 comments on commit 3c72d44

Please sign in to comment.