documentation update

This commit is contained in:
Alexander Kiselev
2026-02-22 10:07:29 -08:00
parent 6c50e84593
commit 8b8caada4e
5 changed files with 26 additions and 601 deletions
+2 -7
View File
@@ -48,9 +48,6 @@ Use this subagent when you need to:
# Import and analyze a binary
ghidra import <binary-path> --project=<project>
# Quick analysis (all-in-one)
ghidra quick <binary-path>
# Get program summary
ghidra summary --program=<binary>
```
@@ -382,10 +379,9 @@ export GHIDRA_DEFAULT_PROGRAM=malware.elf
### Common Issues
1. **Ghidra not found**: Run `ghidra init` or set `GHIDRA_INSTALL_DIR`
1. **Ghidra not found**: Run `ghidra doctor` to check installation, or set `GHIDRA_INSTALL_DIR`
2. **Program not specified**: Use `--program=<binary>` or set default
3. **Analysis timeout**: Increase with `set GHIDRA_TIMEOUT=600`
4. **Large result set**: Use `--count` first, then filter more aggressively
3. **Large result set**: Use `--count` first, then filter more aggressively
### Troubleshooting
@@ -480,4 +476,3 @@ The subagent is optimized for:
- Run `ghidra doctor` to check installation
- See `README.md` for full documentation
- Check `CLAUDE_SKILL.md` for detailed examples
+3 -3
View File
@@ -2,8 +2,8 @@
## Critical Rules
1. **NEVER SKIP TESTS!** If Ghidra is not installed, the tests MUST fail.
2. **DEFAULT OUTPUT FORMAT** should be human and agent readable, NOT JSON. Use `--json` and `--pretty` for JSON output.
1. **Tests require Ghidra.** Tests use `require_ghidra!()` to check availability; when Ghidra is not installed, tests are skipped (silent pass). This is intentional for local development. CI environments must have Ghidra installed.
2. **DEFAULT OUTPUT FORMAT** should be human and agent readable, NOT JSON. Use `--json` and `--pretty` for JSON output. Exception: when stdout is not a TTY (piped/scripted), the default auto-detects to `JsonCompact` for machine consumption — this is standard Unix pipe convention.
## Architecture
@@ -12,5 +12,5 @@ ghidra-cli uses a **direct bridge architecture**:
- The bridge is a GhidraScript (`GhidraCliBridge.java`) started via `analyzeHeadless -postScript`
- Bridge binds `ServerSocket(0)` on localhost, writes port/PID files for discovery
- One bridge per project, identified by `~/.local/share/ghidra-cli/bridge-{md5}.port`
- Import/Analyze/Quick commands auto-start the bridge if not running
- Import/Analyze commands auto-start the bridge if not running
- No separate Rust daemon process — the Java bridge IS the persistent server
+17 -18
View File
@@ -53,7 +53,7 @@ Set the Ghidra installation path:
```bash
export GHIDRA_INSTALL_DIR=/path/to/ghidra
# Or configure via CLI:
ghidra config set ghidra_path /path/to/ghidra
ghidra config set ghidra_install_dir /path/to/ghidra
```
## Quick Start
@@ -62,14 +62,11 @@ ghidra config set ghidra_path /path/to/ghidra
# Check installation
ghidra doctor
# Import and analyze a binary (daemon auto-starts)
ghidra quick ./binary
# Or step by step:
# Import and analyze a binary (bridge auto-starts)
ghidra import ./binary --project myproject --program mybinary
ghidra analyze --project myproject --program mybinary
# Query functions (uses running daemon)
# Query functions (uses running bridge)
ghidra function list
# Decompile a function
@@ -92,9 +89,8 @@ ghidra graph calls main --depth 3
ghidra project create <name> # Create project
ghidra project list # List projects
ghidra project delete <name> # Delete project
ghidra import <binary> --project <p> # Import binary (auto-starts daemon)
ghidra import <binary> --project <p> # Import binary (auto-starts bridge)
ghidra analyze --project <p> # Run analysis
ghidra quick <binary> # Import + analyze in one step
```
### Function Analysis
@@ -102,7 +98,7 @@ ghidra quick <binary> # Import + analyze in one step
ghidra function list # List all functions
ghidra function list --filter "size > 100" # Filter by size
ghidra decompile <name-or-addr> # Decompile function
ghidra disasm <address> --count 20 # Disassemble instructions
ghidra disasm <address> --instructions 20 # Disassemble instructions
```
### Symbols & Types
@@ -175,20 +171,20 @@ The bridge keeps Ghidra loaded in memory. It starts automatically when needed, b
```bash
# Start bridge with a program loaded
ghidra daemon start --project myproject --program mybinary
ghidra start --project myproject --program mybinary
# Check bridge status
ghidra daemon status --project myproject
ghidra status --project myproject
# All commands use the bridge automatically
ghidra function list --project myproject # Fast!
ghidra decompile main --project myproject # Fast!
# Stop bridge
ghidra daemon stop --project myproject
ghidra stop --project myproject
# Restart with different program
ghidra daemon restart --project myproject --program otherbinary
ghidra restart --project myproject --program otherbinary
```
### Multi-Project Support
@@ -197,8 +193,10 @@ Each project gets its own bridge process and port file, allowing concurrent anal
```bash
# Work on multiple projects simultaneously
ghidra quick ./binary_a --project projA
ghidra quick ./binary_b --project projB
ghidra import ./binary_a --project projA
ghidra analyze --project projA --program binary_a
ghidra import ./binary_b --project projB
ghidra analyze --project projB --program binary_b
# Query each independently
ghidra function list --project projA
@@ -207,9 +205,10 @@ ghidra function list --project projB
## Output Formats
Default output is human-readable in all contexts. Use flags to request machine formats:
Default output is human-readable when connected to a terminal. When piped (non-TTY), output auto-detects to compact JSON for machine consumption. Use flags to override:
- **Default**: Compact human-readable format (designed for both humans and AI agents)
- **Default (TTY)**: Compact human-readable format (designed for both humans and AI agents)
- **Default (pipe)**: Compact JSON for machine parsing
- **--json**: Compact JSON for machine parsing
- **--pretty**: Pretty-printed JSON (indented, multi-line)
@@ -244,7 +243,7 @@ ghidra strings list --filter "length > 20"
Ghidra CLI is designed to work seamlessly with AI coding assistants like Claude Code. The structured output and comprehensive command set make it ideal for automated reverse engineering workflows.
Example workflow with an AI agent:
1. `ghidra quick suspicious.exe` - Import, analyze, start daemon
1. `ghidra import suspicious.exe --project analysis` + `ghidra analyze --project analysis` - Import, analyze, start bridge
2. `ghidra find interesting` - AI analyzes suspicious patterns
3. `ghidra decompile <func>` - AI examines specific functions
4. `ghidra x-ref to <addr>` - AI traces data flow
-564
View File
File diff suppressed because it is too large Load Diff
+4 -9
View File
@@ -16,18 +16,13 @@ tests/
├── project_tests.rs # Project: create/list/delete/info
├── reliability_tests.rs # Bridge restart recovery, stale file cleanup
├── command_tests.rs # Basic commands: version/doctor/config/init
├── batch_tests.rs # Batch command execution
├── comment_tests.rs # Comment operations
├── diff_tests.rs # Program diff operations
├── find_tests.rs # Search operations
├── graph_tests.rs # Call graph operations
├── program_tests.rs # Program info/import/export
├── patch_tests.rs # Binary patching operations
├── readonly_tests.rs # Read-only query tests
├── script_tests.rs # Script execution
├── stats_tests.rs # Statistics
├── symbol_tests.rs # Symbol operations
├── type_tests.rs # Type operations
├── output_format_integration.rs # Output format detection
├── unimplemented_tests.rs # Graceful error tests for stub commands
└── e2e.rs # Lightweight smoke test
```
@@ -88,7 +83,7 @@ cargo test --test e2e --test command_tests --test output_format_integration
### Ghidra Installation
Tests assume Ghidra is installed. Use `require_ghidra!()` in tests that need a fast, explicit availability check; it fails the test if `ghidra doctor` fails.
Tests assume Ghidra is installed. Use `require_ghidra!()` in tests that need a fast, explicit availability check; it skips the test (silent pass) if `ghidra doctor` fails. CI environments must have Ghidra installed.
### Test Fixtures
@@ -122,7 +117,7 @@ fn test_my_command() {
### Bridge-Dependent Tests
Add to the appropriate test file (e.g., `symbol_tests.rs`, `find_tests.rs`):
Add to the appropriate test file (e.g., `symbol_tests.rs`, `readonly_tests.rs`):
```rust
#[test]