A comprehensive reverse engineering toolkit for Solana BPF programs. Analyze compiled .so files to understand program logic, detect vulnerabilities, and recover source code.
- Core Analysis: Function detection, string extraction, constant analysis
- Security: 8 vulnerability checks, taint analysis, flash loan detection
- Code Recovery: Decompiled Rust, Anchor project generation, trait inference
- Visualization: SVG memory layouts, complexity heatmaps, call graphs
- Automation: REST API, watch mode, CI/CD integration
- Markdown/HTML reports (37 sections)
- Ghidra/IDA Pro/Radare2 scripts
- Complete Anchor project skeleton
- Fuzz test harness
# Clone repository
git clone https://github.com/vnxfsc/solana-bpf-reverse.git
cd solana-bpf-reverse
# Install dependencies
pip install -r requirements.txt
# Or install as package
pip install -e .To use as a Cursor IDE AI Skill:
# Copy skill to Cursor skills directory
cp -r cursor-skill ~/.cursor/skills/solana-bpf-reverseThen mention "BPF analysis" or "reverse engineer Solana program" in Cursor to activate.
# Analyze a program
python -m bpf_analyzer program.so -o ./output
# Interactive REPL
python -m bpf_analyzer repl program.so
# Fetch from chain
python -m bpf_analyzer fetch <PROGRAM_ID> -o program.so
# Generate Anchor project
python -m bpf_analyzer anchor program.so -o ./my_project| Command | Description |
|---|---|
analyze <file> |
Full analysis with 37 report sections |
repl <file> |
Interactive analysis mode |
serve [port] |
REST API server |
watch <id> |
Monitor on-chain program for changes |
fetch <id> |
Download program from Solana |
diff <a> <b> |
Compare two program versions |
compare <files> |
Compare 3+ versions |
parallel <files> |
Multi-threaded analysis |
anchor <file> |
Generate Anchor project |
symbolic <file> <addr> |
Symbolic execution |
Analyzing program.so (505,920 bytes)...
Summary:
- Functions: 495
- Strings: 110
- Constants: 2350
- Program Type: dex (CLMM)
- Security Risk: LOW
- Flash Loan Risk: HIGH
Output files:
- report.md (37 sections)
- report.html
- anchor_project/
- memory_layout.svg
- complexity_heatmap.svg
- Basic Information
- String Analysis
- Function Analysis
- Syscall Usage
- Constant Analysis
- Security Analysis
- Symbol Recovery
- Function Signatures
- Data Flow Analysis
- Control Flow Analysis
- Loop Detection
- Cross References
- CPI Targets
- Account Permissions
- Compute Unit Estimation
- Taint Analysis
- Type Inference
- Dead Code Analysis
- Instruction Format
- Library Matching
- Call Chain Analysis
- Code Clone Detection
- Stack Frame Analysis
- Permission Matrix
- Compiler Information
- Optimization Level
- Obfuscation Detection
- Program Similarity
- Flash Loan Detection
- Vulnerability Patterns
- Complexity Metrics
- Gas Optimization
- Error Types
- Rust Traits
- Generic Recovery
- Macro Detection
- Symbolic Execution
| Check | Severity | Description |
|---|---|---|
| Missing Signer | HIGH | No signer verification |
| Missing Owner | MEDIUM | No owner validation |
| Integer Overflow | HIGH | Unchecked arithmetic |
| Reentrancy | MEDIUM | CPI reentrancy risk |
| PDA Validation | MEDIUM | Missing PDA verification |
| Flash Loan | HIGH | Flash loan vulnerability |
| Account Confusion | HIGH | Type confusion risk |
# Start server
python -m bpf_analyzer serve 8080
# Fetch and analyze
curl http://localhost:8080/api/v1/fetch/<PROGRAM_ID>
# Analyze uploaded program
cat program.so | base64 | curl -X POST -d @- http://localhost:8080/api/v1/analyzefrom bpf_analyzer import BPFAnalyzer
with open("program.so", "rb") as f:
data = f.read()
analyzer = BPFAnalyzer(data)
result = analyzer.analyze(level=10)
print(f"Type: {result['program_type']}")
print(f"Functions: {result['function_count']}")
print(f"Security Risk: {result['security']['risk_level']}")- Token / Token-2022
- NFT / cNFT
- DEX (AMM, CLMM, DLMM)
- DEX Aggregator
- Lending
- Staking
- Governance
- Oracle
- Bridge
- Perpetual
- Orderbook
- Name Service
Automatically detects code from:
- SPL Token / Token-2022
- Anchor Framework
- Metaplex
- Orca Whirlpool
- Raydium AMM/CLMM
- Meteora DLMM
- Marinade
- Jupiter
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Run tests
pytest tests/
# Format code
black src/
isort src/
# Type check
mypy src/MIT License - see LICENSE for details.
- Solana Foundation
- Anchor Framework
- The Solana security research community
This tool is for educational and security research purposes only. Always obtain proper authorization before analyzing programs you don't own.
