Last active
May 31, 2024 04:49
-
-
Save msymt/ced6d8c12cc7a4b1b104b0ff81ca219a to your computer and use it in GitHub Desktop.
Ghidraでバイナリの基本ブロックを計算するスクリプト
This file contains hidden or 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
# ref: https://reverseengineering.stackexchange.com/questions/23469/way-to-get-basic-blocks-of-a-binary-using-ghidra | |
from ghidra.program.model.block import BasicBlockModel | |
from ghidra.util.task import TaskMonitor | |
bbm = BasicBlockModel(currentProgram) | |
blocks = bbm.getCodeBlocks(TaskMonitor.DUMMY) | |
block = blocks.next() | |
bbl_cnt = 0 | |
while block: | |
bbl_cnt += 1 | |
print "Label: {}".format(block.name) | |
print "Min Address: {}".format(block.minAddress) | |
print "Max address: {}".format(block.maxAddress) | |
block = blocks.next() | |
print "total number of basic block: {}".format(bbl_cnt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
コマンドラインから実行する方法。ghidraのheadless modeで可能。