-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit adedbd0
Showing
16 changed files
with
889 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
build | ||
*.pyc | ||
*.class | ||
*.log | ||
*.jar | ||
!gradle/wrapper/gradle-wrapper.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
.gradle | ||
test | ||
lib | ||
dist |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM ubuntu:latest | ||
|
||
ENV LANG C.UTF-8 | ||
ENV LC_ALL C.UTF-8 | ||
|
||
ENV GRADLE_VERSION 7.6 | ||
ENV GHIDRA_INSTALL_DIR /ghidra | ||
ENV GRADLE_USER_HOME /home/gradle | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
ARG USER=gradle | ||
ARG GRADLE_CHECKSUM=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b | ||
|
||
RUN apt-get -yq update \ | ||
&& apt-get -yq install openjdk-17-jre openjdk-17-jdk wget unzip \ | ||
&& groupadd --gid ${GID} gradle \ | ||
&& useradd -m ${USER} --uid=${UID} --gid ${GID} | ||
|
||
COPY ghidrachatgpt /build | ||
COPY data/entry /entry | ||
|
||
RUN chmod +x /entry \ | ||
&& chown -R ${USER}:${USER} /build | ||
|
||
RUN wget -q -O gradle.zip "https://downloads.gradle-dn.com/distributions/gradle-${GRADLE_VERSION}-bin.zip" \ | ||
&& echo "${GRADLE_CHECKSUM} gradle.zip" | sha256sum --check - \ | ||
&& unzip gradle.zip && rm gradle.zip | ||
|
||
USER ${USER} | ||
WORKDIR /build | ||
|
||
CMD ["/entry"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# GhidraChatGPT | ||
A plugin that brings the power of ChatGPT to Ghidra! | ||
|
||
![](./assets/ghidrachatgpt.png) | ||
|
||
## Installation | ||
The plugin is available as a [release](https://github.com/likvidera/GhidraChatGPT/releases) and you can build it locally by cloning this repository. | ||
|
||
### Release | ||
1. Download the latest release from this repository. The release version must match your Ghidra version. | ||
2. Copy or move the archive to the `GHIDRA_INSTALL_DIR/Extensions/Ghidra` directory | ||
3. In the Project window of Ghidra: File > Install Extension > Enable the GhidraChatGPT extension | ||
4. Restart Ghidra | ||
5. In the CodeBrowser window of Ghidra: File > Configure > Plugin icon in the top right > Enable the GhidraChatGPT plugin | ||
|
||
### Build | ||
The plugin can be built with or without docker. If it is built without docker then you need to manually resolve the dependencies such as gradle and java. The plugin is automatically added to the Ghidra Extension directory in both cases. | ||
|
||
1. Clone this repository | ||
2. Set the `GHIDRA_INSTALL_DIR` environment variable e.g. `export GHIDRA_INSTALL_DIR=YOUR_GHIDRA_INSTALL_DIR` | ||
3. Build using docker: `./build.sh -d` or without: `./build.sh` | ||
4. In the Project window of Ghidra: File > Install Extension > Enable the GhidraChatGPT extension | ||
5. Restart Ghidra | ||
6. In the CodeBrowser window of Ghidra: File > Configure > Plugin icon in the top right > Enable the GhidraChatGPT plugin | ||
|
||
## Usage | ||
The plugin's features and settings can be accessed via the `Tools` menu in the Ghidra CodeBrowser window. | ||
|
||
### Options | ||
The following options can be set via environment variables or via the settings in the `Tools` menu: | ||
|
||
* `OPENAI_TOKEN`: set this to your OpenAI token e.g. `export OPENAI_TOKEN=YOUR_OPENAI_TOKEN` or the plugin will ask for your OpenAI token. | ||
* `OPENAI_MAX_TOKENS`: set this to the max amount of tokens per ChatGPT request e.g. `export OPENAI_MAX_TOKENS=250` or a default value of `250` will be used. | ||
|
||
### Features | ||
**Identify Function** (Tools > GhidraChatGPT > Identify Function) | ||
Attempts to identify the purpose of the current function and potential open source references with the help of ChatGPT. The response from ChatGPT will be added as a comment above the function. | ||
|
||
**Find Vulnerabilities** (Tools > GhidraChatGPT > Find Vulnerabilities) | ||
Attempts to discover all potential vulnerabilities in the current function with the help of ChatGPT. The response from ChatGPT will be added as a comment above the function. | ||
|
||
**Beautify Function** (Tools > GhidraChatGPT > Beautify Function) | ||
Attempts to beautify the current function with the help of ChatGPT. | ||
|
||
### Settings | ||
**Update OpenAI Token** (Tools > GhidraChatGPT > Settings > Update OpenAI Token) | ||
This will update the currently used Open AI Token for the ChatGPT requests | ||
|
||
**Update Max Tokens** (Tools > GhidraChatGPT > Settings > Update Max Tokens) | ||
This will update the max amounts of tokens used for the ChatGPT requests | ||
|
||
## Credits | ||
All the currently released ChatGPT projects for the inspiration |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
VERSION=10.2.2 | ||
GID=$(id -g) | ||
DOCKER_GHIDRA_IMG="ghidra-chatgpt:$VERSION" | ||
DOCKER_BUILD=0 | ||
FORCE_BUILD=0 | ||
DEV_BUILD=0 | ||
GHIDRA_PATH=${GHIDRA_INSTALL_DIR} | ||
GHIDRA_MNT_DIR=/ghidra | ||
|
||
SCRIPT_DIR=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) | ||
cd "$SCRIPT_DIR" | ||
|
||
function docker_build() { | ||
echo "[+] Building the GhidraChatGPT Plugin" >&2 | ||
|
||
if [ "$(docker images -q "$DOCKER_GHIDRA_IMG" 2> /dev/null)" == "" ] || [ $FORCE_BUILD -ne 0 ]; then | ||
docker build \ | ||
--build-arg UID=$UID \ | ||
--build-arg GID=$GID \ | ||
-t "$DOCKER_GHIDRA_IMG" \ | ||
. | ||
fi | ||
|
||
docker run -t --rm \ | ||
--user $UID:$GID \ | ||
--mount type=bind,source="$GHIDRA_PATH",target="$GHIDRA_MNT_DIR" \ | ||
--entrypoint /entry "$DOCKER_GHIDRA_IMG" | ||
} | ||
|
||
function build() { | ||
echo "[+] Building the GhidraChatGPT Plugin" >&2 | ||
|
||
export GHIDRA_INSTALL_DIR="$GHIDRA_PATH" | ||
pushd ghidrachatgpt > /dev/null 2>&1 | ||
gradle | ||
|
||
APPNAME=$(ls dist/*.zip | xargs basename) | ||
cp dist/*.zip "$GHIDRA_PATH/Extensions/Ghidra" | ||
echo "[+] Built $APPNAME and copied it to $GHIDRA_PATH/Extensions/Ghidra/$APPNAME" | ||
popd > /dev/null 2>&1 | ||
} | ||
|
||
function usage() { | ||
echo "Usage: $0 [OPTION...] [CMD]" >&2 | ||
echo " -p PATH PATH to local Ghidra installation" >&2 | ||
echo " -d Build with Docker" >&2 | ||
echo " -f Force rebuild of the Docker image" >&2 | ||
echo " -h Show this help" >&2 | ||
} | ||
|
||
while getopts "p:dfh" opt; do | ||
case "$opt" in | ||
p) | ||
GHIDRA_PATH=$(realpath ${OPTARG}) | ||
;; | ||
d) | ||
DOCKER_BUILD=1 | ||
;; | ||
f) | ||
FORCE_BUILD=1 | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
echo "Unknown option: $opt" >&2 | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
if [ -z $GHIDRA_PATH ] || [ ! -d $GHIDRA_PATH ] ; then | ||
echo "GHIDRA_PATH is not configured or is not a directory" | ||
exit 1 | ||
fi | ||
|
||
if [ $DOCKER_BUILD -ne 0 ] ; then | ||
docker_build | ||
else | ||
build | ||
fi | ||
|
||
exit 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
"/gradle-${GRADLE_VERSION}/bin/gradle" | ||
|
||
APPNAME=$(ls dist/*.zip | xargs basename) | ||
cp dist/*.zip "${GHIDRA_INSTALL_DIR}/Extensions/Ghidra" | ||
|
||
echo "[+] Built $APPNAME and copied it to YOUR_GHIDRA_INSTALL/Extensions/Ghidra/$APPNAME" |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* ### | ||
* IP: GHIDRA | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// Builds a Ghidra Extension for a given Ghidra installation. | ||
// | ||
// An absolute path to the Ghidra installation directory must be supplied either by setting the | ||
// GHIDRA_INSTALL_DIR environment variable or Gradle project property: | ||
// | ||
// > export GHIDRA_INSTALL_DIR=<Absolute path to Ghidra> | ||
// > gradle | ||
// | ||
// or | ||
// | ||
// > gradle -PGHIDRA_INSTALL_DIR=<Absolute path to Ghidra> | ||
// | ||
// Gradle should be invoked from the directory of the project to build. Please see the | ||
// application.gradle.version property in <GHIDRA_INSTALL_DIR>/Ghidra/application.properties | ||
// for the correction version of Gradle to use for the Ghidra installation you specify. | ||
|
||
//----------------------START "DO NOT MODIFY" SECTION------------------------------ | ||
def ghidraInstallDir | ||
|
||
if (System.env.GHIDRA_INSTALL_DIR) { | ||
ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR | ||
} | ||
else if (project.hasProperty("GHIDRA_INSTALL_DIR")) { | ||
ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR") | ||
} | ||
|
||
if (ghidraInstallDir) { | ||
apply from: new File(ghidraInstallDir).getCanonicalPath() + "/support/buildExtension.gradle" | ||
} | ||
else { | ||
throw new GradleException("GHIDRA_INSTALL_DIR is not defined!") | ||
} | ||
//----------------------END "DO NOT MODIFY" SECTION------------------------------- | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'com.theokanning.openai-gpt3-java:client:0.8.1' | ||
implementation 'org.json:json:20220924' | ||
} | ||
|
||
// Exclude additional files from the built extension | ||
// Ex: buildExtension.exclude '.idea/**' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=GhidraChatGPT | ||
description=Brings the power of ChatGPT to Ghidra | ||
author=likvidera | ||
createdOn= | ||
version=@extversion@ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "GhidraChatGPT" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version='1.0' encoding='ISO-8859-1' ?> | ||
<!-- | ||
This is an XML file intended to be parsed by the Ghidra help system. It is loosely based | ||
upon the JavaHelp table of contents document format. The Ghidra help system uses a | ||
TOC_Source.xml file to allow a module with help to define how its contents appear in the | ||
Ghidra help viewer's table of contents. The main document (in the Base module) | ||
defines a basic structure for the | ||
Ghidra table of contents system. Other TOC_Source.xml files may use this structure to insert | ||
their files directly into this structure (and optionally define a substructure). | ||
In this document, a tag can be either a <tocdef> or a <tocref>. The former is a definition | ||
of an XML item that may have a link and may contain other <tocdef> and <tocref> children. | ||
<tocdef> items may be referred to in other documents by using a <tocref> tag with the | ||
appropriate id attribute value. Using these two tags allows any module to define a place | ||
in the table of contents system (<tocdef>), which also provides a place for | ||
other TOC_Source.xml files to insert content (<tocref>). | ||
During the help build time, all TOC_Source.xml files will be parsed and validated to ensure | ||
that all <tocref> tags point to valid <tocdef> tags. From these files will be generated | ||
<module name>_TOC.xml files, which are table of contents files written in the format | ||
desired by the JavaHelp system. Additionally, the genated files will be merged together | ||
as they are loaded by the JavaHelp system. In the end, when displaying help in the Ghidra | ||
help GUI, there will be on table of contents that has been created from the definitions in | ||
all of the modules' TOC_Source.xml files. | ||
Tags and Attributes | ||
<tocdef> | ||
-id - the name of the definition (this must be unique across all TOC_Source.xml files) | ||
-text - the display text of the node, as seen in the help GUI | ||
-target** - the file to display when the node is clicked in the GUI | ||
-sortgroup - this is a string that defines where a given node should appear under a given | ||
parent. The string values will be sorted by the JavaHelp system using | ||
a javax.text.RulesBasedCollator. If this attribute is not specified, then | ||
the text of attribute will be used. | ||
<tocref> | ||
-id - The id of the <tocdef> that this reference points to | ||
**The URL for the target is relative and should start with 'help/topics'. This text is | ||
used by the Ghidra help system to provide a universal starting point for all links so that | ||
they can be resolved at runtime, across modules. | ||
--> | ||
|
||
|
||
<tocroot> | ||
<!-- Uncomment and adjust fields to add help topic to help system's Table of Contents | ||
<tocref id="Ghidra Functionality"> | ||
<tocdef id="HelpAnchor" text="My Feature" target="help/topics/my_topic/help.html" /> | ||
</tocref> | ||
--> | ||
</tocroot> |
Oops, something went wrong.