Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import shodan
- import sys
- import os
- import threading
- #python xx.py product:IIS version:"6.0"
- # Configuration
- API_KEY = "rj8iYTWES8TttT3Ykp0K3MMDCEOVUtAh"
- #API_KEY = "pHHlgpFt8Ka3Stb5UlTxcaEwciOeF2QM"
- def crawler():
- # Input validation
- if len(sys.argv) == 1:
- print 'Usage: %s <search query>' % sys.argv[0]
- sys.exit(1)
- try:
- #api = shodan.Shodan(API_KEY)
- # Perform the search
- query = ' '.join(sys.argv[1:])
- for i in range(1,2):
- threading.Thread(target=shodanthread,args=(i,query,)).start()
- except Exception as e:
- print 'Error: %s' % e
- sys.exit(1)
- def shodanthread(i,query):
- # Setup the api
- api = shodan.Shodan(API_KEY)
- result = api.search(query,page=10,limit=200,offset=(i-1)*200)
- # Loop through the matches and print each IP
- for service in result['matches']:
- ip = service['ip_str']
- country_code = service['location']['country_code']
- domains = service['domains']
- Location = service['http']['redirects']['Location']
- port = service['port']
- org = service['org']
- server = service['server']
- if country_code != 'CN':
- with open('urlresult', 'a') as f:
- f.write(ip+"--"+str(port)+"--"+str(domains)+"--"+country_code+"--"+org+"--"+server+"--"+Location+"\n")
- if __name__ == '__main__':
- crawler()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement