From 36ceaab17438bed4f0f7774faf7973df4895f77e Mon Sep 17 00:00:00 2001 From: Laramies Date: Fri, 23 Nov 2018 00:31:21 +0100 Subject: [PATCH] Google Certificates Added new search engine Google Certificate Transparency and fixed temporarily Shodan --- discovery/googlecertificates.py | 20 ++++++++++---------- discovery/shodansearch.py | 9 ++++++--- theHarvester.py | 20 +++++++++++--------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/discovery/googlecertificates.py b/discovery/googlecertificates.py index f0997689..2b21ce3b 100644 --- a/discovery/googlecertificates.py +++ b/discovery/googlecertificates.py @@ -20,21 +20,21 @@ def __init__(self, word, limit, start): def do_search(self): try: urly="https://" + self.server + "/transparencyreport/api/v3/httpsreport/ct/certsearch?include_expired=true&include_subdomains=true&domain=" + self.word - except Exception, e: - print e + except Exception as e: + print (e) try: r=requests.get(urly) - except Exception,e: - print e - self.results = r.content + except Exception as e: + print (e) + self.results = r.text self.totalresults += self.results def get_domains(self): - domains = [] - rawres = json.loads(self.totalresults.split("\n", 2)[2]) - for array in rawres[0][1]: - domains.append(array[1]) - return list(set(domains)) + domains = [] + rawres = json.loads(self.totalresults.split("\n", 2)[2]) + for array in rawres[0][1]: + domains.append(array[1]) + return list(set(domains)) def process(self): self.do_search() diff --git a/discovery/shodansearch.py b/discovery/shodansearch.py index 288d82e3..07125885 100644 --- a/discovery/shodansearch.py +++ b/discovery/shodansearch.py @@ -13,9 +13,12 @@ def __init__(self, host): def run(self): try: - host = self.api.host(self.host) - return host['data'] + result = self.api.host(self.host) + #for service in result['data']: + # print ("%s:%s" % (service['ip_str'], service['port'])) + # print ("%s" % (service['product'])) + # print ("%s" % (service['hostnames'])) + return result except Exception as e: print("SHODAN empty reply or error in the call") - print(e) return "error" diff --git a/theHarvester.py b/theHarvester.py index 9f85f3a0..2177d73b 100644 --- a/theHarvester.py +++ b/theHarvester.py @@ -93,6 +93,7 @@ def start(argv): takeover_check = False google_dorking = False limit = 500 + full = [] dnsserver = "" for value in enumerate(opts): opt = value[1][0] @@ -391,7 +392,7 @@ def start(argv): search = googlecertificates.search_googlecertificates(word, limit, start) search.process() domains = search.get_domains() - all_hosts.extend(domains) + all_hosts.extend(domains) @@ -553,6 +554,10 @@ def start(argv): shodanvisited = [] if shodan == True: print("\n\n\033[1;32;40m[-] Shodan DB search (passive):\n") + if full ==[]: + print ('No host to search, exiting.') + sys.exit() + for x in full: try: ip = x.split(":")[1] @@ -561,18 +566,15 @@ def start(argv): a = shodansearch.search_shodan(ip) shodanvisited.append(ip) results = a.run() - time.sleep(2) - for res in results: - if res['info'] == []: - res['info'] = '' - shodanres.append( - x + "SAPO" + str(res['info']) + "SAPO" + str(res['data'])) - except Exception: + #time.sleep(2) + for res in results['data']: + shodanres.append(str("%s:%s - %s - %s - %s," % (res['ip_str'], res['port'],res['os'],res['isp']))) + except Exception as e: pass print("\n [+] Shodan results:") print("------------------") for x in shodanres: - print((x.split("SAPO")[0] + ":" + x.split("SAPO")[1])) + print (x) else: pass