Skip to content

Instantly share code, notes, and snippets.

@apkunpacker
Created August 18, 2023 08:56
Show Gist options
  • Save apkunpacker/83d56b142f1f914057eb059457eb2a90 to your computer and use it in GitHub Desktop.
Save apkunpacker/83d56b142f1f914057eb059457eb2a90 to your computer and use it in GitHub Desktop.
from idautils import Segments, Functions, XrefsTo, XrefTypeName
from idc import get_segm_name, get_segm_end
class Dictionary(dict):
def add(self, key, value):
self[key] = value
xref_dict = Dictionary()
for segea in Segments():
if get_segm_name(segea) == ".text":
for funcea in Functions(segea, get_segm_end(segea)):
count = 0
for xrefs in XrefsTo(funcea, flags=0):
if str(XrefTypeName(xrefs.type)) == "Code_Near_Call":
count += 1
if count != 0:
xref_dict.add(hex(funcea), count)
for func, count in sorted(xref_dict.items(), key=lambda x: x[1]):
print(f"{func}: {count} references")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment