Skip to content

Instantly share code, notes, and snippets.

@iamtutu
Forked from achillean/simple-export.py
Created December 5, 2017 07:04
Show Gist options
  • Save iamtutu/f1989d98774235f37718694f9a86fd41 to your computer and use it in GitHub Desktop.
Save iamtutu/f1989d98774235f37718694f9a86fd41 to your computer and use it in GitHub Desktop.
A simple script to search Shodan and output the results as JSON-encoded banners; each line corresponds to a single banner.
#!/usr/bin/env python
"""
A simple script to search Shodan and output the results as JSON-encoded banners;
each line corresponds to a single banner.
Warning: This will use up query credits because it pages through the results!
Usage: python simple-export.py <search query>
"""
# Install via "easy_install shodan"
import shodan
# Install via "easy_install simplejson", it's more resilient than the default json package
import simplejson
# For accessing the command-line arguments
import sys
api = shodan.Shodan('YOUR API KEY')
for banner in api.search_cursor(sys.argv[1:]):
print simplejson.dumps(banner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment