1

I'm running a Ghidra python script in headless mode from the commandline specifying my script as a preScript.
e.g. ./analyzeHeadless project_path project_name -preScript pre.py -import my_exec_file

I would like so set the HeadlessContinuationOption in that script.

The equivalent in a Java preScript will be:

import ghidra.app.util.headless.HeadlessScript;

public class Pre extends HeadlessScript {
  @Override
  public void run() throws Exception {
      setHeadlessContinuationOption(HeadlessContinuationOption.ABORT);
  }
}

However in the python there is no class to inherit from HeadlessScript (and setHeadlessContinuationOption in an instance method of that abstract class). I just write the script in the global scope.

I've tried to create a class similar to how the Java script is written, but nothing instantiate it. I've also tried to instantiate it and call run myself and call setHeadlessContinuationOption on that instance in run, but it doesn't have the desired effect (the abort option is being ignore and importing of the exec file continues).
Here's this code (that doesn't work)

from ghidra.app.util.headless import HeadlessScript

class Pre(HeadlessScript):
        def run(self):
                self.setHeadlessContinuationOption(self.HeadlessContinuationOption.ABORT)
Pre().run()

So how can I set setHeadlessContinuationOption(HeadlessContinuationOption.ABORT) in a python preScript?

Thanks.

Seki
  • 11,135
  • 7
  • 46
  • 70
Eran
  • 2,324
  • 3
  • 22
  • 27
  • Wanted to add a Ghidra tag but it doesn't exist and I don't have enough reputation to create it. If someone mods this question, it will be useful to have this tag. – Eran Jul 10 '19 at 06:12
  • why are you using self to access? you can access it directly - `setHeadlessContinuationOption(HeadlessContinuationOption.ABORT)` – R4444 Sep 28 '19 at 00:48
  • @R4444, Thanks for commenting, however, it's not accessible directly (it's not in `globals()` - again, I'm running in headless mode). As for why I'm using self, as I wrote, it's an example of a failed attempt, just before running out of ideas and posting here :) – Eran Sep 28 '19 at 06:18
  • 1
    Tried `HeadlessScript.setHeadlessContinuationOption(HeadlessScript.HeadlessContinuationOption.ABORT)`, but it demands two arguments. Best way is to raise an issue or question in their github. I am sure someone will help. – R4444 Sep 30 '19 at 17:00

0 Answers0