Sunshine CTF 2021 Writeup

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

Liveness Check (Misc 1)

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

sun{flag_to_check_if_you_are_alive}

Discooooooooord (Misc 2)

Discordに入り、#announcementsチャネルのトピックを見ると、フラグが書いてあった。

sun{dont_u_love_work_from_home}

Mr Robot (Crypto 10)

問題文中のbase64文字列らものを結合して、base64デコードする。

$ echo c3Vue2hlbGxvX3dvcmxkfQ== | base64 -d
sun{hello_world}
sun{hello_world}

MultipleExponents (Crypto 100)

同じn、異なる2つのeでそれぞれ暗号がわかっているので、Common Modules Attackで復号する。

from Crypto.Util.number import *
import gmpy

def commom_modules_attack(c1, c2, e1, e2, n):
    gcd, s1, s2 = gmpy.gcdext(e1, e2)
    if s1 < 0:
        s1 = -s1
        c1 = gmpy.invert(c1, n)
    elif s2 < 0:
        s2 = -s2
        c2 = gmpy.invert(c2, n)
 
    v = pow(c1, s1, n)
    w = pow(c2, s2, n)
    x = (v*w) % n
    return x

n = 86683300105327745365439507825347702001838360528840593828044782382505346188827666308497121206572195142485091411381691608302239467720308057846966586611038898446400292056901615985225826651071775239736355509302701234225559345175968513640372874437860580877571155199027883755959442408968543666251138423852242301639
e1 = 11048796690938982746152432997911442334648615616780223415034610235310401058533076125720945559697433984697892923155680783661955179131565701195219010273246901
e2 = 9324711814017970310132549903114153787960184299541815910528651555672096706340659762220635996774790303001176856753572297256560097670723015243180488972016453
c1 = 84855521319828020020448068809384113135703375013574055636013459151984904926013060168559438932572351720988574536405041219757650609586761217385808427001020204262032305874206933548737826840501447182203920238204769775531537454607204301478815830436609423437869412027820433923450056939361510843151320837485348066171
c2 = 54197787252581595971205193568331257218605603041941882795362450109513512664722304194032130716452909927265994263753090021761991044436678485565631063700887091405932490789561882081600940995910094939803525325448032287989826156888870845730794445212288211194966299181587885508098448750830074946100105532032186340554
 
m = commom_modules_attack(c1, c2, e1, e2, n)
flag = long_to_bytes(m)
print(flag)
sun{d0n7_d0_m0r3_th4n_0ne_3xp0n3nt}