NeverLAN CTF 2018 Writeup

この大会は2018/2/24 4:00(JST)~2018/2/27 9:00(JST)に開催されました。
今回もチームで参戦。結果は6973点で816チーム中15位でした。
自分で解けた問題をWriteupとして書いておきます。

basic math (Scripting 10)

合計値を求めるだけ。

with open('some_numbers.txt', 'r') as f:
    lines = f.readlines()

sum = 0
for line in lines:
    sum += int(line.strip())

print sum
49562942146280612

more basic math (Scripting 50)

合計値を求めるだけ。

with open('some_more_numbers.txt', 'r') as f:
    lines = f.readlines()

sum = 0
for line in lines:
    sum += int(line.strip())

print sum
50123971501856573397

even more basic math with some junk (Scripting 100)

数値以外が入ってくることがあることに気を付け、合計値を出す。

with open('even_more_numbers_with_some_mild_inconveniences.txt', 'r') as f:
    lines = f.readlines()

sum = 0
for line in lines:
    line = line.strip().replace(',', ' ')
    nums = line.split(' ')
    for num in nums:
        if num.isdigit():
            sum += int(num)

print sum
34659711530484678082

Encoding != Hashing (Passwords 100)

NetworkMinorでpcapファイルを開くと、Credentialsタブでフラグを確認できる。
f:id:satou-y:20180304193022p:plain

flag{help-me-obiwan}

Zip Attack (Passwords 100)

添付ファイルの構成から明らかにZIPの既知平文攻撃で解ける問題。

$ zipinfo encrypted.zip 
Archive:  encrypted.zip   186312 bytes   3 files
drwxr-xr-x  3.0 unx        0 bx stor 23-Feb-18 10:53 supersecretstuff/
-rw-r--r--  3.0 unx       34 TX stor 23-Feb-18 10:53 supersecretstuff/flag.txt
-rw-r--r--  3.0 unx   220680 BX defX 23-Feb-18 10:48 supersecretstuff/sw-iphone-wallpaper-first-order.jpg
3 files, 220714 bytes uncompressed, 185662 bytes compressed:  15.9%
$ unzip known-file.zip 
Archive:  known-file.zip
  inflating: sw-iphone-wallpaper-first-order.jpg
$ ./pkcrack-1.2.2/src/pkcrack -C encrypted.zip -c supersecretstuff/sw-iphone-wallpaper-first-order.jpg -p sw-iphone-wallpaper-first-order.jpg -P known-file.zip -d decrypted.zip
Files read. Starting stage 1 on Sat Feb 24 11:10:01 2018
Generating 1st generation of possible key2_185639 values...done.
Found 4194304 possible key2-values.
Now we're trying to reduce these...
                          :
Finished on Sat Feb 24 11:10:36 2018
$ unzip decrypted.zip
Archive:  decrypted.zip
   creating: supersecretstuff/
 extracting: supersecretstuff/flag.txt  
  inflating: supersecretstuff/sw-iphone-wallpaper-first-order.jpg  
$ cat supersecretstuff/flag.txt
flag{plaintext-attacks-are-cool!}
flag{plaintext-attacks-are-cool!}

The WIFI Network (Passwords 200)

WIFIのキーを見つける問題。

$ aircrack-ng -w dict/rockyou.txt neverlan.cap 
Opening neverlan.cap
Read 15 packets.

   #  BSSID              ESSID                     Encryption

   1  C6:3D:C7:A2:18:A4  neverlan                  WPA (1 handshake)

Choosing first network as target.

Opening neverlan.cap
Reading packets, please wait...

                                 Aircrack-ng 1.1


                   [01:49:35] 3065940 keys tested (783.26 k/s)


                           KEY FOUND! [ obiwan17 ]


      Master Key     : A9 9B 5F 42 6D 12 57 4E 72 86 3C 47 15 C1 49 1F 
                       FD EB 45 47 EB 2C 6C 37 F0 10 B2 BC 93 21 76 45 

      Transient Key  : 4F E2 99 2C F5 05 67 28 D7 AD 50 58 C6 54 69 E1 
                       33 96 6D 92 5B 65 13 80 91 37 CB 4D 6A 5E 45 4A 
                       78 36 F8 6A 1C 89 30 86 1F D9 D4 5C 57 22 29 F1 
                       53 CA 97 3E FA 8C D6 A7 96 AB DA F9 7D 36 DD 8B 

      EAPOL HMAC     : 7F E2 C8 CE E1 4D 48 05 D4 D7 97 1B C8 C1 3A 86
obiwan17

Neo's Recon (Recon 200)

NeverLAN Neoで検索すると、https://neverlanctf.com/Neoというページがある。
ソースを見ると、右下の位置にsubmitのinputがあり、hidden属性もある。

<form method="post" action="ZD.php">
	<input type="submit" name="submit" value="submit" class="alt" style="position:fixed;bottom:0;right:0;padding:0;z-index:99999;background:transparent;">
	<input type="hidden" name="riddle" maxlength="3" minlength="3" value="">
	<!-- 
		Finding this form is half the challenge. Now can you solve the riddle?
		Edit the input field above to solve the challenge.
			type:text; maxlength: 3; minlength: 3;  
			solve -> riddle: To grow your mental perception and increase your cognizance.  Never let him stop growing. Never let him die; 
	-->
</form>

mental perception cognizance で検索すると ken というあやしい人名がある。

$ curl https://www.neverlanctf.com/ZD.php -d 'riddle=ken'
<!DOCTYPE html>
<html lang="en" itemscope itemtype="http://schema.org/WebPage">
    <head>
        <meta name="robots" content="noindex, nofollow">
        <meta name="Author" content="Neo">
    </head>
    <body>
        <style>body{text-align:center;}</style>
        <h1>Congratulations, You Solved It</h1>
        <p><!--Throughout this event you may have noticed (or didn't notice) that we occationally personified the word ken to symbolize the strive for education.<br/>--> He[Ken] is used as a representation of the constant growth of mental perception. His friendship is your search for knowledge and his death your final attempt to reach new boundries.<br/> To never let Ken die you must never stop trying to learn, never give up on knowledge.<br/> Finding Ken is to find the joy in education. Learn to love learning and your ken will never stop growing.<br/> This event was created to help those who have not yet found their ken realize how important knowledge is.<br/>Even if computer programming or scripting is not your thing, I would hope you continue your search to find something you love to learn about.</p>
        <br/>
        <br/>
        <br/>
        <p>Ken, as described by dictionary.com, is "knowledge, understanding, or cognizance; mental perception"</p>
        <h5>ok, here's you flag{dat_ken_though}</h5>
        <!--<h5>For more fun, try the challenges on my cohorts' pages, you might even learn some more about them</h5>-->
    </body>
</html>
flag{dat_ken_though}

Purvesta's Recon (Recon 200)

rap songsのことが書いてある。SoundCloudを調べてみると、https://soundcloud.com/purvesta がある。
さらにhttps://soundcloud.com/purvesta/the_gettysburg_address_rapを見てみると、Base64文字列らしきものがある。
f:id:satou-y:20180304194818p:plain

$ echo Wm14aFozdE5NWGhVUUhCbFh6RnVYM1JvTTE5dFFHc3hibWMvZlE9PQ== | base64 -d
ZmxhZ3tNMXhUQHBlXzFuX3RoM19tQGsxbmc/fQ==
$ echo ZmxhZ3tNMXhUQHBlXzFuX3RoM19tQGsxbmc/fQ== | base64 -d
flag{M1xT@pe_1n_th3_m@k1ng?}
flag{M1xT@pe_1n_th3_m@k1ng?}

Zesty's challenge (Recon 200)

https://live.neverlanctf.com/robots.txtにアクセスする。

user-agent: *
disallow: zestyschallenge.php

https://live.neverlanctf.com/zestyschallenge.phpにアクセスする。それからそのページにあるリンクhttps://www.youtube.com/watch?v=dhebl9oD5Lcにアクセスしてみる。flagで検索すると、フラグが見つかった。
f:id:satou-y:20180304195316p:plain

flag{10684524746ba936b43a82d84385dcf5}

Story Time! (Cryptography 200)

一文字ずつ半角英字に置き換える。quipqiupで調整しながら、復号する。

CAPTAI KIDD USED THE GOLD BUG CIPHER TO HIDE THE LOCATIO OF HIS TREASURE I A STORY WRITTE BY EDGAR ALLA POE I FLAG IS PIRATESANDDAGGERS

なぜか英文としてはNが抜けている箇所があるが、フラグはわかった。

PIRATESANDDAGGERS

Picture Words (Cryptography 200)

イメージの換字式暗号。各イメージをアルファベットに置き換える。

ABCDEFGHID
JKLFMGCNEO
IJPQQBCLFF
QEIDEQCPOF
RSTEQBPUVI
DJPQQBCGCP
HCERGPJIEK
IUQTLCEAFL
QBPQBFTEPD
OAFLOE

一列にしてquipqiupにかける。復号結果は以下の通り。

WHEN SOLVING PROBLEMS DIG AT THE ROOTS INSTEAD OF JUST HACKING AT THE LEAVES FLAG IS PICTURES WORTH A THOUSAND WORDS
PICTURESWORTHATHOUSANDWORDS

How much can you throw on a Caesar salad? (Cryptography 300)

steghideによる秘匿を疑い、適当にパスフレーズを入れる。パスフレーズはneverlanctf。

$ steghide extract -sf O_SO_Curious.jpeg -p neverlanctf
wrote extracted data to "WhyS0CuR1o5.txt".

抽出したファイルのデータをBase64デコードする。次に2進表記のコードになるので、ASCIIコードとして読む。Ceaser暗号とみて、7シフトする。

import string

def rot7(s):
    str = ''
    for i in range(len(s)):
        if s[i] not in string.letters:
            str += s[i]
        else:
            code = ord(s[i]) - 7
            if s[i] in string.uppercase:
                if code < ord('A'):
                    code += 26
            else:
                if code < ord('a'):
                    code += 26
            str += chr(code)
    return str

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

code_str = data.decode('base64')
codes = code_str.split(' ')

dec = ''
for code in codes:
    dec += chr(int(code, 2))

flag = rot7(dec)
print flag

この結果、以下のメッセージになる。

Experience is the Teacher of all things

これを言ったのはJulius Caesar。どうやらこの名前をラテン語表記にして答える必要があるらしい。
https://en.wikipedia.org/wiki/Gaius_Julius_Caesar_(name)で調べる。

flag{GAIUS_JULIUS_CAESAR}×
flag{GAIVS_IVLIVS_CAESAR}×
flag{GAIUS_IULIUS_CAESAR}×

なかなかフラグが通らない。
「Julius Caesar's name」の節の最後の段落にこう書いてある。

The name of the dictator Julius Caesar—Latin script: CAIVS IVLIVS CAESAR—was often extended by the official filiation Gai filius ("son of Gaius"), rendered as Gaius Iulius Gai filius Caesar.
flag{CAIVS_IVLIVS_CAESAR}

That's a big file (Cryptography 300)

巨大なBase64文字列。ひたすらデコードする。

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

i = 1
while True:
    try:
        print 'Round %d' % i
        data = data.decode('base64')
    except:
        break
    i += 1

print data

59回デコードすると、フラグが得られた。

flag{persistant_are_we?}