Pytest实战包:含登录验证与API接口测试的完整可运行工程
2026/6/6 20:21:05
CVE-2025-66516 是一个针对 Apache Tika 服务器的关键漏洞检测工具。该漏洞是一个 XML 外部实体(XXE)注入漏洞,影响 Apache Tika 的核心处理引擎,CVSS 评分为 10.0(最高风险等级)。攻击者可以通过上传包含 XFA 内容的恶意 PDF 文件,触发服务器敏感文件泄露、服务器端请求伪造(SSRF),甚至可能导致远程代码执行(RCE)。
本工具旨在安全地检测远程 Apache Tika 服务器是否受到此漏洞影响,仅通过检查版本头信息,无需发送恶意载荷。
tika-core1.x 至 3.2.1 以及tika-parsers分支 1.13 至 1.28.5。该工具基于 Python 3 开发,安装过程非常简单。
requests库。如果尚未安装,可通过 pip 安装:pipinstallrequestsCVE-2025-66516.py。chmod+x CVE-2025-66516.py运行脚本时,需要将目标 Apache Tika 服务器的 URL 作为参数传入。
python3 CVE-2025-66516.py http://目标地址:端口假设你的 Apache Tika 服务器运行在192.168.1.100的9998端口上:
python3 CVE-2025-66516.py http://192.168.1.100:9998发现漏洞时:
[+] Version response from /version: Apache Tika 1.28.4 🚨 VULNERABLE to CVE-2025-66516 (CVSS 10.0)! Upgrade to Apache Tika ≥ 3.2.2 immediately版本安全时:
[+] Version response from /: Apache Tika 3.2.2 ✅ SAFE – version is patched or not affected无法连接时:
[-] Connection error: HTTPConnectionPool(...) [-] Could not retrieve Tika version – is it running?以下是本工具的核心代码部分及注释。
#!/usr/bin/env python3""" CVE-2025-66516 Safe Detector Detects if a remote Apache Tika server is vulnerable to the critical XXE by checking the version header only (no malicious PDF sent). Author : Ash Wesker Date : Dec 2025 CVE : CVE-2025-66516 (CVSS 10.0) Target : Apache Tika ≤ 3.2.1 / ≤ 1.28.5 Github : https://github.com/Ashwesker/Blackash-CVE-2025-66516 """importsysimportrequestsfromurllib3.exceptionsimportInsecureRequestWarning# 如果测试内部或自签名实例,抑制SSL警告requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)# 定义所有已知的受影响的版本前缀VULNERABLE_VERSIONS={# tika-core 分支的受影响版本"1.","2.","3.0","3.1","3.2.0","3.2.1",# tika-parsers (旧分支) 的受影响版本"1.13","1.14","1.15","1.16","1.17","1.18","1.19","1.20","1.21","1.22","1.23","1.24","1.25","1.26","1.27","1.28.0","1.28.1","1.28.2","1.28.3","1.28.4","1.28.5"}defbanner():"""打印工具横幅,显示项目信息和CVE详情。"""print(r""" ██████╗ ██╗ █████╗ ██████╗ ██╗ ██╗ █████╗ ███████╗ ██╗ ██╗ ██╔══██╗ ██║ ██╔══██╗ ██╔════╝ ██║ ██╔╝ ██╔══██╗ ██╔════╝ ██║ ██║ ██████╔╝ ██║ ███████║ ██║ █████╔╝ ███████║ ███████╗ ███████║ ██╔══██╗ ██║ ██╔══██║ ██║ ██╔═██╗ ██╔══██║ ╚════██║ ██╔══██║ ██████╔╝ ███████╗ ██║ ██║ ╚██████╗ ██║ ██╗ ██║ ██║ ███████║ ██║ ██║ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ CVE-2025-66516 — Critical Apache Tika Vulnerability """)defcheck_tika_version(url,timeout=10):""" 尝试从目标URL获取Apache Tika版本。 尝试访问 /version 和根路径 / 端点。 返回版本字符串,失败则返回 None。 """try:# 大多数Tika服务器在/version或根路径暴露版本信息forendpointin["/version","/"]:r=requests.get(f"{url.rstrip('/')}{endpoint}",timeout=timeout,verify=False,headers={"Accept":"text/plain"})ifr.status_code==200:version=r.text.strip()print(f"[+] Version response from{endpoint}:{version}")returnversionexceptExceptionase:print(f"[-] Connection error:{e}")returnNonedefis_vulnerable(version):""" 根据获取的版本字符串判断是否属于受影响的版本。 返回布尔值,True表示易受攻击。 """ifnotversion:returnFalse# 清理版本字符串,移除常见前缀并转为小写version=version.lower().replace("apache tika ","").strip()forvulninVULNERABLE_VERSIONS:ifversion.startswith(vuln):returnTruereturnFalsedefmain():"""主函数,协调整个检测流程。"""banner()# 检查命令行参数iflen(sys.argv)!=2:print("Usage: python3 CVE-2025-66516.py http://target:9998")print("Example: python3 CVE-2025-66516.py http://192.168.1.10:9998")sys.exit(1)target=sys.argv[1]print(f"[*] Targeting:{target}\n")# 1. 获取版本version=check_tika_version(target)ifnotversion:print("[-] Could not retrieve Tika version – is it running?")sys.exit(1)# 2. 判断并输出结果ifis_vulnerable(version):print("🚨 VULNERABLE to CVE-2025-66516 (CVSS 10.0)!")print(" Upgrade to Apache Tika ≥ 3.2.2 immediately")else:print("✅ SAFE – version is patched or not affected")if__name__=="__main__":main()6HFtX5dABrKlqXeO5PUv/ydjQZDJ7Ct83xG1NG8fcAOko2QgR3cZVsAQWPedfETG
更多精彩内容 请关注我的个人公众号 公众号(办公AI智能小助手)
对网络安全、黑客技术感兴趣的朋友可以关注我的安全公众号(网络安全技术点滴分享)