A powerful and efficient Go tool to fetch and save search results from FOFA (Cyberspace Search Engine) with real-time data saving, concurrent requests, and rate limiting support.
✨ Interactive Query Input - Enter your FOFA query directly when running the tool
🚀 Concurrent Requests - Configurable concurrent fetching for faster results
⏱️ Rate Limiting - Customizable delay between requests to avoid API rate limits
💾 Real-time Saving - Data is saved immediately as it's fetched (no data loss if interrupted)
📁 Multiple Output Formats - Domain list, JSON, CSV, and summary files
🔧 Browser-like Headers - Mimics real browser requests to avoid blocking
📊 Progress Tracking - Real-time progress display with percentage completion
🗂️ Organized Output - All results saved in timestamped files within results/ folder
- Go 1.16 or higher
- FOFA API Key (get it from FOFA User Info)
- Clone this repository:
git clone https://github.com/willygoid/fofa-grabber.git
cd fofa-grabber- Run the program (it will create a default
.envfile):
go run main.go- Edit the
.envfile with your FOFA API key:
FOFA_API_KEY=your_api_key_here
DELAY_SECONDS=5
CONCURRENT_REQUESTS=1go run main.goWhen prompted, enter your FOFA query:
Input Query: app="Apache-Tomcat" && country="ID"
To create a standalone executable:
go build -o fofa-grabber main.goThen run:
./fofa-grabberEdit the .env file to customize behavior:
| Variable | Description | Default |
|---|---|---|
FOFA_API_KEY |
Your FOFA API key | - |
DELAY_SECONDS |
Delay between requests (seconds) | 2 |
CONCURRENT_REQUESTS |
Number of concurrent requests | 3 |
- Safe/Slow:
DELAY_SECONDS=3-5,CONCURRENT_REQUESTS=1-2 - Normal:
DELAY_SECONDS=2,CONCURRENT_REQUESTS=3 - Fast (risky):
DELAY_SECONDS=1,CONCURRENT_REQUESTS=5
FOFA uses a powerful query syntax. Here are some examples:
# Search for Livewire applications in Indonesia
(body="wire:id" || body="wire:click=") && country="ID"
# Search for Apache Tomcat servers
app="Apache-Tomcat" && country="ID"
# Search for specific ports
port="8080" && country="ID"
# Search by IP range
ip="103.0.0.0/8" && country="ID"
# Search by domain
domain="example.com"
# Combine multiple conditions
app="nginx" && port="443" && country="ID"For more query syntax, visit FOFA Query Syntax.
All files are saved in the results/ directory with timestamps:
results/
├── fofa_domain_20260123_143045.txt # List of domains/URLs (one per line)
├── fofa_json_20260123_143045.txt # Raw JSON results (one per line)
├── fofa_results_20260123_143045.csv # CSV format (URL, IP, Port)
└── summary_20260123_143045.json # Complete summary with metadata
- fofa_domain_*.txt: Clean list of all discovered domains/URLs
- fofa_json_*.txt: Raw JSON data for each result
- fofa_results_*.csv: Easy-to-process CSV format
- summary_*.json: Complete data with query info and timestamps
Configuration loaded:
- Delay: 2s
- Concurrent requests: 3
- Results will be saved to: results/
Input Query: app="Apache-Tomcat" && country="ID"
Query (Base64): YXBwPSJBcGFjaGUtVG9tY2F0IiAmJiBjb3VudHJ5PSJJRCI=
Fetching first page to determine total size...
Total size: 1500
Total pages to fetch: 15
Query: app="Apache-Tomcat" && country="ID"
Starting to fetch 15 pages with 3 concurrent requests and 2s delay...
✓ Progress: 3/15 pages completed (20.0%) - 100 results saved
✓ Progress: 6/15 pages completed (40.0%) - 100 results saved
✓ Progress: 9/15 pages completed (60.0%) - 100 results saved
✓ Progress: 12/15 pages completed (80.0%) - 100 results saved
✓ Progress: 15/15 pages completed (100.0%) - 100 results saved
✓ All pages fetched successfully!
Total results collected: 1500
✓ Summary saved to results/summary_20260123_143045.json
All files saved in results/ directory:
- fofa_domain_20260123_143045.txt (all domains)
- fofa_json_20260123_143045.txt (raw JSON results)
- fofa_results_20260123_143045.csv (CSV format)
- summary_20260123_143045.json (complete summary)
If you encounter rate limiting:
❌ Error fetching page X: rate limit exceeded (429) - increase delay time
Solution: Increase DELAY_SECONDS in .env or reduce CONCURRENT_REQUESTS
Error fetching first page: API returned error: Invalid API key
Solution: Check your FOFA_API_KEY in .env
Error: Query cannot be empty
Solution: Enter a valid FOFA query when prompted
Data is saved immediately as it's fetched. If the program is interrupted:
- All fetched data is already saved
- You can safely interrupt (Ctrl+C) and still have partial results
- Resume by running again with a different query
- Uses mutex locks for concurrent file writing
- Safe for high concurrent request settings
- No data corruption or race conditions
Automatically handles GZIP-compressed API responses for efficient data transfer.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational and research purposes only. Always:
- Respect FOFA's Terms of Service
- Use appropriate rate limiting
- Don't overload the API
- Use the data responsibly
Willy The Great - @willygoid
- FOFA - Cyberspace Search Engine
- Go community for excellent libraries
If you find this tool useful, please give it a ⭐ on GitHub!
For issues or questions, please open an issue.