Skip to content

Commit

Permalink
Improved string xref algo
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgprado committed Oct 19, 2018
1 parent 63584ae commit 29ffc6e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions IDAPlugin/jarvis/jarvis/core/BinaryAnalysis.py
Expand Up @@ -92,26 +92,24 @@ def get_string_references(self):
Get all references to strings within the current function
@return: list of tuples [(xref addr, s), ...]
"""
f = get_func(ScreenEA())
f = get_func(here())
if not f:
# get_func returned None
print '[x] This does not look like a function...'
return []

start = f.startEA
end = f.endEA

s_refs = []

# TODO: This algorithm can be improved :)
# For now I will make do
for s_ea, s in self.cache.string_list:
# Calculate xrefs
for ref in XrefsTo(s_ea, True):
ref_addr = ref.frm
# Within current function?
if ref_addr >= start and ref_addr <= end:
s_refs.append((ref_addr, s))
for ins_ea in FuncItems(f.startEA):
for xref in XrefsFrom(ins_ea, True):
if xref.type != 1: # Data_Offset
continue

to = xref.to
for s_ea, s in self.cache.string_list:
# Gotta love unpacking
if to == s_ea:
s_refs.append((xref.frm, s))

return s_refs

Expand Down

0 comments on commit 29ffc6e

Please sign in to comment.