本文整理汇总了Python中shodan.WebAPI.search方法的典型用法代码示例。如果您正苦于以下问题:Python WebAPI.search方法的具体用法?Python WebAPI.search怎么用?Python WebAPI.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shodan.WebAPI
的用法示例。
在下文中一共展示了WebAPI.search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shodan_search
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def shodan_search(search, apikey, pages):
from shodan import WebAPI
if apikey:
API_KEY = apikey
else:
API_KEY = 'ENTER YOUR API KEY HERE AND KEEP THE QUOTES'
api = WebAPI(API_KEY)
ips_found = []
try:
results = api.search(search, page=1)
total_results = results['total']
print '[+] Results: %d' % total_results
print '[*] Page 1...'
pages = max_pages(pages, total_results)
for r in results['matches']:
ips_found.append(r['ip'])
if pages > 1:
i = 2
while i <= pages:
results = api.search(search, page=i)
print '[*] Page %d...' % i
for r in results['matches']:
ips_found.append(r['ip'])
i += 1
return ips_found
except Exception as e:
print '[!] Shodan search error:', e
示例2: __init__
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
class Shodan:
""" Clase para buscar en Shodan """
def __init__(self,API_KEY):
self.api = WebAPI(API_KEY)
def buscar(self,cadena):
""" Busca segun la cadena dada """
try:
# Buscamos lo de la cadena pasada como parametro
resultado = self.api.search(str(cadena))
return resultado
except Exception as e:
print 'Ups! Ha ocurrido un error: %s' % e
resultado = []
return resultado
def obtener_info_host(self,IP):
""" Obtiene la info que pueda tener shodan sobre una IP """
try:
host = self.api.host(IP)
return host
except Exception as e:
print 'Ups! Ha ocurrido un error: %s' % e
host = []
return host
示例3: autoroot
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def autoroot(api_key, thread_count=10):
api = WebAPI(api_key)
search_queries = ['Server: Linux, HTTP/1.1, DIR','Mathopd/1.5p6' ]#, 'Server: Linux, HTTP/1.1, DIR-300']
for query in search_queries:
count = 0
page = 1
total = 0
while True:
results = api.search(query)
if total == 0:
total = int(results['total'])
print('Results found: %s' % results['total'])
print('Countries found: ')
pprint(results['countries'])
raw_input('press enter to start hacking')
dm = DlinkManager(results['matches'],thread_count=10)
dm.run()
page += 1
count += len(results['matches'])
if count == total:
break
print("Rooted routers count: %i" % len(rooted))
print(rooted)
示例4: shodan_search
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def shodan_search(search, apikey, pages):
from shodan import WebAPI
if apikey:
API_KEY = apikey
else:
API_KEY = "ENTER YOUR API KEY HERE AND KEEP THE QUOTES"
api = WebAPI(API_KEY)
ips_found = []
try:
results = api.search(search, page=1)
total_results = results["total"]
print "[+] Results: %d" % total_results
print "[*] Page 1..."
pages = max_pages(pages, total_results)
for r in results["matches"]:
# Replace the following ports with port 80 since they'll virtually never have a web server running
# ftp, ssh, telnet, smtp, smtp, netbios x3, smb
if r["port"] in [21, 22, 23, 25, 26, 137, 138, 139, 445]:
r["port"] = 80
ips_found.append("%s:%s" % (r["ip"], r["port"]))
if pages > 1:
i = 2
while i <= pages:
results = api.search(search, page=i)
print "[*] Page %d..." % i
for r in results["matches"]:
ips_found.append(r["ip"])
i += 1
return ips_found
except Exception as e:
print "[!] Shodan search error:", e
示例5: main
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def main(queue):
# Connect to Shodan
api = WebAPI(API_KEY)
# get the first page of results
res = api.search(filter)
#keep track of how many results we have left
#total_results = res['total']
total_results = res.get('total', 0)
# Start looping through results now
page = 1
try:
while(page * 100 <= total_results):
#check the matches to see if they fit what we are looking for
for host in res['matches']:
queue.put_nowait(host['ip'])
page +=1
res = api.search(filter,page)
except Exception, e:
print e
示例6: shodanquery
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def shodanquery(query, api_key=None):
if not api_key or api_key == "":
return False
api = WebAPI(api_key)
if is_valid_ipv4(query):
try:
response = api.host(query)
except:
return False
else:
try:
response = api.search(query)
except:
return False
return response
示例7: CamScanner
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
class CamScanner(object):
filter = "netcam"
def __init__(self, shodan_api_key):
self.api_key = shodan_api_key
self.api = WebAPI(self.api_key)
def cam_available(self, url):
try:
resp = urlopen(url, None, 10)
except (URLError, timeout):
print "Failed to contact cam: %s" % url
return False
else:
if resp.code == 200:
return True
print "Bad resp code: %d" % resp.code
return False
def get_cams(self):
results = self.api.search(self.filter)
total_pages = (results["total"] / 50) + 1
current_page = 1
skip = False
while current_page <= total_pages:
if not skip:
for result in results["matches"]:
url = "http://%s/anony/mjpg.cgi" % result["ip"]
if self.cam_available(url):
yield url, result.get("latitude"), result.get("latitude")
current_page += 1
try:
results = self.api.search(self.filter, page=current_page)
except URLError:
print "Failed to GET page %d" % current_page
skip = True
示例8: __init__
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
class fingershodan:
def __init__(self,search,typeSearch):
self.search = search
self.typeSearch = typeSearch
self.searchList = {}
self.allCount = 0
self.__initKey()
self.__switchSearch()
def __initKey(self):
self.api = WebAPI("CvXzhcMm3YemfeNnNKE7ed9xRSCKfAhY")
def __switchSearch(self):
if self.typeSearch=="search":
self.__execSearch()
elif self.typeSearch=="lookup":
self.search = socket.gethostbyname(self.search)
self.webHost = self.api.host(self.search)
self.__execLookup()
#elif self.typeSearch=="mac":
# self.__macLocation()
def __execSearch(self):
searched = self.api.search(self.search)
for search in searched["matches"]:
try:
self.searchList["Result "+str(self.allCount)] = {"Ip":search["ip"],"Updated":search["updated"],
"Country":search["country_name"],"Latitude":search["latitude"],"Longitude":search["longitude"],
"Port":search["port"],"Data":search["data"],"Os":search["os"]}
self.allCount += 1
except:
continue
def __execLookup(self):
try:
self.searchList["Result "+str(self.allCount)] = {"Ip":self.webHost["ip"],"Country":self.webHost["country_name"],"City":self.webHost["city"],
"Os":self.webHost["os"],"Banner":self.webHost["data"][0]["banner"],"Port":self.webHost["data"][0]["port"],
"TimeStamp":self.webHost["data"][0]["timestamp"]}
except:
print "Fail Lookup"
#def __macLocation(self):
def _returnData(self):
return self.searchList
示例9: shodan_search
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def shodan_search(search, apikey):
if apikey:
API_KEY = args.apikey
else:
API_KEY = 'ENTER YOUR API KEY HERE AND KEEP THE QUOTES'
api = WebAPI(API_KEY)
ips_found = []
try:
results = api.search('%s' % search)
print '[+] Results: %s' % results['total']
for r in results['matches']:
ips_found.append(r['ip'])
return ips_found
except Exception as e:
print '[!] Error:', e
示例10: ShodanScanner
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
class ShodanScanner(object):
def __init__(self, KEY):
self.api = WebAPI(KEY)
def searchShodan(self, search_string):
try:
filename = 'ips.txt'
fp = open(filename, 'w');
self.results = self.api.search(search_string)
for result in self.results['matches']:
print result['ip'], str(result['latitude']), str(result['longitude'])
fp.write(result['ip']+' '+str(result['latitude'])+','+str(result['longitude'])+'\n')
for name in result['hostnames']:
print name
print result['data']
print '***%s results with \"%s\"***' % (self.results['total'], search_string)
fp.close()
except Exception, e:
print 'Error: %s' % e
示例11: shodan_frame
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
def shodan_frame(port):
# Currently Supports query based on port Filter only and Displays Corresponding IP
print colored("\n[!] Shodan Search Module For NoSQL Framework Launched.....",'yellow')
api = WebAPI("API KEY GOES HERE")
if port == 5984:
query='{"couchdb":"Welcome","version":""}'
else:
query='port:%s'%(port)
result = api.search(query)
print colored("[-] Would Like to write the Results to a File",'green')
choice=raw_input()
if choice.lower()=='y':
file=open('shodan-%s.txt'%(port),'w')
for host in result['matches']:
file.write(host['ip']+"\n")
print colored('[-] File to %s/shodan-%s.txt'%(os.getcwd(),port),'green')
file.close()
else:
print colored("[-] Printing Found IP \n",'blue')
for host in result['matches']:
print colored("[-] "+host['ip'],'green')
示例12: str
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
hoststring = str(ip) + ":" + str(port)
print 'Found http://%s/videostream.cgi' % hoststring
f = '<img src="http://%s/videostream.cgi?user=admin&pwd=" height=240 width=320>\n' % hoststring
outfile.write(f)
outfile.flush()
#file.close()
return True
return False
except:
return False
api = WebAPI(key)
#get the first page of results
res = api.search(filter)
#keep track of how many results we have left
total_results = (res['total'])
page = 1
list = []
outfile = open('netwave.html','w')
length = 0
try:
while(page * 100 <= total_results):
# Check the matches to see if they fit what we are looking for
for host in res['matches']:
ip = ''.join(str(host['ip']))
port = ''.join(str(host['port']))
pool.apply_async(checkCam, (ip,port),)
#pool.join()
示例13: WebAPI
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
if(res.find('200 Ok') > 0):
return True
return False
except:
return False
if __name__ == "__main__":
api = WebAPI(key)
res = api.search('DSL Router micro_httpd')#Dork shodan dos modelos vulneraveis
i = 1
try:
while i <= 100: #Vai printar apenas 100 resultados pela API ser free
for ips in res['matches']:
print '[!] Testando http://%s' % ips['ip'] + bcolors.WARNING +' | Localizado em: ' + bcolors.ENDC + ips['country_name'] + bcolors.WARNING + ' | na porta:'+ bcolors.ENDC, bcolors.OKBLUE, ips['port'], bcolors.ENDC
if(checar(ips['ip'])):
print '[+] Is vull: http://%s/password.cgi' % ips['ip']
i +=1
except():
print 'Failed'
示例14: str
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
workbook = xlsxwriter.Workbook('VulnerableLocation.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': True})
worksheet.write('A1','IP',bold)
worksheet.write('B1','Latitude',bold)
worksheet.write('C1','Longitude',bold)
worksheet.write('D1','Country',bold)
worksheet.write('E1','Port',bold)
row = 1
try:
# Search Shodan
results = api.search('port:32764')
# Show the results
print results
for result in results['matches']:
ipaddress = result['ip']
latitude = result['latitude']
longitude = str(result['longitude'])
country = result['country_name']
port = result['port']
worksheet.write(row, 0, ipaddress)
worksheet.write(row, 1, latitude)
worksheet.write(row, 2, longitude)
worksheet.write(row, 3, country)
worksheet.write(row, 4, port)
示例15: WebAPI
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import search [as 别名]
'''
Created on Feb 22, 2014
@author: Zhu Yirong
'''
from shodan import WebAPI
SHODAN_API_KEY = "CUn5UHoYD784Z3AlfUdvulRjiP2oUBfm"
api= WebAPI(SHODAN_API_KEY)
# Wrap the request in a try/ except block to catch errors
try:
# Search Shodan
results = api.search('apache')
print results
# Show the results
for result in results['matches']:
if '200 OK' in result['data']:
print 'IP: %s' % result['ip']
except Exception, e:
print 'Error: %s' % e