Merge remote-tracking branch 'origin/master'

# Conflicts:
#	modules/dnsquery/srv.py
#	modules/finder.py
This commit is contained in:
Jing Ling
2020-08-20 21:36:33 +08:00
42 changed files with 88 additions and 70 deletions
+6 -3
View File
@@ -13,7 +13,9 @@ from config import settings
HEADERS = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Language": "zh-CN,zh;q=0.9",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/63.0.3239.84 Safari/537.36",
}
@@ -73,8 +75,9 @@ def github_takeover(url):
},
"content": cname_url64
}
html_url = 'https://api.github.com/repos/' + user + '/' + repo_name + '/contents/index.html'
url_url = 'https://api.github.com/repos/' + user + '/' + repo_name + '/contents/CNAME'
base_url = 'https://api.github.com/repos/'
html_url = base_url + user + '/' + repo_name + '/contents/index.html'
url_url = base_url + user + '/' + repo_name + '/contents/CNAME'
html_r = requests.put(url=html_url, data=json.dumps(html_dict),
headers=headers) # 上传index.html
cname_r = requests.put(url=url_url, data=json.dumps(url_dict),
+2 -2
View File
@@ -388,8 +388,8 @@ class Condition(object):
else:
name = []
while self.index < len(
self.condstr) and self.condstr[self.index] in self.allow_character:
while self.index < len(self.condstr) and self.condstr[self.index] \
in self.allow_character:
name.append(self.condstr[self.index])
self.index += 1
+1 -1
View File
@@ -34,7 +34,7 @@ class CensysAPI(Query):
logger.log('ALERT', f'{self.source} module {status}')
return
subdomains = self.match_subdomains(resp.text)
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
pages = json.get('metadata').get('pages')
for page in range(2, pages + 1):
data['page'] = page
+1 -1
View File
@@ -21,7 +21,7 @@ class Crtsh(Query):
return
text = resp.text.replace(r'\n', ' ')
subdomains = self.match_subdomains(text)
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
def run(self):
"""
+7 -4
View File
@@ -33,24 +33,27 @@ class CheckAXFR(Module):
:param server: domain server
"""
logger.log('DEBUG', f'Trying to perform domain transfer in {server} of {self.domain}')
logger.log('DEBUG', f'Trying to perform domain transfer in {server} '
f'of {self.domain}')
try:
xfr = dns.query.xfr(where=server, zone=self.domain,
timeout=5.0, lifetime=10.0)
zone = dns.zone.from_xfr(xfr)
except Exception as e:
logger.log('DEBUG', e.args)
logger.log('DEBUG', f'Domain transfer to server {server} of {self.domain} failed')
logger.log('DEBUG', f'Domain transfer to server {server} of '
f'{self.domain} failed')
return
names = zone.nodes.keys()
for name in names:
full_domain = str(name) + '.' + self.domain
subdomain = self.match_subdomains(full_domain)
self.subdomains = self.subdomains.union(subdomain)
self.subdomains.update(subdomain)
record = zone[name].to_text(name)
self.results.append(record)
if self.results:
logger.log('DEBUG', f'Found the domain transfer record of {self.domain} on {server}')
logger.log('DEBUG', f'Found the domain transfer record of '
f'{self.domain} on {server}')
logger.log('DEBUG', '\n'.join(self.results))
self.results = []
+1 -1
View File
@@ -32,7 +32,7 @@ class CheckCert(Module):
logger.log('DEBUG', e.args)
return
subdomains = self.match_subdomains(str(cert_dict))
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
def run(self):
"""
+1 -2
View File
@@ -23,8 +23,7 @@ class CheckNSEC(Module):
record = item.to_text()
subdomains = self.match_subdomains(record)
subdomain = ''.join(subdomains) # 其实这里的subdomains的长度为1 也就是说只会有一个子域
self.subdomains = self.subdomains.union(subdomains)
self.gen_record(subdomains, record)
self.subdomains.update(subdomains)
if subdomain == self.domain: # 当查出子域为主域 说明完成了一个循环 不再继续查询
break
domain = subdomain
+2 -3
View File
@@ -26,9 +26,8 @@ class ArchiveCrawl(Crawl):
for resp in cdx.iter(url, limit=limit):
if resp.data.get('status') not in ['301', '302']:
url = resp.data.get('url')
subdomains = self.match_subdomains(self.get_maindomain(domain),
url + resp.text)
self.subdomains = self.subdomains.union(subdomains)
subdomains = self.match_subdomains(domain, url + resp.text)
self.subdomains.update(subdomains)
def run(self):
"""
+2 -2
View File
@@ -26,8 +26,8 @@ class CommonCrawl(Crawl):
for resp in tqdm(cdx.iter(url, limit=limit), total=limit):
if resp.data.get('status') not in ['301', '302']:
subdomains = self.match_subdomains(self.get_maindomain(domain), resp.text)
self.subdomains = self.subdomains.union(subdomains)
subdomains = self.match_subdomains(domain, resp.text)
self.subdomains.update(subdomains)
def run(self):
"""
+2 -2
View File
@@ -81,7 +81,7 @@ class CloudFlareAPI(Query):
f'{list_dns_resp.status_code} {list_dns_resp.text}')
return
subdomains = self.match_subdomains(list_dns_resp.text)
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if not self.subdomains:
# waiting for cloudflare enumerate subdomains
sleep(5)
@@ -96,7 +96,7 @@ class CloudFlareAPI(Query):
return
total_pages = list_dns_resp.json()['result_info']['total_pages']
subdomains = (self.match_subdomains(list_dns_resp.text))
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page += 1
if page > total_pages:
break
+1 -1
View File
@@ -35,7 +35,7 @@ class IPv4InfoAPI(Query):
subdomains = self.match_subdomains(str(json))
if not subdomains:
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
# 不直接使用subdomains是因为可能里面会出现不符合标准的子域名
subdomains = json.get('Subdomains')
if subdomains and len(subdomains) < 300:
+1 -1
View File
@@ -50,7 +50,7 @@ class NetCraft(Query):
subdomains = self.match_subdomains(resp)
if not subdomains: # 搜索没有发现子域名则停止搜索
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if 'Next Page' not in resp.text: # 搜索页面没有出现下一页时停止搜索
break
last = re.search(r'&last=.*' + self.domain, resp.text).group(0)
+1 -1
View File
@@ -28,7 +28,7 @@ class QianXun(Query):
subdomains = self.match_subdomains(resp)
if not subdomains: # 没有发现子域名则停止查询
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if '<div id="page" class="pagelist">' not in resp.text:
break
if '<li class="disabled"><span>&raquo;</span></li>' in resp.text:
+1 -1
View File
@@ -26,7 +26,7 @@ class SecurityTrailsAPI(Query):
prefixs = resp.json()['subdomains']
subdomains = [f'{prefix}.{self.domain}' for prefix in prefixs]
if subdomains:
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
def run(self):
"""
+1 -1
View File
@@ -25,7 +25,7 @@ class SiteDossier(Query):
subdomains = self.match_subdomains(resp)
if not subdomains: # 没有发现子域名则停止查询
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
# 搜索页面没有出现下一页时停止搜索
if 'Show next 100 items' not in resp.text:
break
+1 -1
View File
@@ -29,7 +29,7 @@ class SpyseAPI(Query):
subdomains = self.match_subdomains(str(json))
if not subdomains: # 没有发现子域名则停止查询
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
offset += limit
if len(json.get('data').get('items')) < limit:
break
+1 -1
View File
@@ -26,7 +26,7 @@ class ThreatCrowd(Query):
if resp.status_code != 200:
return
subdomains = self.match_subdomains(resp.text)
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
def run(self):
"""
+1 -1
View File
@@ -34,7 +34,7 @@ class WZPCQuery(Query):
subdomains = self.match_subdomains(resp.text)
if not subdomains: # 没有发现子域名则停止查询
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if not subdomains:
break
if page_num > 10:
+1 -1
View File
@@ -52,7 +52,7 @@ class BruteSRV(Module):
for item in answer:
record = str(item)
subdomains = self.match_subdomains(record)
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
def run(self):
"""
+1 -1
View File
@@ -30,7 +30,7 @@ class VirusTotal(Query):
subdomains = self.match_subdomains(resp)
if not subdomains:
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
data = resp.json()
next_cursor = data.get('meta').get('cursor')
+1 -1
View File
@@ -25,7 +25,7 @@ class VirusTotalAPI(Query):
subdomains = self.match_subdomains(resp)
if not subdomains:
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
data = resp.json()
next_cursor = data.get('meta').get('cursor')
+1 -1
View File
@@ -30,7 +30,7 @@ class Ask(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
self.page_num += 1
if '>Next<' not in resp.text:
break
+2 -2
View File
@@ -25,7 +25,7 @@ class Baidu(Search):
for find_res in bs.find_all('a', {'class': 'c-showurl'}):
url = find_res.get('href')
subdomains = self.match_location(url)
subdomains_all = subdomains_all.union(subdomains)
subdomains_all.update(subdomains)
return subdomains_all
def search(self, domain, filtered_subdomain=''):
@@ -54,7 +54,7 @@ class Baidu(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
self.page_num += self.per_page_num
# 搜索页面没有出现下一页时停止搜索
if '&pn={next_pn}&'.format(next_pn=self.page_num) not in resp.text:
+1 -1
View File
@@ -36,7 +36,7 @@ class Bing(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
# 搜索页面没有出现下一页时停止搜索
if '<div class="sw_next">' not in resp.text:
break
+1 -1
View File
@@ -36,7 +36,7 @@ class BingAPI(Search):
subdomains = self.match_subdomains(resp)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
self.page_num += self.per_page_num
if self.page_num >= self.limit_num: # 搜索条数限制
break
+1 -1
View File
@@ -40,7 +40,7 @@ class FoFa(Search):
subdomains = self.match_subdomains(resp)
if not subdomains: # 搜索没有发现子域名则停止搜索
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
size = resp_json.get('size')
if size < 10000:
break
+1 -1
View File
@@ -37,7 +37,7 @@ class Gitee(Search):
subdomains = self.match_subdomains(soup, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if '<li class="disabled"><a href="###">' in resp.text:
break
page_num += 1
+1 -1
View File
@@ -63,7 +63,7 @@ class GithubAPI(Search):
subdomains = self.match_subdomains(resp)
if not subdomains:
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page += 1
try:
resp_json = resp.json()
+1 -1
View File
@@ -40,7 +40,7 @@ class Google(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page_num += per_page_num
if 'start=' + str(page_num) not in resp.text:
break
+1 -1
View File
@@ -35,7 +35,7 @@ class GoogleAPI(Search):
subdomains = self.match_subdomains(resp)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
self.page_num += self.per_page_num
if self.page_num > 100: # 免费的API只能查询前100条结果
break
+1 -1
View File
@@ -26,7 +26,7 @@ class ShodanAPI(Search):
subdomains = self.match_subdomains(resp)
if not subdomains: # 搜索没有发现子域名则停止搜索
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page += 1
def run(self):
+1 -1
View File
@@ -31,7 +31,7 @@ class So(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page_num += 1
# 搜索页面没有出现下一页时停止搜索
if '<a id="snext"' not in resp.text:
+1 -1
View File
@@ -28,7 +28,7 @@ class Sogou(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
self.page_num += 1
# 搜索页面没有出现下一页时停止搜索
if '<a id="sogou_next"' not in resp.text:
+1 -1
View File
@@ -38,7 +38,7 @@ class Yahoo(Search):
subdomains = self.match_subdomains(text, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if '>Next</a>' not in resp.text: # 搜索页面没有出现下一页时停止搜索
break
self.page_num += self.per_page_num
+1 -1
View File
@@ -36,7 +36,7 @@ class Yandex(Search):
subdomains = self.match_subdomains(resp, fuzzy=False)
if not self.check_subdomains(subdomains):
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
if '>next</a>' not in resp.text: # 搜索页面没有出现下一页时停止搜索
break
self.page_num += 1
+1 -1
View File
@@ -50,7 +50,7 @@ class ZoomEyeAPI(Search):
subdomains = self.match_subdomains(resp)
if not subdomains: # 搜索没有发现子域名则停止搜索
break
self.subdomains = self.subdomains.union(subdomains)
self.subdomains.update(subdomains)
page_num += 1
if page_num > 500:
break