Skip to content

Commit c7c9ef4

Browse files
committed
Moving Certificate Transparency Reports from google to CRT.sh
1 parent 602efc6 commit c7c9ef4

File tree

1 file changed

+65
-4
lines changed

1 file changed

+65
-4
lines changed

domain/domain_subdomains.py

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,67 @@ def subdomains_from_netcraft(domain, subdomain_list):
9898
pass
9999
return subdomain_list
100100

101-
def find_domains_from_next_page_ct(page_identifier, domain, subdomain_list, other_related_domain_list):
101+
102+
def ct_search(domain, subdomain_list, wildcard=True):
103+
104+
'''
105+
###################################################################
106+
Credits:
107+
This Code has been picked from @paulwebsec's git repo crt.sh.
108+
https://github.com/PaulSec/crt.sh/blob/master/crtsh.py
109+
110+
Please say Hi to him, We all love him :)
111+
112+
Few changes made:
113+
1. Removing class structure.
114+
2. Instead of passing all fields, just passing subdomain
115+
3. Checking for repeated subdomain entries
116+
###################################################################
117+
'''
118+
print colored(' [+] Extracting subdomains from Certificate Transparency Reports\n', 'blue')
119+
subdomain_list_tmp = []
120+
121+
base_url = "https://crt.sh/?q="
122+
if wildcard:
123+
base_url += "%25."
124+
base_url += domain
125+
126+
ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 ' + \
127+
'Firefox/40.1'
128+
r = requests.get(url=base_url, headers={'User-Agent': ua})
129+
130+
if r.ok:
131+
soup = BeautifulSoup(r.content, 'html.parser')
132+
try:
133+
table = soup.findAll('table')[2]
134+
rows = table.find_all(['tr'])
135+
for row in rows:
136+
cells = row.find_all('td', limit=5)
137+
if cells:
138+
'''tmp = {
139+
'crtsh_id': cells[0].text,
140+
'pem_url': 'https://crt.sh/?d=' + cells[0].text,
141+
'logged_at': cells[1].text,
142+
'not_before': cells[2].text,
143+
}'''
144+
tmp = {}
145+
if wildcard:
146+
tmp['domain'] = cells[3].text
147+
#tmp['issuer'] = cells[4].text
148+
else:
149+
tmp['domain'] = domain,
150+
#tmp['issuer'] = cells[3].text
151+
check_and_append_subdomains(tmp['domain'], subdomain_list)
152+
#subdomain_list_tmp.append(tmp)
153+
except IndexError:
154+
print("Error retrieving information.")
155+
156+
return subdomain_list_tmp
157+
158+
159+
160+
161+
'''def find_domains_from_next_page_ct(page_identifier, domain, subdomain_list, other_related_domain_list):
102162
url = "https://transparencyreport.google.com/transparencyreport/api/v3/httpsreport/ct/certsearch/page?p=%s" % page_identifier
103163
req2 = requests.get(url)
104164
obj2 = req2.text
@@ -143,7 +203,7 @@ def subdomains_from_google_ct(domain, subdomain_list, other_related_domain_list)
143203
find_domains_from_next_page_ct(page_identifier, domain, subdomain_list, other_related_domain_list)
144204
except:
145205
pass
146-
return subdomain_list, other_related_domain_list
206+
return subdomain_list, other_related_domain_list'''
147207

148208
def subdomains_from_dnstrails(domain, subdomain_list):
149209
print colored(' [+] Extracting subdomains from DNSTrails\n', 'blue')
@@ -161,7 +221,7 @@ def subdomains_from_dnstrails(domain, subdomain_list):
161221
subdomains_new = data['result']['subdomains']
162222
for a in range(0, len(subdomains_new)):
163223
subdomains_new[a] = subdomains_new[a] + '.' + domain
164-
print subdomains_new[a]
224+
#print subdomains_new[a]
165225
subdomain_list = check_and_append_subdomains(subdomains_new[a], subdomain_list)
166226
else:
167227
print colored(' [!] {}\n'.format(data['error']), 'yellow')
@@ -179,7 +239,8 @@ def main(domain):
179239
other_related_domain_list = []
180240
subdomain_list = subdomains(domain, subdomain_list)
181241
subdomain_list = subdomains_from_netcraft(domain, subdomain_list)
182-
subdomain_list, other_related_domain_list = subdomains_from_google_ct(domain, subdomain_list, other_related_domain_list)
242+
#subdomain_list, other_related_domain_list = subdomains_from_google_ct(domain, subdomain_list, other_related_domain_list)
243+
subdomains_from_ct = ct_search(domain, subdomain_list)
183244
subdomain_list = subdomains_from_dnstrails(domain, subdomain_list)
184245
# not printing list of 'other_related_domain_list' anywhere. This is done for later changes.
185246
return subdomain_list

0 commit comments

Comments
 (0)