Created
July 22, 2022 03:33
-
-
Save morimolymoly/6b8eee839ce1b2e482935c1ba5e62c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ghidra.program.model.block import BasicBlockModel | |
from ghidra.util.task import ConsoleTaskMonitor | |
fm = currentProgram.getFunctionManager() | |
functions = fm.getFunctions(True) | |
blockModel = BasicBlockModel(currentProgram) | |
monitor = ConsoleTaskMonitor() | |
for func in functions: | |
print("Basic block details for function '{}':".format(func.getName())) | |
blocks = blockModel.getCodeBlocksContaining(func.getBody(), monitor) | |
# print firstblock | |
print("\t[*] {} ".format(func.getEntryPoint())) | |
bbnum = 1 | |
edgenum = 0 | |
# print any remaining blocks | |
while(blocks.hasNext()): | |
bb = blocks.next() | |
bbnum += 1 | |
dest = bb.getDestinations(monitor) | |
while(dest.hasNext()): | |
dbb = dest.next() | |
edgenum += 1 | |
print("bb: {} edge: {}".format(bbnum, edgenum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment