- 本题考察的是phpMyAdmin 4.8.x before 4.8.2 本地文件包含
- 漏洞编号 CVE-2018-12613 [https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-12613]
WP
打开页面是个😊,Ctrl+U 查看源代码,发现 source.php
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
if语句判断:
- 是否包含file参数;
2.file是否是字符串;
3.通过checkFile检测file参数,第一个if判断page,不可用,第三个语句截取'?'前部分,由于?被后部分被解析为get方式提交的参数,也不可利用第四个if语句中,先进行url解码再截取,因此我们可以将?经过两次url编码,在服务器端提取参数时解码一次,checkFile函数中解码一次,仍会解码为'?',仍可通过第四个if语句校验。('?'两次编码值为'%253f'),构造url
http://****/source.php?file=source.php%3f25../../../../../../ffffllllaaaagggg
读取到flag。
网友评论