translate

This commit is contained in:
JrDw0
2020-05-09 17:11:01 +08:00
committed by GitHub
parent 117d4eff85
commit 8d2af5d1e5
+13 -12
View File
@@ -9,8 +9,9 @@ from config import setting
class Collect(object):
"""
收集子域名类
Collect subdomains
"""
def __init__(self, domain, export=True):
self.domain = domain
self.elapse = 0.0
@@ -22,19 +23,19 @@ class Collect(object):
def get_mod(self):
"""
获取要运行的模块
Get modules
"""
if setting.enable_all_module:
# modules = ['brute', 'certificates', 'crawl',
# 'datasets', 'intelligence', 'search']
# crawl模块还有点问题
# The crawl module has some problems
modules = ['certificates', 'check', 'datasets',
'dnsquery', 'intelligence', 'search']
# modules = ['intelligence'] # crawl模块还有点问题
# modules = ['intelligence'] # The crawl module has some problems
for module in modules:
module_path = setting.module_dir.joinpath(module)
for path in module_path.rglob('*.py'):
# 需要导入的类
# Classes to be imported
import_module = ('modules.' + module, path.stem)
self.modules.append(import_module)
else:
@@ -42,7 +43,7 @@ class Collect(object):
def import_func(self):
"""
导入脚本的do函数
Import do function
"""
for package, name in self.modules:
import_object = importlib.import_module('.' + name, package)
@@ -51,15 +52,15 @@ class Collect(object):
def run(self):
"""
类运行入口
Class entrance
"""
start = time.time()
logger.log('INFOR', f'开始收集{self.domain}的子域')
logger.log('INFOR', f'Start collecting subdomains of {self.domain}')
self.get_mod()
self.import_func()
threads = []
# 创建多个子域收集线程
# Create subdomain collection threads
for collect_func in self.collect_funcs:
func_obj, func_name = collect_func
thread = threading.Thread(target=func_obj,
@@ -67,10 +68,10 @@ class Collect(object):
args=(self.domain,),
daemon=True)
threads.append(thread)
# 启动所有线程
# Start all threads
for thread in threads:
thread.start()
# 等待所有线程完成
# Wait for all threads to finish
for thread in threads:
# 挨个线程判断超时 最坏情况主线程阻塞时间=线程数*module_thread_timeout
# 超时线程将脱离主线程 由于创建线程时已添加守护属于 所有超时线程会随着主线程结束
@@ -80,7 +81,7 @@ class Collect(object):
if thread.is_alive():
logger.log('ALERT', f'{thread.name}模块线程发生超时')
# 数据库导出
# Export
if self.export:
if not self.path:
name = f'{self.domain}.{self.format}'