Created
August 19, 2017 17:38
-
-
Save theMiddleBlue/c664651ab1189717fcb6a70dcdb0af08 to your computer and use it in GitHub Desktop.
Shodan.io API
This file contains 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
import httplib, urllib, re, sys, json, socket, struct | |
# python shodan.py 0 | |
# ^ this is the page number | |
shodan = { | |
'apikey': '<your shodan API key>', | |
'query': r'"root%40"+"android"+port%3A23', | |
} | |
conn = httplib.HTTPSConnection('api.shodan.io') | |
req = conn.request('GET', '/shodan/host/search?key='+shodan['apikey']+'&query='+shodan['query']+'&page='+str(sys.argv[1:][0])) | |
res = conn.getresponse() | |
body = res.read() | |
conn.close() | |
r = json.loads(body) | |
for i in r['matches']: | |
ip = socket.inet_ntoa(struct.pack('!L', i['ip'])) | |
print str(sys.argv[1:][0])+','+ip+','+i['isp']+','+i['data'][3:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment