Created
September 23, 2023 18:41
-
-
Save 0xca7/72660e155c5a128787ffa4ddb93a1ff2 to your computer and use it in GitHub Desktop.
Binary Ninja: Highlight ARM32 bl, blx, b calls - an example script
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
""" | |
binary ninja script to highlight all "bl" instructions in | |
an ARM32 binary. makes assembly easier to read. | |
""" | |
from binaryninja import * | |
TARGET_INSTRS = ['bl', 'blx', 'b'] | |
# RGB color for bright red | |
RED_RGB = (255, 69, 29) | |
# build a highlight color from that | |
red = binaryninja.highlight.HighlightColor( | |
red=RED_RGB[0], | |
green=RED_RGB[1], | |
blue=RED_RGB[2] | |
) | |
# get all instructions | |
instrs = bv.instructions | |
# go through them, check if an instruction is in the | |
# target instructions | |
for instr in instrs: | |
(mnemonic, addr) = (instr[0][0].text, instr[1]) | |
# if we find a target instruction, highlight it | |
if mnemonic in TARGET_INSTRS: | |
# optional, remove if necessary | |
print("highlighting {} @ {}".format(mnemonic, hex(addr))) | |
# get the basic block at address x | |
block = bv.get_basic_blocks_at(addr) | |
# get the function at the basic block to get access to | |
# the set_auto_instr_highlight function | |
f = block[0].function | |
f.set_auto_instr_highlight(addr, red) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment