修改日志输出格式,降低代码重复率。

This commit is contained in:
shmilylty
2019-08-03 21:21:48 +08:00
parent 6241dd16db
commit 439fc9aa8e
55 changed files with 272 additions and 443 deletions
+3 -6
View File
@@ -49,7 +49,7 @@ class Ask(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -62,8 +62,7 @@ class Ask(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -80,10 +79,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Ask(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -70,7 +70,7 @@ class Baidu(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -83,8 +83,7 @@ class Baidu(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -101,10 +100,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Baidu(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -56,7 +56,7 @@ class Bing(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -69,8 +69,7 @@ class Bing(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -87,10 +86,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Bing(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -58,7 +58,7 @@ class BingAPI(Search):
logger.log('ALERT', f'不执行{self.source}模块')
return
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -71,8 +71,7 @@ class BingAPI(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -89,10 +88,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = BingAPI(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -52,7 +52,7 @@ class DuckDuckGO(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -65,8 +65,7 @@ class DuckDuckGO(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -84,10 +83,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
# return # 暂时还有点问题
search = DuckDuckGO(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -52,7 +52,7 @@ class Exalead(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -66,8 +66,7 @@ class Exalead(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -84,10 +83,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Exalead(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+6 -9
View File
@@ -1,8 +1,8 @@
# coding=utf-8
import time
import queue
import json
import base64
import queue
import time
import config
from common.search import Search
from config import logger
@@ -42,10 +42,9 @@ class FoFa(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search()
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -62,10 +61,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = FoFa(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+4 -7
View File
@@ -51,7 +51,7 @@ class Google(Search):
break
self.subdomains = self.subdomains.union(subdomain_find)
page_num += per_page_num
if 'start='+str(page_num) not in resp.text:
if 'start=' + str(page_num) not in resp.text:
break
if '302 Moved' in resp.text:
break
@@ -61,7 +61,7 @@ class Google(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -74,8 +74,7 @@ class Google(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -92,10 +91,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Google(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -57,7 +57,7 @@ class GoogleAPI(Search):
logger.log('ALERT', f'不执行{self.source}模块')
return
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -70,8 +70,7 @@ class GoogleAPI(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -88,10 +87,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = GoogleAPI(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -7
View File
@@ -1,7 +1,6 @@
# coding=utf-8
import time
import queue
import queue
import config
# from shodan import Shodan
from common.search import Search
@@ -44,10 +43,9 @@ class ShodanAPI(Search):
logger.log('ALERT', f'不执行{self.source}模块')
return
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search()
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -64,8 +62,6 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = ShodanAPI(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
+3 -6
View File
@@ -51,7 +51,7 @@ class So(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -64,8 +64,7 @@ class So(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -82,10 +81,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = So(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+4 -7
View File
@@ -1,6 +1,6 @@
# coding=utf-8
import time
import queue
from common.search import Search
from config import logger
@@ -49,7 +49,7 @@ class Sogou(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -62,8 +62,7 @@ class Sogou(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -80,10 +79,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Sogou(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -57,7 +57,7 @@ class Yahoo(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -70,8 +70,7 @@ class Yahoo(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -88,10 +87,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Yahoo(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -53,7 +53,7 @@ class Yandex(Search):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search(self.domain, full_search=True)
# 排除同一子域搜索结果过多的子域以发现新的子域
@@ -66,8 +66,7 @@ class Yandex(Search):
for subdomain in self.subdomains:
if subdomain.count('.') - self.domain.count('.') == layer_num: # 进行下一层子域搜索的限制条件
self.search(subdomain)
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -84,10 +83,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = Yandex(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+3 -6
View File
@@ -68,10 +68,9 @@ class ZoomEyeAPI(Search):
logger.log('ALERT', f'不执行{self.source}模块')
return
logger.log('DEBUG', f'开始执行{self.source}模块搜索{self.domain}的子域')
start = time.time()
self.search()
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -88,10 +87,8 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
"""
search = ZoomEyeAPI(domain)
search.run(rx_queue)
logger.log('INFOR', f'{search.source}模块耗时{search.elapsed}秒发现{search.domain}的子域{len(search.subdomains)}')
logger.log('DEBUG', f'{search.source}模块发现{search.domain}的子域 {search.subdomains}')
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)