ALLMN CTF19 Writeup

この大会は2019/5/1 9:00(JST)~2019/5/4 23:00(JST)に開催されました。
今回もチームで参戦。結果は3475点で417チーム中8位でした。
自分で解けた問題をWriteupとして書いておきます。

Free point (Warmup 10)

問題にフラグが書いてあった。

ALLMN{Y3S_TH1S_1S_Y0UR_FLAG_27SJAL}

Discord (Warmup 10)

Discordに入って、ピン止めされたメッセージを見ると、フラグが書いてあった。

ALLMN{TH4NKS_F0R_J01N1NG_US_2JKLPO}

Saturn.MN (Social Engineering 30)

タブ表示になっている、viewやaboutなどを見ていく。
http://saturn.mn/p/425にフラグが書かれていた。

ALLMN{W3LC0M3_T0_S4TURN_MN}

Easy Math (Warmup 30)

128と56のGCD(最大公約数)は8、LCMは128*56/8で896。

ALLMN{896_8}

Funny Website (Web 50)

HTMLソースコードのコメントにフラグの一部が書いてある。

<!-- ALLMN{W3LL_Y0U -->

http://chall.all.mn/funny/style.cssのコメントにフラグの一部が書いてある。

/*_C4N_1NSP3CT */

http://chall.all.mn/funny/function.jsのコメントにフラグの一部が書いてある。

// _M3_I28DJA}

全部繋げると、フラグになる。

ALLMN{W3LL_Y0U_C4N_1NSP3CT_M3_I28DJA}

Robots (Web 70)

http://chall.all.mn/robot/robots.txtにアクセスする。

User-agent: *
Disallow: /allmnflag.php

http://chall.all.mn/robot/allmnflag.phpにアクセスすると、フラグが表示された。

ALLMN{W3B_R0B0TS_TXT_7DHJ9E}

Question & Answer (Crypto 100)

添付ファイルのテキストはシーザー暗号なので、https://www.geocachingtoolbox.com/index.php?lang=en&page=caesarCipherで復号する。

Rotation 18:
hey, you did a nice job! so here is your answer: eqra_cpf_rcuvg_vjku . but make sure it is in reverse form.

さらにeqra_cpf_rcuvg_vjkuの部分を復号する。

Rotation 2:
copy_and_paste_this

http://chall.all.mn/asuult/index.php?q=1でcopy_and_paste_thisを答えると、フラグが表示された。

ALLMN{Y3S_Y0U_D1D_1T_4Y7JKP}

What is this? (Crypto 100)

Brainfuck言語なので、https://sange.fi/esoteric/brainfuck/impl/interp/i.htmlで実行すると、フラグが表示された。

ALLMN{1_L0V3_BR41N_F4CK_3IQKAP}

Damn! (Crypto 100)

ChromeデベロッパーツールのConsoleで実行してみると、以下のエラーが発生。

Uncaught ReferenceError: f4ckjs is not defined
    at eval (eval at  (local-ntp.html:1), :3:1)
    at :1:4558

f4ckjsがフラグとなるワードとして通った。

ALLMN{f4ckjs}

Find that word (Misc 100)

添付ファイルを解凍すると大量のファイルが展開される。

$ grep -ilr ALLMN findtheflag/*
findtheflag/76.txt
$ grep ALLMN findtheflag/76.txt
         Pauses in Heaven doyoureallywanttoknowtheflag?hereitisALLMN{GR3P_1S_S1mple}.
ALLMN{GR3P_1S_S1mple}

SQL (Web 100)

SQLインジェクションで攻撃。以下の通り入力してログインすると、フラグが表示された。

Username: ' or 1=1 #
ALLMN{W0W_Y0U_D1D_SQLi}

Do you know that? (Crypto 100)

https://github.com/JohnHammond/ctf-katanaのDNAコード表を見てデコードする。

RCCDE{1E_DP_UE4}

https://www.geocachingtoolbox.com/index.php?lang=en&page=caesarCipherで復号する。

Rotation 17:
ALLMN{1N_MY_DN4}
ALLMN{1N_MY_DN4}

My favorite number (Reversing 150)

逆アセンブルする。関係する部分は以下のようになっている。

push    rbp
mov     rbp, rsp
sub     rsp, 10h
mov     rax, fs:28h
mov     [rbp+var_8], rax
xor     eax, eax
lea     rdi, s          ; "Minii durtai toog oruulna uu"
call    _puts
lea     rax, [rbp+x]
mov     rsi, rax
lea     rdi, format     ; "%d"
mov     eax, 0
call    _scanf
mov     eax, [rbp+x]
cmp     eax, 4D1h
jnz     short loc_797

0x4D1と比較している。Pythonで0x4D1の値を確認する。

>>> 0x4D1
1233
ALLMN{1233}

ROCK (Forensics 150)

PDFファイルにパスワードがかかっているので、pdfcrackでパスワードを割り出す。

$ pdfcrack --wordlist=dict/rockyou.txt level-1.pdf 

PDF version 1.5
Security Handler: Standard
V: 2
R: 3
P: -4
Length: 128
Encrypted Metadata: True
FileID: a474737d247fa5259a6fc058ef096d2b
U: d18066309b9c6a7058223fcfa93890430122456a91bae5134273a6db134c87c4
O: 884bb701492d79d69ff17a588a87adb263143d261bdf1dbb0a616a47944d713e
Average Speed: 34703.2 w/s. Current Word: 'avril84'
Average Speed: 34329.1 w/s. Current Word: 'porn123tip'
Average Speed: 32437.8 w/s. Current Word: 'aritzel'
Average Speed: 31514.0 w/s. Current Word: 'xwettie'
Average Speed: 35259.1 w/s. Current Word: 'target0899'
Average Speed: 33870.6 w/s. Current Word: 'salimd'
Average Speed: 34358.9 w/s. Current Word: 'penchalick'
Average Speed: 30534.2 w/s. Current Word: 'ms.kylan'
Average Speed: 30263.8 w/s. Current Word: 'm0891553577'
Average Speed: 30269.2 w/s. Current Word: 'kiri404'
Average Speed: 29818.8 w/s. Current Word: 'jaspal209'
Average Speed: 28429.8 w/s. Current Word: 'hair821sold381'
Average Speed: 28589.2 w/s. Current Word: 'erestodoparamimau'
Average Speed: 31237.2 w/s. Current Word: 'crosby87fan'
Average Speed: 35053.8 w/s. Current Word: 'bisina'
Average Speed: 35201.6 w/s. Current Word: 'ai3office1'
Average Speed: 35135.8 w/s. Current Word: 'JenJen!'
Average Speed: 33758.6 w/s. Current Word: '898989r'
found user-password: '551731'

このパスワードでPDFファイルを開くと、フラグが書いてあった。

ALLMN{Y0U_DID_IT!}

Windows XP (Web 150)

UserAgentを該当するものにして、アクセスする

例)Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
$ curl -H "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" http://chall.all.mn/windows/
<!DOCTYPE html>
<!--
__  __          _____  ______   ______     __
|  \/  |   /\   |  __ \|  ____| |  _ \ \   / /
| \  / |  /  \  | |  | | |__    | |_) \ \_/ /
| |\/| | / /\ \ | |  | |  __|   |  _ < \   /
| |  | |/ ____ \| |__| | |____  | |_) | | |
|_|__|_/_/    \_\_____/|______| |____/__|_|____    _ _____ _   _  _____  ____  __  __ _   _ _____          _
/ ____|  /\   | \ | |/ ____| |  | |_   _|  __ \  ( )_   _| \ | |/ ____|/ __ \|  \/  | \ | |_   _|   /\   ( )
| (___   /  \  |  \| | |    | |__| | | | | |__) | |/  | | |  \| | (___ | |  | | \  / |  \| | | |    /  \  |/
\___ \ / /\ \ | . ` | |    |  __  | | | |  _  /      | | | . ` |\___ \| |  | | |\/| | . ` | | |   / /\ \
____) / ____ \| |\  | |____| |  | |_| |_| | \ \     _| |_| |\  |____) | |__| | |  | | |\  |_| |_ / ____ \
|_____/_/ _  \_\_| \_|\_____|_|_ |_|_____|_|  \_\   |_____|_| \_|_____/ \____/|_|  |_|_| \_|_____/_/    \_\
   /\   | |    | |      |  \/  | \ | |
  /  \  | |    | |      | \  / |  \| |
 / /\ \ | |    | |      | |\/| | . ` |
/ ____ \| |____| |____ _| |  | | |\  |
/_/    \_\______|______(_)_|  |_|_| \_|
-->
<html lang="mn" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>ALL.MN Academy</title>
    <link rel="icon" href="icon.png">
    <link rel="stylesheet" href="style.css" type="text/css">
  </head>
  <body>
    <div class="blocked">
      <img src="icon.png" width="200px"><br><br>
      Sorry, you cannot enter!<br>
      You can enter if you are using Windows XP and Internet Explorer.<br>
      ALLMN{CH4NG3_TH3_US3R_AG3NT_WD8KKA}    </div>
  </body>
</html>
ALLMN{CH4NG3_TH3_US3R_AG3NT_WD8KKA}

Encrypted (Crypto 250)

暗号は16進数で長さは608。1文字ずつMD5にしてつなげていると、推測して復号する。

import hashlib

h_dic = {}
for code in range(32, 127):
    h = hashlib.md5(chr(code)).hexdigest()
    h_dic[h] = chr(code)

with open('encrypted.txt', 'r') as f:
    data = f.read().rstrip()

flag = ''
for i in range(0, len(data), 32):
    flag += h_dic[data[i:i+32]]

print flag
ALLMN{MD5_1S_CR4ZY}

Admin panel (Crypto 250)

John the Ripperでパスワードを割り出す。

$ unshadow passwd shadow > passwd_shadow
$ john --wordlist=../dict/rockyou.txt passwd_shadow
Loaded 1 password hash (crypt, generic crypt(3) [?/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
hellokitty       (root)
1g 0:00:00:01 100% 0.7462g/s 214.9p/s 214.9c/s 214.9C/s alyssa..brenda
Use the "--show" option to display all of the cracked passwords reliably
Session completed

root/hellokittyでログインする。

$ ./login
Sain uu? Ta nevtreh ner bolon nuuts ugee oruulna uu! CTF19.ALL.MN Admin Login
Nevtreh ner: 
root
Nuuts ug: 
hellokitty
ALLMN{G00DJ0B_Y0U_AR3_T00_G00D_SHD8WK}
ALLMN{G00DJ0B_Y0U_AR3_T00_G00D_SHD8WK}

My Little Electric CodeBook (Crypto 300)

ブロック暗号のECBモードの問題。ブロックごとに暗号文が同じであれば平文が同じことを使って解く。
以下の2つに暗号文を16バイトずつ区切って同じものを探す。

4c9e192389e8791554ae342a77069573
661a44fa2a2ab220ed33af9081049b8d

すると、以下の2行が見つかる。

4c9e192389e8791554ae342a77069573fd3281ec97b52ba8817e8560af2b187d:ALLMN{KTZFQVTLIPMONKTERRSCERKLK}
2d3d123382b1fcc266bf0bc5086da8b2661a44fa2a2ab220ed33af9081049b8d:ALLMN{HBSOPKYGXEPHNMSYKYHFXQIVW}

それぞれ前半と後半を切り出す。

ALLMN{KTZFQVTLIP
PHNMSYKYHFXQIVW}

結合するとフラグになる。

ALLMN{KTZFQVTLIPPHNMSYKYHFXQIVW}