Ghidra CLI
A Rust CLI for Ghidra: binary import, decompilation, cross-references and type editing with JSON output for an agent
- 267 ★ on the repository
- Last commit
- GPL-3.0
Broad access
Why this level
- The CLI runs a Java bridge and Ghidra script files with your user permissions
- Patch commands change bytes and types in a project and export modified binaries
- The tool is used to examine potentially malicious files, so work with them in an isolated environment
Install
- Works in
Manual install
git clone https://github.com/akiselev/ghidra-cli
cd ghidra-cli
cargo install --path .Requires a current Rust toolchain, Ghidra 11 or later and a full JDK. Run ghidra doctor after installation; ghidra setup can download Ghidra.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The CLI runs a Java bridge and Ghidra script files with your user permissions
- Patch commands change bytes and types in a project and export modified binaries
- The tool is used to examine potentially malicious files, so work with them in an isolated environment
This is third-party code. Review the repository files before installing.
What it does
Ghidra CLI runs Ghidra without a graphical window and gives you a command line for reverse engineering. The very first command, for example `ghidra import ./binary --project myproject`, starts the bridge itself: a Java script inside the Ghidra JVM that the CLI connects to over TCP on a local port. Ghidra stays in memory, so subsequent commands do not restart the JVM and symbol or type changes persist. Through the CLI you can list functions, symbols, strings and types, decompile a function (`ghidra decompile main`), view disassembly and cross-references (`ghidra x-ref to 0x401000`), build call graphs and export them to DOT. Types are editable: you create structs, enums and typedefs and change function signatures, calling conventions and variable types. Search covers strings, bytes, function names and cryptographic constants. There is byte patching (`ghidra patch bytes`, `ghidra patch nop`) with export of the changed file, function tags, comments, running Ghidra script files, and a batch mode from a command file. Terminal output is human-readable, and in a pipe it becomes compact JSON by default, so an agent parses the answer without extra steps.
Who it is for. For reverse engineers and binary analysts who want to drive Ghidra from a terminal or hand routine passes to an agent such as Claude Code.
Good fit when
- You need to import a binary, analyze it and list functions and interesting strings in one pass
- An agent should decompile functions by name or address and trace where data comes from with `x-ref`
- You need to annotate code: rename symbols, create structs and change signatures while Ghidra keeps the state in memory
- To audit your own software you want to find cryptographic constants and byte patterns
- Several binaries are analyzed in parallel, each project with its own bridge and port
Not a fit when
- You need the Ghidra graphical interface with manual navigation: the CLI is meant for terminal and scripts
- You want an MCP server that attaches to an already open Ghidra window: the CLI starts its own bridge and does not drive an open interface
- The machine has no full JDK: you need a JDK with `javac`, a plain JRE is insufficient
- You plan to analyze binaries you have no right to examine: the tool is meant for lawful analysis such as your own software, security research and debugging
Example request
Import sample.exe into the analysis project, find interesting strings and the function that uses them, and show its decompiled codeLimitations
Ghidra 11 or later, a full JDK with javac and a current Rust toolchain are required. Documentation specifies JDK 21 for Ghidra 12.x. Set GHIDRA_INSTALL_DIR to an existing installation or download Ghidra with setup. Doctor compiles the bridge, so it is not a passive file check.
Inline script python and script java are unsupported in bridge mode; saved Java scripts are the documented path. The `--read-only` flag checks program modifications but does not sandbox the filesystem. Commands can patch bytes and export binaries. Decompiled content reaches the agent and may contain confidential details. The CLI uses GPL-3.0.
How to disable. Stop the bridge with `ghidra stop --project <name>`. If projects are no longer needed, run `ghidra project delete <name>` before removing the CLI: this optional step destroys saved analysis data. Then remove the `ghidra` binary from `~/.cargo/bin`.
FAQ
How do I install Ghidra CLI?
Clone the repository, run `cargo install --path .` and give the Ghidra path through `GHIDRA_INSTALL_DIR` or `ghidra config set ghidra_install_dir /path/to/ghidra`. If you have no Ghidra, `ghidra setup` downloads it. Verify with `ghidra doctor`.
Why is there a bridge and why are queries fast?
The bridge is a Java script, `GhidraCliBridge`, inside the Ghidra JVM. Ghidra loads once and stays in memory, and the CLI sends commands over TCP, so no JVM starts for each command. Reads run in parallel, writes one at a time.
What output format does the CLI use?
Human-readable text in a terminal and compact JSON when piped. The `--json` and `--pretty` flags set the format explicitly, and `--fields name,address,size` keeps only the fields you need. Filters use a small language such as `size > 100 AND name ~ 'crypt'`.
Can I patch the binary?
Yes. `ghidra patch bytes <addr> "90 90"` changes bytes, `ghidra patch nop <addr> --count 5` overwrites instructions and `ghidra patch export -o patched.bin` saves the result. For `patch nop`, the whole patch rolls back if any selected address has no instruction.
Are there ready materials for Claude Code?
The repository `.claude/` folder holds a `ghidra-cli` skill and a `ghidra-agent` subagent definition. Copy them into your project so Claude Code knows the CLI commands.
Discussion
No questions or reviews yet.
Related
CLI toolsMCP server and Ghidra plugin that lets an agent decompile binaries, follow cross-references and rename functions in an open project
Rebuilds C and C++ functions from compiled programs through Ghidra: one model writes the code and another checks it.
A Ghidra extension with an MCP server: an agent reads pseudocode and disassembly, builds call graphs and edits names, types and structures via 100 tools
An MCP server for the Ghidra disassembler: hundreds of tools for reverse engineering, decompilation, renaming, structures, emulation and debugging
A Ghidra MCP server: the agent decompiles, renames variables, builds cross references and works through a binary via a set of small tools
Hook rules with no model in the loop stop dangerous commands and secrets in code, and every block goes to a local log.
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| Ghidra CLI (this card) | no | 267 | ||
| GhidraMCP | no | not required | 11,907 | an MCP server and plugin for Ghidra that attaches to the open interface |
| Ghidra MCP Server | no | not required | 6,207 | an MCP server for the Ghidra disassembler with hundreds of tools |
README in short
Long-running operations have separate status and cancellation commands. Cancellation is cooperative, not an immediate interruption guarantee; decompilation timeouts are configured separately.