HCTF 2018 Warmup (API functions)

0x01 Title Description

Look at the hint
Here Insert Picture Description
look urlhave filea feel of what's possible to use pseudo-protocol, try the next, not a thing
to sweep through the catalog, find ./source.phpthe source file
source code is as follows

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

0x02 solution to a problem

Read the file contains, whether before checkFile $ _page function takes a file argument first question mark field and check the file name as the file parameter so configured whitelisthint.php?/../../../../../ffffllllaaaagggg

The principle is hint.php?/treated as a directory, the directory after the jump like (this only applies to linux)
and the includefunction is not the same mkdirfunction, if there is no table of contents will error

Published 47 original articles · won praise 2 · Views 3135

Guess you like

Origin blog.csdn.net/a3320315/article/details/102961772