滑稽镇楼,哈哈。
一进来就是个大滑稽,有点意思,审计看元素。
访问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 (! 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\" />";
}
如果有提交file
并且file
为字符串,则调用类当中的checkFile()
函数进行检查,检查通过就包含file
,反之输出滑稽。
再看第一个if
语句
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
如果没有提交参数,或者参数不是字符串,则return
一个false
,并输出"you can't see it"
。没啥用,再看一个并列的if
if (in_array($page, $whitelist)) {
return true;
}
如果提交的参数在白名单里面,则返回true
,即可以包含参数。白名单在一段当中,有两个source.php
和hint.php
,目前访问的就是source.php
,那现在送个hint.php
看看会有什么。
提示结果在ffffllllaaaagggg
里面,没法用,继续看,下一个if
走起。
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
截取参数中的?
之前的一部分,如果没有?
则,截取所有参数。
mb_strpos()
是用来截取汉字的。。。
这样的话就有提示了阿,构造参数file=hint.php?ffffllllaaaagggg
即可。
执行以后,发现没有echo
那行讨厌的字you can't see it
,说明确实return
的true
,也就是已经成功绕过,但是ffffllllaaaagggg
并不在此目录下,接着构造file=hint.php?../ffffllllaaaagggg
,接着不停的加../
即可,如果这样还不行,那就只能换方法了,好在第五个../
的时候flag
就出来了。
后面的其实可以不需要,大概是用于post
提交方式的payload
吧。。。