题目:
WP:
只有一张没显示好的图片,右键查看源代码
提示source.php,访问该页面
接下来进行代码审计
<?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;
}//page一定不能为空,且为字符串
if (in_array($page, $whitelist)) {
return true;
}//此处若在白名单内,则直接返回true
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);//找到page第一次出现?的位置,截取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\" />";
}
?>
mb_substr():mb_substr ( string $str , int $start [, int $length = NULL
[, string $encoding = mb_internal_encoding() ]] ) : string
mb_strpos :mb_strpos (haystack ,needle )//找到一个字符串在另一个字符串中出现的位置
发现还有个白名单中可以将file设为hint.php
提示我们文件在 ffffllllaaaagggg中,但为了绕过白名单的过滤
我们准备在截取第一个问号出现前的部分这段之前就返回true,所以file=hint.php或者file=source.php,带上参数…/…/…/…/…/…/…/ffffllllaaaagggg,include里面将忽视/前面的内容,直接解析ffffllllaaaagggg
找到flag啦~