Merge pull request #305 from j4vaovo/patch-2

Update crtsh.py
This commit is contained in:
Jing Ling
2023-04-05 22:05:25 +08:00
committed by GitHub
+36 -2
View File
@@ -1,4 +1,6 @@
from common.query import Query
import json
import os
class Crtsh(Query):
@@ -15,12 +17,44 @@ class Crtsh(Query):
"""
self.header = self.get_header()
self.proxy = self.get_proxy(self.source)
self.timeout = 90
self.timeout = 120
params = {'q': f'%.{self.domain}', 'output': 'json'}
resp = self.get(self.addr, params)
if not resp:
return
text = resp.text.replace(r'\n', ' ')
"""
* > altdns
"""
subDomains = set()
try:
jsonData = json.loads(text)
except Exception as e:
pass
for i in range(len(jsonData)):
try:
name_value = str(jsonData[i]['name_value'])
except Exception as e:
pass
if '*' in name_value:
try:
if 'certificates' in os.path.dirname(os.path.abspath(__file__)):
dictFile = open("../../data/altdns_wordlist.txt", "r", encoding='utf8')
else:
dictFile = open("./data/altdns_wordlist.txt", "r", encoding='utf8')
for line in dictFile.readlines():
altdns = line.strip()
result = name_value.replace('*', altdns)
if self.domain in result:
subDomains.add(result)
except Exception as e:
pass
if len(subDomains) > 0:
for x in subDomains:
text = text + ',' + x + ','
"""
* > altdns end
"""
subdomains = self.match_subdomains(text)
self.subdomains.update(subdomains)
@@ -47,4 +81,4 @@ def run(domain):
if __name__ == '__main__':
run('huawei.com')
run('163.com')