先看一下源碼
<?php
error_reporting(0);
class a
{
public $uname;
public $password;
public function __construct($uname,$password)
{
$this->uname=$uname;
$this->password=$password;
}
public function __wakeup()
{
if($this->password==='yu22x')
{
include('flag.php');
echo $flag;
}
else
{
echo 'wrong password';
}
}
}
function filter($string){
return str_replace('Firebasky','Firebaskyup',$string);
}
$uname=$_GET[1];
$password=1;
$ser=filter(serialize(new a($uname,$password)));
$test=unserialize($ser);
?>
看題目是構造一個反序列化逃逸。
因為
str_replace('Firebasky','Firebaskyup',$string);
的存在,傳入
Firebasky
後會多兩個字元。
因為我們要逃逸的是這串字元
s:8:"password";s:5:"yu22x";}
因為我們隻能讀入一個
uname
,而原來的
password
預設為1,試着構造
我們這句話裡,要覆寫掉原來的password,需要
";s:8:"password";s:5:"yu22x";}
利用這句話,一共有30位,而每個
str_replace
多兩位,是以一共需要用15個Firebasky來構造逃逸。是以,構造payload
得到flag