https://github.com/smx-smx/ghidrascriptproject
Example skeleton to create self contained Ghidra Scripts
https://github.com/smx-smx/ghidrascriptproject
ghidra java kotlin maven osgi script
Last synced: about 2 months ago
JSON representation
Example skeleton to create self contained Ghidra Scripts
- Host: GitHub
- URL: https://github.com/smx-smx/ghidrascriptproject
- Owner: smx-smx
- Created: 2022-02-13T17:26:45.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T22:45:15.000Z (over 1 year ago)
- Last Synced: 2025-01-26T07:24:51.523Z (3 months ago)
- Topics: ghidra, java, kotlin, maven, osgi, script
- Language: Java
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## GhidraScriptProject
This project illustrates how to (ab)use Ghidra to run precompiled scripts from external .jar files.### Features
This project enables you to write Ghidra Scripts using your favourite IDE, using any additional library from maven and/or
any maven build plugin.This in turn makes it possible to use Kotlin, Scala, or any other JVM language.
### Usage
#### 1. Install the archetype after cloning this repository
```console
mvn install
```#### 2. Generate a new project
Run the following command, replacing the variables with your desired values**IMPORTANT**: Set ${ghidra_path} to your Ghidra installation directory
```console
mvn archetype:generate \
-DarchetypeGroupId=com.smx \
-DarchetypeArtifactId=ghidra-script \
-DarchetypeVersion=1.0-SNAPSHOT \
-DinteractiveMode=false \
-DoutputDirectory=${project_output_directory} \
-DgroupId="${project_group_id}" \
-DartifactId="${project_artifact_id}" \
-Dversion="${project_version}" \
-DghidraPath="${ghidra_path}"
```#### 3. Build the generated project
```console
cd "${project_output_directory}/${project_artifact_id}"
mvn package
```#### 4. Load the generated Jar in Ghidra.
It should appear highlighted in green in the Scripts Manager, indicating it was loaded successfully

If it fails loading, make sure any Maven Dependency is either embedded in the produced JAR (done by default in the generated project with `maven-shade-plugin`) or provided as an OSGI bundle
#### 5. Install the "launcher" Ghidra script (only for the first time)
Copy `./src/main/java/InvokeBundleScript.java` to your Ghidra scripts directory, e.g. `$HOME/ghidra_scripts`#### 6. Run the launcher script
Run `InvokeBundleScript` from the Scripts Manager, and choose the script class from the loaded bundle