1

Basically, Ghidra in headless mode is divided into three phases: preScript, analysis, and postScript.

Pre/post scripts are written extending the GhidraScript class, while analysis ones extend the AbstractAnalyzer class.

When you run Ghidra in headless mode, you can specify which pre/post scripts you want to run (-preScript and -postScript options).

My questions is: how do I choose which analyses to perform?

For example, if I run this command:

./analyzeHeadless /tmp test -import ~/Downloads/test.elf -scriptPath ~/ghidra_scripts/ -postScript TestScript.java
[...]

INFO  -----------------------------------------------------
    ARM Constant Reference Analyzer           14.667 secs
[...]
    Subroutine References - One Time           0.000 secs
-----------------------------------------------------
     Total Time   86 secs
-----------------------------------------------------
 (AutoAnalysisManager)  

How can I exclude the ARM Constant Reference Analyzer and add another analysis?

2

This is possible. You can select desired analysis options in the prescript. Checkout this function - setAnalysisOption in GhidraScript class. You can also look @ this example script.

So, in your case you can do something like:

from ghidra.app.script import GhidraScript
setAnalysisOption(currentProgram, "ARM Constant Reference Analyzer", "false")
1
  • It works! Thanks. For the readers: if you want to enable some analysis that ends with the (Prototype) string, e.g., Aggressive Instruction Finder (Prototype), just use Aggressive Instruction Finder.
    – packmad
    Feb 24 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.