Skip to content

Instantly share code, notes, and snippets.

@theMiddleBlue
Created August 19, 2017 17:38
Show Gist options
  • Save theMiddleBlue/c664651ab1189717fcb6a70dcdb0af08 to your computer and use it in GitHub Desktop.
Save theMiddleBlue/c664651ab1189717fcb6a70dcdb0af08 to your computer and use it in GitHub Desktop.
Shodan.io API
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