A powerful Python-based CLI tool to extract IP addresses from Shodan search results using the official Shodan API.
- β Extract IPs using your own Shodan API key
- β Search using advanced queries (e.g., port, country, product, org)
- β Collect thousands of IPs using pagination
- β Save output to a file
- β Delay support to avoid API rate limits
- β CLI-based and easy to use
- Python 3.x
- Shodan Python Library
Install the library via pip:
pip install shodanpython3 Shodan-IP-Extractor.py -k YOUR_API_KEY -q "your query" [options]| Argument | Description |
|---|---|
-k, --api-key |
Shodan API key (required) |
-q, --query |
Shodan search query string |
-p, --pages |
Number of result pages to fetch (default: 1) |
-d, --delay |
Delay between API requests in seconds (default: 1.0) |
-o, --output |
Output file to save found IPs |
python3 Shodan-IP-Extractor.py -k YOUR_API_KEY -q "apache"python3 Shodan-IP-Extractor.py -k YOUR_API_KEY -q "nginx" -o nginx_ips.txtpython3 Shodan-IP-Extractor.py -k YOUR_API_KEY -q "port:22 country:US" -p 50 -d 1 -o ssh_us_ips.txt| Goal | Query |
|---|---|
| Apache servers | apache |
| Open SSH in US | port:22 country:US |
| MongoDB with no auth | product:MongoDB port:27017 |
| RDP in Germany | port:3389 country:DE |
π More at: Shodan Search Guide
You can get your API key from the Shodan account dashboard.
Free accounts have search and usage limits. For large-scale scans, use a Shodan Membership or API plan.
The script saves results as a plain text file like:
192.168.0.1
45.77.23.99
203.0.113.15
...
You can process this list with tools like nmap, masscan, or custom scripts.