└── xrefto_counter.py /xrefto_counter.py: -------------------------------------------------------------------------------- 1 | from idautils import * 2 | from idc import * 3 | from idaapi import * 4 | 5 | class dictionary(dict): 6 | def __init__(self): 7 | self = dict() 8 | 9 | def add(self, key, value): 10 | self[key] = value 11 | 12 | xref_dict = dictionary() 13 | 14 | for segea in Segments(): 15 | 16 | if (idc.get_segm_name(segea) == ".text"): #check if in .text segment 17 | for funcea in Functions(segea, get_segm_end(segea)): 18 | count = 0 19 | for xrefs in XrefsTo(funcea, flags=0): 20 | if (str(XrefTypeName(xrefs.type)) in "Code_Near_Call" ): 21 | count+=1 22 | if count != 0: # don't list functions without referation 23 | xref_dict.add(hex(funcea), count) 24 | 25 | print(sorted(xref_dict.items(), key=lambda x:x[1])) 26 | --------------------------------------------------------------------------------