-
Notifications
You must be signed in to change notification settings - Fork 3
/
analyzerstatistics.py
36 lines (29 loc) · 1.63 KB
/
analyzerstatistics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# idaDiscover plugin - by Javier Vicente Vallejo - @vallejocc
#
from ida_defines import *
class AnalyzerStatistic():
####################################################################################################
################################################################################################
def __init__(self, gPrinter):
self.gPrinter = gPrinter
################################################################################################
def SearchMostUsedFunctions(self, nfuncs=0xffffffff, loopsAnalz=None):
l = []
#TODO: discard functions with a name already set?
for ea in IDAAPI_Segments():
for funcea in IDAAPI_Functions(IDAAPI_SegStart(ea), IDAAPI_SegEnd(ea)):
refs = []
for r in IDAAPI_XrefsTo(funcea, 0): refs.append(r)
l.append((funcea, len(refs)))
l = sorted(l, key=lambda l: l[1], reverse=True)
i = 0
self.gPrinter.doPrint("List of functions ordered by number of references:", "functions")
self.gPrinter.doPrint("----------------------------------------------------------", "functions")
while i<nfuncs and i<len(l):
functags = loopsAnalz.GetFuncTags(l[i][0])
self.gPrinter.doPrint("Function %x - references %x ( %s ) - ( %s )" % (l[i][0], l[i][1], IDAAPI_GetFunctionName(l[i][0]), functags), "functions")
i += 1
self.gPrinter.doPrint("----------------------------------------------------------", "functions")
self.gPrinter.doPrint("", "functions")
self.gPrinter.doPrint("", "functions")