环境访问
打开网站就是个这个:

F12看源码(ctrl+shift+c):

看到有个这个:
<body> <br><img src="https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg" /></body>
</html>
|
访问这个链接后还是那个图片;
在这个靶机的url+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; }
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\" />"; } ?>
|
看到”hint”=>”hint.php”后寻找hint.php

根据提示找到这个:

不是flag;
源码审计
php源码中定义了一个emm类,且其中实现了一个checkFile函数,然后该类的主题内容如下:

其中_REQUEST[‘file’] 表示从 HTTP 请求中提取名为 file
的参数,直接在url后边加上 ?filename即可设置这个参数:

看源码可知这个file参数不能为空、必须是string,且能通过checkFile的检查:

checkFile表明要在白名单中,
攻击成功

参考
https://cloud.tencent.com/developer/article/2349595