Introduction
The Ghidra Headless Analyzer (analyzeHeadless) enables batch processing of binaries without launching the GUI. This is essential for:
- Automated analysis pipelines
- CI/CD integration
- Large-scale binary processing
- Server-side analysis
- Scripted workflows
Basic Usage
Command Syntax
Simple Analysis
Analyze a single binary:Batch Processing
Process multiple binaries:Command-Line Options
Project Options
Create or use existing project:Import Options
Import file or directory:Analysis Options
Disable analysis:Script Options
Pre-script (runs before analysis):Process Options
Process existing program:Logging Options
Log file:Server Options
Connect to Ghidra Server:Real-World Examples
Example 1: Batch Malware Analysis
Example 2: Function Signature Export
Example 3: Differential Analysis
Example 4: Custom Loader Analysis
Example 5: CI/CD Integration
Script Development for Headless
Headless-Compatible Scripts
Scripts must handle absence of GUI:Using .properties Files
Provide default values for headless execution: MyScript.properties:Python Scripts in Headless Mode
PyGhidra Headless
Use PyGhidra for pure Python headless analysis:Jython Scripts
Jython scripts work in headless mode:Performance Optimization
Parallel Processing
Resource Limits
Analysis Control
Disable unnecessary analyzers for speed:Troubleshooting
Common Issues
Script not found:Debug Mode
Enable verbose output:Environment Variables
Integration Examples
Docker Container
GitHub Actions
Best Practices
- Use -deleteProject for temporary analysis to save disk space
- Set timeouts to prevent hung analysis jobs
- Log output for debugging and audit trails
- Validate inputs in scripts before processing
- Handle errors gracefully in scripts
- Use -max-cpu to control resource usage
- Test scripts in GUI before headless deployment
- Version control scripts and configurations
