この大会は2021/10/9 9:00(JST)~2021/10/11 9:00(JST)に開催されました。
今回もチームで参戦。結果は900点で2247チーム中115位でした。
自分で解けた問題をWriteupとして書いておきます。
Too much sharing (CRYPTO 100)
RSA暗号と思われる。c, n, phiがわかっている。eの値は以下のようになっている。
e = int(str(p)[:32]) + (str(q)[:32]) 素数になるまで1プラスする。
phiとn、p、qの関係は以下のようになる。
phi = (p - 1) * (q - 1) = n - (p + q) + 1 p + q = n - phi + 1
ここからは二次方程式を解けば、pとqはわかる。p, qがわかれば、eも算出できる。あとは通常通り復号すればよい。
#!/usr/bin/python3 from Crypto.Util.number import * from sympy import * with open('crypto100-readme.txt', 'r') as f: Claire = int(f.readline().rstrip().split(' ')[-1]) Nathan = int(f.readline().rstrip().split(' ')[-1]) Philip = int(f.readline().rstrip().split(' ')[-1]) p_q = Nathan - Philip + 1 p = symbols('p') eq = Eq(p * (p_q - p), Nathan) ps = solve(eq) Portia = ps[0] Quincy = ps[1] assert(Portia * Quincy == Nathan) Edgard = int(str(Portia)[0:32])+int(str(Quincy)[0:32]) while not isPrime(Edgard): Edgard += 1 d = inverse(Edgard, Philip) m = pow(Claire, d, Nathan) flag = long_to_bytes(m).decode() print(flag)
{FLG:Cha0s_h1d3s_b3h1nd_th3_m3n4c1ng_f4c3_0f_0rd3r!}
What an Enigma! (CRYPTO 200)
エニグマ暗号で、M4 Sharkであるようだ。まず順にhelpを解き、パラメータを取得する。
first helpでは、モールス信号をデコードする。
GURCBFVGVBAFNAQEVATFLBHARRQNERS21Y18G16T11
さらにROT13をかける。
THEPOSITIONSANDRINGSYOUNEEDAREF21L18T16G11 →THE POSITIONS AND RINGS YOU NEED ARE F21 L18 T16 G11
second helpでは、表からワードを消し込む。
NH CW MK PO ZS QB FU TR
他のパラメータはブルートフォースで復号する。
from enigma.machine import EnigmaMachine import itertools ciphertext = 'utogaaxgeonuvkegegddajktikdtvepnkolokj' rotors = ['Beta', 'Gamma', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'] reflectors = ['B', 'C', 'B-Thin', 'C-Thin'] found = False for rotor in itertools.product(rotors, repeat=4): for reflector in reflectors: machine = EnigmaMachine.from_key_sheet( rotors = rotor, reflector = reflector, ring_settings = (20, 17, 15, 10), plugboard_settings='NH CW MK PO ZS QB FU TR') machine.set_display('FLTG') plaintext = machine.process_text(ciphertext.upper()) flag = plaintext.lower() if flag.startswith('flg'): found = True print flag break if found: break
実行結果は以下の通り。
flgthematrixhasyoufollowthewhiterabbit
{FLG:thematrixhasyoufollowthewhiterabbit}