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

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
+8 -8
View File
@@ -7,19 +7,20 @@ DNS域传送(DNS zone transfer)指的是一台备用域名服务器使用来自
目的是为了做冗余备份,防止主域名服务器出现故障时 dns 解析不可用。
当主服务器开启DNS域传送同时又对来请求的备用服务器未作访问控制和身份验证便可以利用此漏洞获取某个域的所有记录。
"""
import time
import queue
import dns.resolver
import dns.zone
from config import logger
from common import utils, resolve
from common import resolve, utils
from common.module import Module
from config import logger
class CheckAXFR(Module):
"""
DNS域传送漏洞检查类
"""
def __init__(self, domain: str):
Module.__init__(self)
self.domain = self.register(domain)
@@ -55,7 +56,7 @@ class CheckAXFR(Module):
else:
names = zone.nodes.keys()
for name in names:
subdomain = utils.match_subdomain(self.domain, str(name)+'.'+self.domain)
subdomain = utils.match_subdomain(self.domain, str(name) + '.' + self.domain)
self.subdomains = self.subdomains.union(subdomain)
record = zone[name].to_text(name)
self.results.append(record)
@@ -69,10 +70,9 @@ class CheckAXFR(Module):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}检查{self.domain}的域传送漏洞')
start = time.time()
self.check()
end = time.time()
self.elapsed = round(end - start, 1)
logger.log('DEBUG', f'结束执行{self.source}检查{self.domain}的域传送漏洞')
self.save_json()
self.gen_result()
@@ -95,4 +95,4 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
if __name__ == '__main__':
# do('ZoneTransfer.me')
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+8 -7
View File
@@ -2,17 +2,18 @@
"""
检查crossdomain.xml文件收集子域名
"""
import time
import queue
from config import logger
from common.utils import match_subdomain
from common.module import Module
from common.utils import match_subdomain
from config import logger
class CheckCDX(Module):
"""
检查crossdomain.xml文件收集子域名
"""
def __init__(self, domain: str):
Module.__init__(self)
self.domain = self.register(domain)
@@ -37,10 +38,9 @@ class CheckCDX(Module):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}检查{self.domain}域的crossdomain.xml')
start = time.time()
self.check()
end = time.time()
self.elapsed = round(end - start, 1)
self.save_json()
self.gen_result()
self.save_db()
@@ -61,4 +61,5 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
if __name__ == '__main__':
do('163.com')
result_queue = queue.Queue()
do('163.com', result_queue)
+6 -7
View File
@@ -4,13 +4,13 @@
"""
检查域名证书收集子域名
"""
import ssl
import time
import queue
import socket
from config import logger
import ssl
from common import utils
from common.module import Module
from config import logger
class CheckCert(Module):
@@ -41,10 +41,9 @@ class CheckCert(Module):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}检查{self.domain}域的证书中的子域')
start = time.time()
self.check()
end = time.time()
self.elapsed = round(end - start, 1)
logger.log('DEBUG', f'结束执行{self.source}检查{self.domain}域的证书中的子域')
self.save_json()
self.gen_result()
@@ -67,4 +66,4 @@ def do(domain, rx_queue): # 统一入口名字 方便多线程调用
if __name__ == '__main__':
result_queue = queue.Queue()
do('owasp.org', result_queue)
do('example.com', result_queue)
+6 -5
View File
@@ -2,17 +2,18 @@
"""
检查内容安全策略收集子域名收集子域名
"""
import time
import queue
from config import logger
from common import utils
from common.module import Module
from config import logger
class CheckCSP(Module):
"""
检查内容安全策略收集子域名
"""
def __init__(self, domain, header):
Module.__init__(self)
self.domain = self.register(domain)
@@ -42,10 +43,9 @@ class CheckCSP(Module):
类执行入口
"""
logger.log('DEBUG', f'开始执行{self.source}检查{self.domain}域响应头中的内容安全策略字段')
start = time.time()
self.check()
end = time.time()
self.elapsed = round(end - start, 1)
logger.log('DEBUG', f'结束执行{self.source}检查{self.domain}域响应头中的内容安全策略字段')
self.save_json()
self.gen_result()
@@ -69,6 +69,7 @@ def do(domain, rx_queue, header=None): # 统一入口名字 方便多线程调
if __name__ == '__main__':
import requests
# resp = requests.get('https://content-security-policy.com/')
result_queue = queue.Queue()
resp = requests.get('https://www.baidu.com/')