[网鼎杯 2020 朱雀组]phpweb

写在前面

一.有三个函数可以读取文件:

1.readfile

2.file_get_contents

3.highlight_file

二.回调函数

call_user_func($callback,$parameter)

第一个参数 $callback 是被调用的回调函数,$parameter是回调函数的参数。

进入页面,这里我可以发现页面一直在刷新,会一直变换时间

我们抓个包看看

两个变量:

1.date //显示时间的函数

2.Y-m-d+h%3Ai%3As+a //就是显示日期时分秒

正常来说应该是这样的格式:

date("Y-m-d+h%3Ai%3As+a")

才能显示时间

但是这里被分成了两个参数,那么我们猜测就是回调函数call_user_func

我们把这两个参数改一下获取index.php的代码

这里还可以使用file_get_contents和highlight_file来获取源代码 

1.file_get_contents  php://filter/read=convert.base64-encode/resource=index.php    

2.highlight_file获取源代码建议让他回显在页面,如果在burp里面就会

获取到源代码后就变成了:

<?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...");
        }
    }
?>

 可以看到过滤了非常多的函数,但是可以注意到有一个类叫Test.

那我们是不是就可以传参

$func=unserialize

$p=序列化内容

这样就绕过了他黑名单的检测,因为调用类的函数时没有检测$p的内容

就相当于有一层嵌套在里面,魔术方法__destruct调用了这个类之后,又反序列化再调用一次

有了这层理解我们开始构造exp

放在burp执行一下

 有一个big.jpg还有一个index.php

都不是我们想要的,再看一下根目录

 

 也没有我们想要的,这时候就要学习一个新东西,叫做

find命令

其中有一个命令是

find / -name flag*(因为题目没有提示我们flag的名字所以我们就默认flag就是flag)

因为是查找,所以等待回显有点慢,要等待一会

成功得到flag

 

 

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值