当前位置: 首页>>代码示例>>Python>>正文


Python shodan.WebAPI类代码示例

本文整理汇总了Python中shodan.WebAPI的典型用法代码示例。如果您正苦于以下问题:Python WebAPI类的具体用法?Python WebAPI怎么用?Python WebAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WebAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: autoroot

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)
开发者ID:0x90,项目名称:routerz,代码行数:26,代码来源:dir300.py

示例2: locateip

	def locateip(self, data):
		if '!locateip' in data['recv']:
			args = argv('!locateip',data['recv'])
			api = WebAPI("KpYC07EoGBtGarTFXCpjsspMVQ0a5Aus")#don look
			query = args['argv'][1]
			try:
				socket.inet_aton(query)
			except socket.error:
				return None
			results = api.host(query)
			output = []
			output.append('OS: ' + str(results['os']))
			output.append('City: ' + str(results['city']) + '\tPostal code: ' + str(results['postal_code']))
			output.append('Area code: ' + str(results['area_code']) + '\t\tCountry code: ' + str(results['country_code']))
			output.append('Region name: ' + str(results['region_name']) + '\tCountry name: ' + str(results['country_name']))
			output.append('Latitude: ' + str(results['latitude']) + '\tLongitude: ' + str(results['longitude']))
			ports = []
			for data in results['data']:
				port = data['port']
				if not str(port) in ports:
					ports.append(str(port))
			output.append('Open ports: ' + ', '.join(ports))
			ircoutput = ''
			for line in output:
				ircoutput += say(args['channel'],line)
			return ircoutput
开发者ID:Taiiwo,项目名称:IRCLinkBot,代码行数:26,代码来源:plugins.py

示例3: __init__

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	    
开发者ID:aljavier,项目名称:Shodan3r,代码行数:26,代码来源:Shodan3r.py

示例4: shodan_search

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
开发者ID:clebeer,项目名称:device-pharmer,代码行数:34,代码来源:device-pharmer.py

示例5: run

    def run(self, info):

        # This is where we'll collect the data we'll return.
        results = []

        # Skip unsupported IP addresses.
        if info.version != 4:
            return
        ip = info.address
        parsed = netaddr.IPAddress(ip)
        if parsed.is_loopback() or \
           parsed.is_private()  or \
           parsed.is_link_local():
            return

        # Query Shodan for this host.
        try:
            key = self.get_api_key()
            api = WebAPI(key)
            shodan = api.host(ip)
        except Exception, e:
            tb = traceback.format_exc()
            Logger.log_error("Error querying Shodan for host %s: %s" % (ip, str(e)))
            Logger.log_error_more_verbose(tb)
            return
开发者ID:Autoscan,项目名称:golismero,代码行数:25,代码来源:shodan.py

示例6: shodanquery

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
开发者ID:benhagen,项目名称:dossier,代码行数:15,代码来源:ip.py

示例7: __init__

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
开发者ID:overxfl0w,项目名称:Grampus-Forensic-Utils,代码行数:48,代码来源:fingershodan.py

示例8: __init__

	def __init__(self,host):
		self.host=host
		self.key = ""
		if self.api =="":
			print "You need an API key in order to use SHODAN database. You can get one here: http://www.shodanhq.com/"
			sys.exit()
		self.api = WebAPI(self.key)
开发者ID:Fadyazmy,项目名称:Cyber-Security-Tools,代码行数:7,代码来源:shodansearch.py

示例9: shodan_search

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
开发者ID:synick,项目名称:shodan_pharmer,代码行数:17,代码来源:shodan_pharmer.py

示例10: __init__

	def __init__(self,host):
		self.host=host
		self.shodan_api_key = "oykKBEq2KRySU33OxizNkOir5PgHpMLv"

		if self.shodan_api_key =="":
			print "You need an API key in order to use SHODAN database. You can get one here: http://www.shodanhq.com/"
			sys.exit()

		self.api = WebAPI(self.shodan_api_key)
开发者ID:Autoscan,项目名称:golismero,代码行数:9,代码来源:shodansearch.py

示例11: shodan_search

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
开发者ID:Mondego,项目名称:pyreco,代码行数:38,代码来源:allPythonContent.py

示例12: shodan_frame

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')
开发者ID:52piaoyu,项目名称:Nosql-Exploitation-Framework,代码行数:23,代码来源:nosqlexp.py

示例13: main

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
开发者ID:Viss,项目名称:Eagleeye,代码行数:23,代码来源:eagle-eye.py

示例14: CamScanner

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
开发者ID:mattoufoutu,项目名称:TrendnetStalker,代码行数:36,代码来源:camscan.py

示例15: search_shodan

class search_shodan():
	def __init__(self,host):
		self.host=host
		self.key = ""
		if self.api =="":
			print "You need an API key in order to use SHODAN database. You can get one here: http://www.shodanhq.com/"
			sys.exit()
		self.api = WebAPI(self.key)
	def run(self):
		try:
			host = self.api.host(self.host)
			return host['data']
		except:
			#print "SHODAN empty reply or error in the call"
			return "error"
开发者ID:Fadyazmy,项目名称:Cyber-Security-Tools,代码行数:15,代码来源:shodansearch.py


注:本文中的shodan.WebAPI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。