Skip to content

Instantly share code, notes, and snippets.

@achillean
Last active April 16, 2022 16:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save achillean/8833720 to your computer and use it in GitHub Desktop.
Save achillean/8833720 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