Created
June 22, 2016 08:40
-
-
Save 0xded093/c5d9d213920e35f3ef9c6b5b32b5a8e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import shodan | |
import sys | |
# Configuration | |
API_KEY = "apikey" | |
# Input validation | |
if len(sys.argv) == 1: | |
print 'Usage: %s <search query>' % sys.argv[0] | |
sys.exit(1) | |
try: | |
# Setup the api | |
api = shodan.Shodan(API_KEY) | |
# Perform the search | |
query = ' '.join(sys.argv[1:]) | |
result = api.search(query) | |
# Loop through the matches and print each IP | |
for service in result['matches']: | |
print service['ip_str']+' - '+ str(service['port']) | |
print '---------------------------------------------------' | |
print service['data'] | |
print '---------------------------------------------------' | |
except Exception as e: | |
print 'Error: %s' % e | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment