本题考查的知识点有:php源码审计,url过滤
1.首先我们进入,看到了一个大大的滑稽,所以先看看源代码
2.看到提示:source.php,所以我们访问一下
<?php
highlight_file(__FILE__);
class emmm//定义emmm类
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
//白名单列表 if (! isset($page)
|| !is_string($page)) {
//检测变量page是不是被声明,变量page是不是字符串
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
//检测传进来的值page是否匹配whitelist
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);//过滤page的问号
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);/过滤page的问号,二次过滤
if (in_array($_page, $whitelist)) {
return true;//检测传进来的值page是否匹配whitelist
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])//file不能为空
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {//检测传进来的值page是否匹配whitelist
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
共存在两次问号过滤,三次比较检测,所以我们在构造payload时要记得加?
include函数一般放在程序的流程控制中,当程序执行时碰到才会引用
3.我们来看看这个代码,发现还存在一个叫hint.php的文件,所以我们再访问一下
4.出题者说flag不在这里,而是在ffffllllaaaagggg里面,则通过试探payload,fileffffllllaaaagggg可能存在于上n级目录中:
得到flag了