CVE-2025-66516 Apache Tika 漏洞检测工具
项目概述
CVE-2025-66516 是一个针对 Apache Tika 服务器的关键漏洞检测工具。该漏洞是一个 XML 外部实体(XXE)注入漏洞,影响 Apache Tika 的核心处理引擎,CVSS 评分为 10.0(最高风险等级)。攻击者可以通过上传包含 XFA 内容的恶意 PDF 文件,触发服务器敏感文件泄露、服务器端请求伪造(SSRF),甚至可能导致远程代码执行(RCE)。
本工具旨在安全地检测远程 Apache Tika 服务器是否受到此漏洞影响,仅通过检查版本头信息,无需发送恶意载荷。
功能特性
- 安全检测:仅通过查询服务器版本信息进行判断,无需发送恶意 PDF 文件,避免对目标系统造成任何损害。
-
全面覆盖:支持检测所有受影响的 Apache Tika 版本,包括
tika-core1.x 至 3.2.1 以及tika-parsers分支 1.13 至 1.28.5。 - 简单易用:提供命令行界面,只需指定目标 URL 即可运行。
- 结果清晰:明确提示目标服务器处于“易受攻击”或“安全”状态,并给出升级建议。
- 抗干扰:内置 SSL 警告抑制功能,便于测试内部或使用自签名证书的实例。
安装指南
该工具基于 Python 3 开发,安装过程非常简单。
- 环境要求:确保系统已安装 Python 3.x。
-
依赖安装:本工具仅依赖
requests库。如果尚未安装,可通过 pip 安装:pip install requests -
获取脚本:将提供的 Python 脚本保存为
CVE-2025-66516.py。 -
(可选)赋予执行权限:在 Linux/macOS 系统上,可以赋予脚本执行权限:
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 :police_car_light: VULNERABLE to CVE-2025-66516 (CVSS 10.0)! Upgrade to Apache Tika ≥ 3.2.2 immediately -
版本安全时:
[+] Version response from /: Apache Tika 3.2.2 :check_mark_button: 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
"""
import sys
import requests
from urllib3.exceptions import InsecureRequestWarning
# 如果测试内部或自签名实例,抑制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"
}
def banner():
"""打印工具横幅,显示项目信息和CVE详情。"""
print(r"""
██████╗ ██╗ █████╗ ██████╗ ██╗ ██╗ █████╗ ███████╗ ██╗ ██╗
██╔══██╗ ██║ ██╔══██╗ ██╔════╝ ██║ ██╔╝ ██╔══██╗ ██╔════╝ ██║ ██║
██████╔╝ ██║ ███████║ ██║ █████╔╝ ███████║ ███████╗ ███████║
██╔══██╗ ██║ ██╔══██║ ██║ ██╔═██╗ ██╔══██║ ╚════██║ ██╔══██║
██████╔╝ ███████╗ ██║ ██║ ╚██████╗ ██║ ██╗ ██║ ██║ ███████║ ██║ ██║
╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝
CVE-2025-66516 — Critical Apache Tika Vulnerability
""")
def check_tika_version(url, timeout=10):
"""
尝试从目标URL获取Apache Tika版本。
尝试访问 /version 和根路径 / 端点。
返回版本字符串,失败则返回 None。
"""
try:
# 大多数Tika服务器在/version或根路径暴露版本信息
for endpoint in ["/version", "/"]:
r = requests.get(
f"{url.rstrip('/')}{endpoint}",
timeout=timeout,
verify=False,
headers={"Accept": "text/plain"}
)
if r.status_code == 200:
version = r.text.strip()
print(f"[+] Version response from {endpoint}: {version}")
return version
except Exception as e:
print(f"[-] Connection error: {e}")
return None
def is_vulnerable(version):
"""
根据获取的版本字符串判断是否属于受影响的版本。
返回布尔值,True表示易受攻击。
"""
if not version:
return False
# 清理版本字符串,移除常见前缀并转为小写
version = version.lower().replace("apache tika ", "").strip()
for vuln in VULNERABLE_VERSIONS:
if version.startswith(vuln):
return True
return False
def main():
"""主函数,协调整个检测流程。"""
banner()
# 检查命令行参数
if len(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)
if not version:
print("[-] Could not retrieve Tika version – is it running?")
sys.exit(1)
# 2. 判断并输出结果
if is_vulnerable(version):
print(":police_car_light: VULNERABLE to CVE-2025-66516 (CVSS 10.0)!")
print(" Upgrade to Apache Tika ≥ 3.2.2 immediately")
else:
print(":check_mark_button: SAFE – version is patched or not affected")
if __name__ == "__main__":
main()
6HFtX5dABrKlqXeO5PUv/ydjQZDJ7Ct83xG1NG8fcAOko2QgR3cZVsAQWPedfETG