解决批量获取子域问题

This commit is contained in:
shmilylty
2019-08-14 16:07:30 +08:00
parent f3540ee07b
commit d9c1cb3937
9 changed files with 57 additions and 39 deletions
+5 -2
View File
@@ -13,10 +13,10 @@ from config import logger
class Database(object):
def __init__(self, db_path=None):
self.conn = self.get_connection(db_path)
self.conn = self.get_conn(db_path)
@staticmethod
def get_connection(db_path):
def get_conn(db_path):
"""
获取数据库对象
@@ -205,3 +205,6 @@ class Database(object):
logger.log('ERROR', e)
else:
return rows
def close(self):
self.conn.close()
+1
View File
@@ -274,4 +274,5 @@ class Module(object):
source, results = self.results
# 将结果存入数据库中
db.save_db(self.domain, results, source)
db.close()
lock.release()
+7 -5
View File
@@ -109,9 +109,11 @@ def get_domains(target):
:param set or str target:
:return: 域名集合
"""
domains = set()
domains = list()
logger.log('INFOR', f'正在获取域名')
if isinstance(target, set):
if isinstance(target, (set, tuple)):
domains = list(target)
elif isinstance(target, list):
domains = target
elif isinstance(target, str):
path = pathlib.Path(target)
@@ -120,9 +122,9 @@ def get_domains(target):
for line in file:
domain = Domain(line.strip()).match()
if domain:
domains.add(domain)
if Domain(target).match():
domains = {target}
domains.append(domain)
elif Domain(target).match():
domains = [target]
logger.log('INFOR', f'获取到{len(domains)}个域名')
return domains