-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathcount_func_bb.py
More file actions
25 lines (20 loc) · 882 Bytes
/
Copy pathcount_func_bb.py
File metadata and controls
25 lines (20 loc) · 882 Bytes
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
from __future__ import print_function
import idaapi
import idautils
import idc
# http://moritzraabe.de/2017/01/15/ida-pro-anti-disassembly-basic-blocks-and-idapython/
# This script counts the number of basic blocks present in a function recognized by the auto-analysis of IDA
def main():
data = []
for fva in idautils.Functions():
func_name = GetFunctionName(fva)
function = idaapi.get_func(fva)
func_start_addr = function.startEA
flowchart = idaapi.FlowChart(function)
#print ("[-] Function name: %s, Start addr: %x, no. basic blocks: %d" % (func_name, func_start_addr, flowchart.size))
data.append("[-] Function name: %s, Start addr: %x, no. basic blocks: %d" % (func_name, func_start_addr, flowchart.size))
fd = open(r"func_bb.txt", "w")
fd.write(str(data))
fd.close()
if __name__ == "__main__":
main()