I feel like all the Binary Ninja Python scripts I see are:
- written specifically for commercial license headless usage
- some super complicated automated pwn thing written by a PhD
So for the heck of it, here's (almost) how I solved PicoCTF's Bizz Fuzz task in Binary Ninja. This script is meant for use with the Personal license inside the GUI.
Load up the binary provided, let it finish analysing, and select the script below from File->Run Script...
The code isn't sophisticated or pretty, it was written trying to solve the task, not to be pretty and shared :P
The "only" change from the code I used to solve the task initially is that my initial code didn't have any kind of branching search for the call chain from main to the bof fgets call 😅
I somehow just got INCREDIBLY lucky and just iterating through the callers from the bof fgets call and always picking the first one, I lucked into the optimal chain 😂
Sharing that script seemed silly, so I whipped up a very quick & dirty depth limited search.
The code runs in about 30 seconds on my PC, so there's a lot of room for optimisation, but I'm honestly happy with it as-is.
I also think it shows off how easy it is to write quick scripts for automating Binja for tasks like this.