[网鼎杯 2020 朱雀组]phpweb WP

打开靶场,js是每5秒发一次请求,抓包看一下,post传了两个参数,一个是date,一个是Y-m-d什么的,很容易联想到date(Y-m-d)函数,页面也返回了当前时间,明显后端采用了call_user_finc(),使用readfile(index.php)或者是file_get_contents(index.php),返回index.php的源码,这里有个很坑的点就是由于一些闭合,后端代码不会完全输出到页面上,需要在burp suite的repeter那里看网页源代码,拿到index.php的源码:

<?php
    $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...");
        }
    }
    ?>
</p>

考虑传参unserialize()函数,然后穿过去

 

这里linux常用指令:find / -name flag*

最后用readfile(/tmp/flagoefiu4r93)函数得到flag

posted @ 2022-06-26 22:12  Galio  阅读(144)  评论(0编辑  收藏  举报