- APP: metinfo6.0
- Reference: https://nosec.org/home/detail/1740.html
0x01 XXE
XXE漏洞之前接触的比较少。
<?php
$xml = simplexml_load_string($_GET['xml']);
print_r((string)$xml);
?>
这里是利用了 simplexml_load_string
simplexml_load_string — Interprets a string of XML into an object
注入字符串,注意url编码
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [<!ENTITY file SYSTEM "file:///etc/passwd">]>
<root>&file;</root>
0x02 分析
位于metinfo60/app/system/pay/web/pay.class.php
:
$GLOBALS['HTTP_RAW_POST_DATA']
貌似通常用于微信接口获取数据。
对于PHP的外部post方法传入, $_POST
, 他是以关联数组的方式提交数据, 并对此进行编码处理。如urldecode。无法解析text/xml, application/json等非 application/x-www.form-urlencoded数据类型内容。\
$HTTP_RAW_POST_DATA
, 在PHP无法识别Content-Type的时候,就会把 POST 数据填入到 $HTTP_RAW_POST_DATA 中。[1]
Warning This feature was DEPRECATED in PHP 5.6.0, and REMOVED as of PHP 7.0.0.
输入清楚了, 那么这里就可以直接注入一个原始xml。 (这里还要开启always_populate_raw_post_data
)
[2] 。
然后这个注入处是无回显的。通过远程访问http进行注入。
参考
[1] 说说$POST 、$HTTP_RAW_POST_DATA、php://input三者之间的区别,https://segmentfault.com/a/1190000003707728
[2] 小试XML实体注入攻击, https://chybeta.github.io/2017/07/04/小试XML实体注入攻击/