You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MiaCTFer/client/subdomain/oneforall/modules/check/cdx.py

74 lines
2.2 KiB

"""
检查crossdomain.xml文件收集子域名
"""
from client.subdomain.oneforall.common.module import Module
from client.subdomain.oneforall.common import utils
class CheckCDX(Module):
"""
检查crossdomain.xml文件收集子域名
"""
def __init__(self, domain: str):
"""
初始化 CheckCDX 类
:param domain: 目标域名
"""
Module.__init__(self) # 调用父类 Module 的初始化方法
self.domain = self.register(domain) # 注册域名并保存
self.module = 'Check' # 模块名称
self.source = "CrossDomainXml" # 数据源标识
def check(self):
"""
检查crossdomain.xml文件以收集子域名
"""
# 定义可能的 crossdomain.xml 文件路径
urls = [f'http://{self.domain}/crossdomain.xml',
f'https://{self.domain}/crossdomain.xml',
f'http://www.{self.domain}/crossdomain.xml',
f'https://www.{self.domain}/crossdomain.xml']
for url in urls:
# 获取请求头和代理
self.header = self.get_header()
self.proxy = self.get_proxy(self.source)
# 发送 GET 请求,检查 crossdomain.xml 文件
response = self.get(url, check=False)
if not response:
return # 如果请求失败,跳过该 URL
# 如果文件内容非空,则匹配并收集子域名
if response and len(response.content):
self.subdomains = utils.match_subdomain(self.domain, response.text)
def run(self):
"""
类执行入口,执行检查并保存结果
"""
self.begin() # 开始执行
self.check() # 执行子域名检查
self.finish() # 完成执行
# 保存结果
self.save_json()
self.gen_result()
self.save_db()
def do(domain): # 统一入口,方便多线程调用
"""
类统一调用入口
:param domain: 域名
"""
check = CheckCDX(domain) # 创建 CheckCDX 实例
check.run() # 执行检查
if __name__ == '__main__':
do('example.com') # 对 example.com 执行检查