4

I have a plugin that I want to install for Ghidra.

The current way to install the plugin is to go to the file->Install Extension in the project window, and add my plugin there. However, in my scenario, I don't have an access to the GUI and I want to deploy Ghidra for Headless Analysis.

For some reason, just copying the plugin files to <ghidra_home>\Ghidra\Extensions doesn't do the trick, and it looks like it only partially installs the plugin, and only the GUI way does the complete job.

Any idea how can I programmatically install plugins for Ghidra?

6
  • 1
    According to the official documentation unzipping the extension .zip into the <GhidraInstallDir>/Ghidra/Extensions folder should be enough. And it explicitly states that this is the way to go for full headless installs. What do you mean by "only partially installs the plugin"? Aug 18, 2021 at 13:33
  • I'm installing the following plugin: github.com/astrelsky/Ghidra-Cpp-Class-Analyzer . Upon copying the files to the described folder, I am able to access classes from the extension - for example from cppclassanalyzer.utils import CppClassAnalyzerUtils successes, but it is not fully initalized because CppClassAnalyzerUtils.getManager(currentProgram) returns None. Only a full isntallation by the GUI makes it return the class.. Aug 18, 2021 at 15:14
  • 1
    I have vague memories of running into some issue like that too with this specific plugin. Turns out I Actually have a local branch of the repo called plugin_not_activated, but the changes in that branch aren't quite clear how this would fix it. Aug 18, 2021 at 15:50
  • 1
    This is most likely some issue with this specific plugin, that branch I had was for this PR github.com/astrelsky/Ghidra-Cpp-Class-Analyzer/pull/41. IIRC CppClassAnalyzerUtils.getManager(currentProgram) returns the Service and this Service is only available for within the GUI (specifically in a tool IIRC). I think this would be worth opening on issue about Aug 18, 2021 at 15:57
  • 1
    Ah, that might have been why I didn't dig into this further, I'll quickly dive into the code of GhidraTool.java to see if there is some obvious way to do this headless Aug 19, 2021 at 7:51

2 Answers 2

2

According to the official documentation unzipping the extension .zip into the <GhidraInstallDir>/Ghidra/Extensions folder should be enough.

As you specified in the comments the specific plugin this is about is Ghidra C++ Class and Run Time Type Information Analyzer and it only works after going through the initial "New extension plugins detected. Would you like to configure them?" dialog on starting the Ghidra GUI.

This dialog is part of the method ghidra.framework.project.tool.GhidraTool#checkForNewExtensions and the actual install process happens ghidra.framework.project.tool.GhidraTool#addInstalledExtensions.

The problem is that during the headless processing there is no tool available, i.e. state.tool is null and these methods don't seem to be intended to be run in a headless context. I don't quite understand what specifically makes it work afterwards, but overall I am reasonably confident that this is an issue with the specific plugin, and the fact that it requires the ServiceManager to provide the service even for the analyzers (which should be available in headless mode after unzipping).

So this is an issue with this specific plugin which is somewhat hinted at in an already existing issue

0

Instead of modifying the install directory, you can put the extension into your home directory.

You should manually unzip the extension .zip to ~/.ghidra/.ghidra_10.1.1_PUBLIC/Extensions/. (Replace the Ghidra version with whichever you're using.)

e.g.

cd ~/.ghidra/.ghidra_10.1.1_PUBLIC/Extensions/
unzip ~/Downloads/ghidra_10.1.1_PUBLIC_20220127_BinExport.zip 

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.