[HCTF 2018]WarmUp……未完

    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];
            //检测变量是否设置,并且不是 NULL
            //如果已经使用unset() 释放了一个变量之后,它将不再是 isset()
            if (! isset($page) || !is_string($page)) {
                echo "you can't see it";
                return false;
            }
            //in_array(needle,sea,bool) — 检查数组中是否存在某个值
            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;
        }
    }//?file=source.php?/../../../../../ffffllllaaaagggg
    //file=source.php%253f/../../../../../ffffllllaaaagggg
    if (! empty($_REQUEST['file'])
        && is_string($_REQUEST['file'])
        && emmm::checkFile($_REQUEST['file'])
    ) {
        include $_REQUEST['file'];
        exit;
    } else {
        echo "
";
    }  
?>

你可能感兴趣的:([HCTF 2018]WarmUp……未完)