-
Book Overview & Buying
-
Table Of Contents
Ghidra Software Reverse Engineering for Beginners
By :
As mentioned before, you can use Ghidra headless mode to run scripts before and after the analysis of a file (pre-scripts and post-scripts, respectively).
As you know, non-GUI scripts run without human interaction, so it is recommended to write a headless script extending from the HeadlessScript class that, at the same time, extends from the already-known GhidraScript class.
But extending from HeadlessScript is not a must. You can write a headed script extending from the GhidraScript class directly and it will also work when running in headless mode, but if some GUI-specific method is called, then ImproperUseException will be thrown.
A similar thing happens in reverse. When a script extending from HeadlessScript is running on Ghidra headed mode, if a HeadlessScript-only method is called, an exception will also be thrown.
Let's adapt an existing Ghidra script currently extending from GhidraScript in order to extend from HeadlessScript...