Environment:416rehman DeepZero Ghidra
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Reverse_Engineering |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Ghidra headless analysis installation (`analyzeHeadless`) pointed at by `GHIDRA_INSTALL_DIR`, used by the GhidraDecompile processor for binary decompilation.
Description
This environment provides the NSA Ghidra reverse-engineering suite, invoked in headless mode by the `GhidraDecompile` MapProcessor. The processor calls `analyzeHeadless` (or `analyzeHeadless.bat` on Windows) located under `<ghidra_install_dir>/support/`. Each worker spawns a separate JVM holding a full program database in memory (~4 GiB per worker). Ghidra version 11.0.3 (build 20240410) is what CI tests against. The installation directory is supplied via the `GHIDRA_INSTALL_DIR` environment variable or the processor's `ghidra_install_dir` config field, expanded from YAML with `${VAR}` syntax.
Usage
Use this environment when running any pipeline that includes the `GhidraDecompile` processor (e.g. the loldrivers BYOVD pipeline). It is the mandatory prerequisite for the GhidraDecompile implementation. The processor's `validate()` method checks that the install dir exists and contains `analyzeHeadless` at pipeline load time.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, or Windows | `analyzeHeadless` vs `analyzeHeadless.bat` selected by platform |
| Hardware | ~4 GiB RAM per parallel worker | Auto worker count is RAM-bounded; see Heuristic:416rehman_DeepZero_Memory_Safe_Parallelism |
| Disk | Several hundred MB for Ghidra install + project files | Ghidra archive is ~400 MB |
Dependencies
System Packages
- Ghidra >= 11.0.3 (headless `analyzeHeadless` script under `support/`)
- JDK 17+ (see Environment:416rehman_DeepZero_JDK)
Python Packages
- Python >= 3.11 (base DeepZero requirement)
- `deepzero` core package
Credentials
No credentials required. Ghidra is an open-source local tool.
Required environment variables:
- `GHIDRA_INSTALL_DIR` — path to the Ghidra installation root (containing `support/analyzeHeadless`)
- `JAVA_HOME` — path to the JDK (optional; can also be set via processor's `java_home` config)
- `DEEPZERO_MAX_FUNCTIONS` — optional limit on functions analyzed (set by processor at runtime)
- `DEEPZERO_MAX_DEPTH` — optional call-graph depth limit (set by processor at runtime)
Quick Install
# Download Ghidra 11.0.3 (CI-pinned version)
GHIDRA_VERSION="11.0.3"
GHIDRA_BUILD="20240410"
ZIP="ghidra_${GHIDRA_VERSION}_PUBLIC_${GHIDRA_BUILD}.zip"
wget "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_${GHIDRA_VERSION}_build/${ZIP}" -O ghidra.zip
# Verify checksum (CI value)
echo "2462a2d0ab11e30f9e907cd3b4aa6b48dd2642f325617e3d922c28e752be6761 ghidra.zip" | sha256sum -c -
# Unpack
mkdir -p ~/ghidra
unzip -q ghidra.zip -d ~/ghidra
rm ghidra.zip
# Point DeepZero at it
export GHIDRA_INSTALL_DIR="$HOME/ghidra/ghidra_${GHIDRA_VERSION}_PUBLIC"
Code Evidence
Install-dir validation from `ghidra_decompile.py:122-134`:
def validate(self, ctx: ProcessorContext) -> list[str]:
if not self.config.ghidra_install_dir:
return [
"ghidra_install_dir is required - set it in config or via ${GHIDRA_INSTALL_DIR}"
]
ghidra_dir = Path(self.config.ghidra_install_dir)
if not ghidra_dir.exists():
return [f"ghidra not found at {ghidra_dir}"]
try:
self._find_analyze_headless(ghidra_dir)
except FileNotFoundError as e:
return [str(e)]
return []
Headless binary discovery (platform-aware) from `ghidra_decompile.py:349-366`:
def _find_analyze_headless(self, ghidra_dir: Path) -> Path:
if sys.platform == "win32":
bat = ghidra_dir / "support" / "analyzeHeadless.bat"
if bat.exists():
return bat
else:
sh = ghidra_dir / "support" / "analyzeHeadless"
if sh.exists():
return sh
# fallback: probe both names
for name in ("analyzeHeadless.bat", "analyzeHeadless"):
p = ghidra_dir / "support" / name
if p.exists():
return p
raise FileNotFoundError(
f"analyzeHeadless not found in {ghidra_dir}/support/ - verify ghidra install directory"
)
CI-pinned Ghidra version from `.github/workflows/ci.yml:19-21`:
env:
GHIDRA_VERSION: "11.0.3"
GHIDRA_BUILD: "20240410"
GHIDRA_SHA256: "2462a2d0ab11e30f9e907cd3b4aa6b48dd2642f325617e3d922c28e752be6761"
Memory-per-worker constant from `ghidra_decompile.py:24-26`:
_GHIDRA_GB_PER_WORKER = 4.0
_GHIDRA_MAX_AUTO_WORKERS = 16
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ghidra_install_dir is required - set it in config or via ${GHIDRA_INSTALL_DIR}` | Config/env not set | Set `GHIDRA_INSTALL_DIR` or `ghidra_install_dir` in pipeline config |
| `ghidra not found at <path>` | Directory does not exist | Verify the path; check `$GHIDRA_INSTALL_DIR` |
| `analyzeHeadless not found in <dir>/support/` | Wrong install root | Point at the top-level Ghidra dir (containing `support/`) |
| `ghidra timed out after 300s` | Analysis exceeded timeout | Increase `timeout` config (default 300s) |
| `ghidra exited with code <N>` | Ghidra analysis failure | Check `ghidra_stderr.log` in sample's `decompiled/` dir |
Compatibility Notes
- Version 11.0.3 (build 20240410) tested in CI: The CI workflow downloads and checksum-verifies this specific build. Other versions may work but are not tested.
- Checksum verification: CI verifies the SHA256 of the downloaded archive because it is a binary from outside the build.
- Windows: Uses `analyzeHeadless.bat`; POSIX uses `analyzeHeadless` shell script.
- Memory-bounded parallelism: Each worker is a full JVM (~4 GiB). Auto worker count is bounded by RAM, CPU, and a hard cap of 16 — see Heuristic:416rehman_DeepZero_Memory_Safe_Parallelism.
- Cache: Results cached as `decompiled/ghidra_result.json` per sample; corrupt cache triggers re-analysis.
- Project cleanup: Uses `-deleteProject` flag; temporary Ghidra projects are not retained.