4、出现了php代码,进行代码分析 ① 观察参数file,首先file不能为空,其次要满足是字符串类型 php 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满足条件便开始传入emmm类下的checkfile()方法,进行代码检测,如果检测通过,便可以进入file变量的目录中.
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
is_string($page)判断变量为字符串类型.
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
length)截取函数,开始位置为start设置,常委为length,返回到_page中
$_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;
} ```