Bulk-decompile binaries via Ghidra into a browsable source tree
Project description
ghidra-decomp
Bulk-decompile binaries into browsable source trees using Ghidra.
Takes a binary, runs Ghidra's decompiler on every function, and produces a directory of .c files and JSON indexes — ready for grep, code review, or AI-assisted analysis.
Why
Reverse engineering through Ghidra's GUI (or MCP) means looking at one function at a time. This tool dumps everything upfront so you can treat the binary like a normal codebase: grep for patterns, read call graphs, search strings — all without waiting for decompilation round-trips.
Install
Requires Ghidra 11.0+ (which bundles pyghidra).
pip install -e .
Set GHIDRA_INSTALL_DIR to your Ghidra installation, or pass --ghidra-path.
Usage
ghidra-decomp ./firmware.bin -o ./firmware_decomp
Options:
| Flag | Description | Default |
|---|---|---|
-o, --output |
Output directory | <binary>_decomp/ |
--timeout |
Per-function decompilation timeout (seconds) | 60 |
--ghidra-path |
Path to Ghidra install | $GHIDRA_INSTALL_DIR |
--base-addr |
Rebase binary to this address before analysis (e.g. 0x80000000) |
none |
--entry |
Mark this address as the entry point and disassemble from it before analysis (e.g. 0x31000). Useful for raw binaries. |
none |
--language |
Force Ghidra language ID (e.g. ARM:LE:32:v7). Use when auto-detect fails. |
auto |
--compiler |
Force compiler spec ID (e.g. gcc, default, windows). Requires --language. |
auto |
--list-languages |
List all available language IDs and compiler specs, then exit. |
For raw binaries or unknown formats, Ghidra will refuse to auto-load. Discover the right spec then pass it:
ghidra-decomp --list-languages | grep -i arm
ghidra-decomp ./firmware.bin --language ARM:LE:32:v7 --compiler default
Raw binaries typically also need a known image base and an entry point for auto-analysis to reach every function. Both are applied before analysis runs, so function boundaries, xrefs, and switch-table recovery all happen at the real addresses:
ghidra-decomp ./dal_ivm.mod \
--language x86:LE:32:default \
--compiler gcc \
--base-addr 0x00031000 \
--entry 0x00031000
Output
firmware_decomp/
├── functions/
│ ├── 00010000_main.c
│ ├── 00010234_parse_config.c
│ └── ...
├── all_functions.c # everything in one file
├── types.json # recovered structs, enums, unions, typedefs
├── functions.json # function index with address ranges + signatures
├── callgraph.json # who calls who
├── strings.json # strings + xrefs to functions
├── imports.json # external library functions
├── exports.json # exported entry points
├── symbols.json # globals, labels, data
├── sections.json # memory map with r/w/x permissions
└── metadata.json # binary info + stats
Each .c file includes a metadata header:
// Function: parse_config
// Address: 00010234
// Size: 284 bytes
// Calling: __stdcall
// Params: 3
void parse_config(char *param_1, int param_2, int param_3) {
...
}
Intended workflow
- Dump the binary with
ghidra-decomp - Analyze the output like source code — grep, glob, read
- Write back renames/annotations to Ghidra via MCP (separate tool)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghidra_decomp-0.2.0.tar.gz.
File metadata
- Download URL: ghidra_decomp-0.2.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e74dd6da1beaa9e492edd8b5b78bf78dc550d6eb8b5ffb78c5454c8cd27c41f4
|
|
| MD5 |
9a9b145e59439f408817786ff4976309
|
|
| BLAKE2b-256 |
1e053772e48e23d156dd6bcbb5a76ee6c2bf4ea7220278b1f3c8a2ab43595316
|
File details
Details for the file ghidra_decomp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ghidra_decomp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2464b3420c47ee1be892bbf9a7490dfe83aa20665aed2e07c1940fc1d9c27956
|
|
| MD5 |
d316ce32e229527452b06c6638775b09
|
|
| BLAKE2b-256 |
6ad648a27e5aac472f850396e35ca5c57ea1e6ab65464b0ae046e1806e02235a
|