- Need to create
ghidra.jar
and place into thelib
directory. - run below script to create the directory structure
- put the following contents in the
src/main/java/MyProject.java
fileimport ghidra.app.script.GhidraScript; public class MyProject extends GhidraScript { @Override public void run() throws Exception { println("Hello World"); } }
- Enter
gradle build
at the root directory. - Open in Spacemacs.
Last active
September 7, 2022 20:04
-
-
Save jstaursky/7caae3f964e8f6ac032d8c6985319265 to your computer and use it in GitHub Desktop.
Ghidra plugin development with emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage ./<this-script> <project-name> | |
project="${1:-MyProject}" | |
toplevel='src,lib' | |
echo -n ${toplevel} | xargs -d, -I% mkdir -p ${project}/% | |
mkdir -p ${project}/src/main/java | |
touch ${project}/src/main/java/${project}.java | |
touch ${project}/settings.gradle | |
# create an initial build.gradle file | |
cat << EOF > ${project}/build.gradle | |
apply plugin: 'java' | |
dependencies { | |
implementation fileTree (dir: 'lib', include: ['*.jar']) | |
} | |
EOF | |
# Readme | |
cat << EOF > ${project}/README.org | |
The file =src/main/java/<file-name>.java= | |
must have "=public class <file-name> ...=" in it. | |
to compile enter | |
=gradle build= at the root directory. | |
You should be able to drop any =jar= file into the =lib= directory | |
and be able to import it for use in the =src/main/java/<file-name>.java= file. | |
EOF | |
echo "created project folder '${project}'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
GHIDRA_HOME="$HOME/ghidra_10.1.5_PUBLIC" | |
FILENAME=$1 | |
SCRIPT=$2 | |
DIR=${SCRIPT%/*} | |
TMP_PROJECT_NAME=$RANDOM | |
CMD="$GHIDRA_HOME/support/analyzeHeadless \"/tmp\" \"$TMP_PROJECT_NAME\" -deleteProject " | |
$CMD -import "$FILENAME" -scriptPath $DIR -postScript $SCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment