2017-10-08 22:20:35 +08:00
|
|
|
import requests
|
|
|
|
import json
|
2019-01-06 17:50:07 +08:00
|
|
|
from lib.core import *
|
2017-10-08 22:20:35 +08:00
|
|
|
|
2019-01-06 17:50:07 +08:00
|
|
|
|
|
|
|
class SearchGoogleCertificates:
|
2017-10-08 22:20:35 +08:00
|
|
|
# https://www.google.com/transparencyreport/api/v3/httpsreport/ct/certsearch?include_expired=true&include_subdomains=true&domain=
|
|
|
|
def __init__(self, word, limit, start):
|
|
|
|
self.word = word
|
|
|
|
self.results = ""
|
|
|
|
self.totalresults = ""
|
|
|
|
self.server = "www.google.com"
|
|
|
|
self.quantity = "100"
|
|
|
|
self.limit = limit
|
|
|
|
self.counter = start
|
|
|
|
|
|
|
|
def do_search(self):
|
|
|
|
try:
|
2018-12-18 13:21:05 +08:00
|
|
|
urly = "https://" + self.server + "/transparencyreport/api/v3/httpsreport/ct/certsearch?include_expired=true&include_subdomains=true&domain=" + self.word
|
2018-11-23 07:31:21 +08:00
|
|
|
except Exception as e:
|
2018-12-18 13:21:05 +08:00
|
|
|
print(e)
|
2017-10-08 22:20:35 +08:00
|
|
|
try:
|
2019-01-06 17:50:07 +08:00
|
|
|
headers = {'User-Agent': Core.get_user_agent()}
|
2018-12-18 13:21:05 +08:00
|
|
|
r = requests.get(urly, headers=headers)
|
2018-11-23 07:31:21 +08:00
|
|
|
except Exception as e:
|
2018-12-18 13:21:05 +08:00
|
|
|
print(e)
|
2018-11-23 07:31:21 +08:00
|
|
|
self.results = r.text
|
2017-10-08 22:20:35 +08:00
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def get_domains(self):
|
2018-12-18 13:21:05 +08:00
|
|
|
domains = []
|
|
|
|
rawres = json.loads(self.totalresults.split("\n", 2)[2])
|
|
|
|
for array in rawres[0][1]:
|
|
|
|
domains.append(array[1])
|
|
|
|
return list(set(domains))
|
2017-10-08 22:20:35 +08:00
|
|
|
|
|
|
|
def process(self):
|
|
|
|
self.do_search()
|