CVE-2025-20393 安全检测工具

34 阅读5分钟

CVE-2025-20393 安全检测工具

项目描述

本项目是一个专业的网络安全工具,专门用于检测Cisco Secure Email Gateway和Secure Email and Web Manager设备上存在的CVE-2025-20393高危漏洞。该漏洞是一个远程代码执行(RCE)漏洞,CVSS评分为10.0(最高级别),目前已在野外被中国关联的APT组织UAT-9686积极利用。本工具通过自动化扫描,帮助安全人员快速识别暴露在互联网上且存在风险的设备,并提示立即采取缓解措施。

功能特性

  • 自动化批量扫描:支持通过命令行参数指定单个或多个目标(域名或IP),也支持从文本文件中读取目标列表。
  • 多端口探测:默认扫描443、80、8443端口,可根据需要自定义端口列表。
  • 并发处理:采用多线程技术,可配置线程数,显著提升扫描速度。
  • 智能指纹识别:通过检测HTTP响应内容和头部信息,识别Cisco AsyncOS、IronPort、Email Security Appliance (ESA)、Security Management Appliance (SMA) 等关键指纹。
  • 风险等级判断:对扫描结果进行分类,清晰标记“高危风险”或“可能安全”等状态。
  • 详细结果输出:当发现潜在风险时,不仅提供URL,还会列出检测到的具体指纹标识,并给出明确的安全建议。

安装指南

本项目为Python脚本,无需复杂安装。

  1. 系统要求

    • Python 3.x
    • 网络连接(用于访问目标)
  2. 依赖库安装: 运行脚本需要requests库。可通过以下命令安装:

    pip install requests
    
  3. 获取工具: 将提供的Python脚本(例如 cve-2025-20393-scanner.py)保存到本地。

使用说明

基础用法

通过命令行传递参数来运行脚本。

扫描单个目标:

python cve-2025-20393-scanner.py 192.168.1.100

扫描多个目标:

python cve-2025-20393-scanner.py example1.com example2.org 10.0.0.5

从文件读取目标列表: 假设 targets.txt 文件中每行包含一个IP或域名。

python cve-2025-20393-scanner.py @targets.txt

高级选项

指定扫描端口: 使用 --ports 参数,多个端口用逗号分隔。

python cve-2025-20393-scanner.py example.com --ports 443,8080,9443

调整并发线程数: 使用 --threads 参数控制扫描速度。

python cve-2025-20393-scanner.py @targets.txt --threads 20

输出解读

  • ⚠️ HIGH RISK: [URL] → Potentially Exposed to CVE-2025-20393!:发现高危风险,目标可能已暴露且存在漏洞。工具会列出检测到的相关指纹(如“cisco”, “ironport”)。
  • ✅ [URL] → No vulnerable indicators found (Likely Safe):未发现明确的漏洞指纹,目标可能安全或未暴露相应接口。

核心代码

以下是项目中的核心功能模块及详细注释:

import requests
import argparse
import threading
from urllib3.exceptions import InsecureRequestWarning

# 禁用SSL证书验证警告(便于测试内部或自签名证书的系统)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# 定义可能暴露漏洞的Spam Quarantine等相关Web路径
COMMON_PATHS = [
    "/", "/login", "/quarantine", "/spamquarantine", "/quarantine/login.cgi",
    "/cgi-bin/quarantine", "/esa/login.cgi", "/sma/login.cgi"
]

# 用于识别Cisco AsyncOS设备的关键词列表
VULN_INDICATORS = [
    "cisco", "asyncos", "ironport", "spam quarantine", "secure email gateway",
    "esa", "sma", "quarantine", "email security appliance"
]

def check_target(target, port=443, timeout=15):
    """
    检查单个目标在指定端口上是否存在CVE-2025-20393暴露风险。
    
    参数:
        target (str): 目标主机名或IP地址。
        port (int): 要检查的端口号。
        timeout (int): 请求超时时间(秒)。
    """
    # 根据端口决定使用HTTP还是HTTPS协议
    scheme = "https" if port in [443, 8443] else "http"
    base_url = f"{scheme}://{target}:{port}"

    try:
        vulnerable = False
        # 遍历所有常见路径进行探测
        for path in COMMON_PATHS:
            url = base_url + path
            # 发起HTTP GET请求,不验证SSL证书,允许重定向
            response = requests.get(url, timeout=timeout, verify=False, allow_redirects=True)
            
            # 如果返回状态码表示页面存在(200)或需要认证(401/403),则进一步分析
            if response.status_code in [200, 401, 403]:
                content = response.text.lower()  # 将响应正文转为小写以便匹配
                headers = str(response.headers).lower()  # 将响应头转为小写字符串
                # 尝试提取HTML标题
                title = response.text.split("<title>")[1].split("</title>")[0].lower() if "<title>" in response.text else ""
                
                # 检查内容、头部或标题中是否包含漏洞指纹关键词
                indicators = [ind for ind in VULN_INDICATORS if ind in content or ind in headers or ind in title]
                
                # 如果找到任何指纹,则判定为高危
                if indicators:
                    print(f"⚠️ HIGH RISK: {url} → Potentially Exposed to CVE-2025-20393!")
                    print(f"   Detected Indicators: {', '.join(indicators)}")
                    print("   🚨 IMMEDIATELY restrict external access and apply Cisco mitigations!")
                    vulnerable = True
        # 如果遍历所有路径都未发现指纹,则判定为可能安全
        if not vulnerable:
            print(f"✅ {base_url} → No vulnerable indicators found (Likely Safe)")
    except Exception as e:
        # 处理请求过程中发生的任何异常(如超时、连接拒绝)


def main():
    """
    主函数,负责解析命令行参数、组织目标列表、分配线程进行并发扫描。
    """
    parser = argparse.ArgumentParser(description="🔍 Safe Exposure Checker for CVE-2025-20393")
    parser.add_argument("targets", nargs="+", help="Target(s): IP/domain or @file.txt for list")
    parser.add_argument("--ports", default="443,80,8443", help="Ports to scan (comma-separated)")
    parser.add_argument("--threads", type=int, default=10, help="Thread count for speed")
    
    args = parser.parse_args()
    
    # 处理目标输入:可以是直接参数,也可以是从文件读取
    targets = []
    for t in args.targets:
        if t.startswith("@"):
            with open(t[1:], "r") as f:
                targets.extend([line.strip() for line in f if line.strip()])
        else:
            targets.append(t)
    
    # 解析端口列表
    ports = [int(p.strip()) for p in args.ports.split(",")]
    
    print(f"🚀 Scanning {len(targets)} target(s) on ports {args.ports}...\n")
    
    def worker(tgt):
        """工作线程函数,负责对一个目标的所有指定端口进行检查。"""
        for p in ports:
            check_target(tgt, p)
    
    # 多线程扫描控制逻辑
    threads = []
    for target in targets:
        t = threading.Thread(target=worker, args=(target,))
        t.start()
        threads.append(t)
        # 当活跃线程数达到上限时,等待这批线程完成
        if len(threads) >= args.threads:
            for th in threads:
                th.join()
            threads = []
    
    # 等待所有剩余线程完成
    for th in threads:
        th.join()
    
    print("\n✅ Scan Complete! If HIGH RISK detected → Act NOW to secure your appliances!")

if __name__ == "__main__":
    main()

6HFtX5dABrKlqXeO5PUv/ydjQZDJ7Ct83xG1NG8fcAOFBHTlsJfG1YvQepI+t6dM