Skip to content

Commit

Permalink
fixup README
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hunhoff committed Jan 27, 2024
1 parent d3c14bb commit 673bb42
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 68 deletions.
105 changes: 41 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,87 +74,64 @@ Ghidrathon links your local Python installation to Ghidra using the open-source

For more information on how Jep works to embed Python in Java see their documentation [here](https://github.com/ninia/jep/wiki/How-Jep-Works).

## OS Support

Ghidrathon supports the following operating systems:

* Linux
* Windows
* macOS (x86_64)

## Requirements

The following tools are needed to build, install, and run Ghidrathon:
## Installing Ghidrathon

### Requirements
Tool | Version |Source |
|---|---|---|
| Ghidra | `>= 10.3.2` | https://ghidra-sre.org |
| Jep | `4.2.0` | https://github.com/ninia/jep |
| Gradle | `>= 7.3` | https://gradle.org/releases |
| Ghidrathon | `>= 4.0.0` | https://github.com/mandiant/Ghidrathon/releases |
| Python | `>= 3.8` | https://www.python.org/downloads |
| Jep | `4.2.0` | https://github.com/ninia/jep/releases |
| Ghidra | `>= 10.3.2` | https://github.com/NationalSecurityAgency/ghidra/releases |
| Java | `>= 17.0.0` | https://adoptium.net/temurin/releases/ |

Note: Ghidra >= 10.2 requires [JDK 17 64-bit](https://adoptium.net/temurin/releases/).

## Python Virtual Environments

Ghidrathon supports Python virtual environments. To use a Python virtual environment, simply build Ghidrathon inside your virtual environment **and** execute Ghidra inside the **same** virtual environment.

## Building Ghidrathon

**Note:** Review [Python Virtual Environments](#python-virtual-environments) before building if you would like to use a Python virtual environment for Ghidrathon.

**Note**: Building Ghidrathon requires building Jep. If you are running Windows, this requires installing the Microsoft C++ Build Tools found [here](https://visualstudio.microsoft.com/visual-cpp-build-tools/). See Jep's documentation [here](https://github.com/ninia/jep/wiki/Windows) for more information on installing Jep on Windows.

Use the following steps to build Ghidrathon for your environment:

* Install Ghidra using the documentation [here](https://htmlpreview.github.io/?https://github.com/NationalSecurityAgency/ghidra/blob/stable/GhidraDocs/InstallationGuide.html#InstallationNotes)
* Install Gradle from [here](https://gradle.org/releases)
* Download the latest Ghidrathon source release from [here](https://github.com/mandiant/Ghidrathon/releases)
* Run the following command from the Ghidrathon source directory:
* **Note:** Ghidrathon defaults to the Python binary found in your path. You can specify a different Python binary by adding the optional argument `-PPYTHON_BIN=<absolute path to Python binary>` to the command below
* **Note:** you may optionally set an environment variable named `GHIDRA_INSTALL_DIR` instead of specifying `-PGHIDRA_INSTALL_DIR`
Use the following steps to install Ghidrathon to your Ghidra environment:

1. Install `Jep`:
```python
$ python -m pip install jep==4.2.0
```
$ gradle -PGHIDRA_INSTALL_DIR=<absolute path to Ghidra install>
2. Execute `ghidrathon_configure.py`:
```python
$ python ghidrathon_configure.py <absolute_path_to_ghidra_install_dir>
```
3. Download and unzip the latest `Ghidrathon` [release](https://github.com/mandiant/Ghidrathon/releases)
4. Install the `Ghidrathon` extension (`.zip`) into Ghidra:
* Using Ghidra's UI:
* Navigate to `File > Install Extensions...`
* Click the green `+` button
* Navigate to the `Ghidrathon` extension (`.zip`)
* Click `Ok`
* Using a limited environment:
* Extract the `Ghidrathon` extension (`.zip`) to `<absolute_path_to_ghidra_install_dir>\Ghidra\Extensions`

This command installs Jep, configures Ghidrathon with the necessary Jep binaries, and builds Ghidrathon. If successful, you will find a new directory in your Ghidrathon source directory named `dist` containing your Ghidrathon extension (`.zip`). Please open a new issue if you experience any issues building Ghidrathon.

## Installing Ghidrathon

Use the following steps to install your Ghidrathon extension using the Ghidra UI:

* Start Ghidra
* Navigate to `File > Install Extensions...`
* Click the green `+` button
* Navigate to your Ghidrathon extension built earlier (`.zip`)
* Click `Ok`
* Restart Ghidra

**OR**

Extract your Ghidrathon extension (`.zip`) directly to `<absolute path to Ghidra install>\Ghidra\Extensions` to automatically enable Ghidrathon the next time that Ghidra is started. This method works great if you do not have access to the Ghidra UI when installing Ghidrathon.
### Switching Python Interpreters

### Disabling Jython
You can switch Ghidrathon to use a different Python interpreter by running `ghidrathon_configure.py` from the new Python interpreter.

Ghidrathon disables the built-in Jython script provider to avoid conflicts when Ghidra decides which provider should handle scripts with the `.py` file extension. This means existing Jython scripts cannot be executed with Ghidrathon installed. We recommend completely disabling the Jython extension.
### Python Virtual Environments

Use the following steps to disable the Jython extension:
Ghidrathon supports Python virtual environments. To use a Python virtual environment, complete steps `1` and `2` using the Python interpreter that is configured for your environment. Do the same when running `ghidrathon_configure.py` to switch the Ghidrathon to use a different interpreter.

* Open a CodeBrowser window (*not the Project Manager window*)
* Navigate to `File > Configure...`
* Click `Ghidra Core`
* Un-check `PythonPlugin`
## Building Ghidrathon

Use the following steps to enable the Jython extension:
### Requirements

* Uninstall Ghidrathon
* Enable the Jython extension using the steps outlined above
* Restart Ghidra
Tool | Version |Source |
|---|---|---|
| Ghidrathon | `>= 4.0.0` | https://github.com/mandiant/Ghidrathon/releases |
| Ghidra | `>= 10.3.2` | https://github.com/NationalSecurityAgency/ghidra/releases |
| Java | `>= 17.0.0` | https://adoptium.net/temurin/releases/ |
| Gradle | `>= 7.3` | https://gradle.org/releases |

## Using Ghidrathon
Use the following steps to build Ghidrathon:
1. Download the [supported `Jep` JAR release](https://github.com/ninia/jep/releases/download/v4.2.0/jep-4.2.0.jar) to `<absolute_path_to_ghidrathon_source_dir>/lib`
2. Execute gradle from `<absolute_path_to_ghidrathon_source_dir>`:
```
$ gradle -PGHIDRA_INSTALL_DIR=<absolute_path_to_Ghidra_install_dir>
```

See [Python 3 Interpreter Window](#python-3-interpreter-window), [Ghidra Script Manager Integration](#ghidra-script-manager-integration), and [Ghidra Headless Mode](#ghidra-headless-mode) for more information about using Ghidrathon.
The extension is stored in `<absolute_path_to_ghidrathon_source_dir>/dist`.

## Considerations

Expand Down
4 changes: 2 additions & 2 deletions data/python/tests/hello.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Run Ghidrathon unit tests.
# @author Mike Hunhoff (michael.hunhoff@mandiant.com)
# Run Ghidrathon CI tests.
# @author Mike Hunhoff (mehunhoff@google.com)
# @category Python 3
# Copyright (C) 2024 Mandiant, Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion data/python/tests/runall.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Run Ghidrathon unit tests.
# @author Mike Hunhoff (michael.hunhoff@mandiant.com)
# @author Mike Hunhoff (mehunhoff@google.com)
# @category Python 3
# Copyright (C) 2024 Mandiant, Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion ghidra_scripts/ghidrathon_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Print function basic block and instruction counts.
# @author Mike Hunhoff (michael.hunhoff@mandiant.com)
# @author Mike Hunhoff (mehunhoff@google.com)
# @category Python 3

# Copyright (C) 2024 Mandiant, Inc. All Rights Reserved.
Expand Down

0 comments on commit 673bb42

Please sign in to comment.