EvlzCTF Writeup

この大会は2018/2/10 0:30(JST)~2018/2/11 0:30(JST)に開催されました。
今回もチームで参戦。結果は1475点で241チーム中6位でした。
自分で解けた問題をWriteupとして書いておきます。

Sorry for this (Miscellaneous 75)

問題は動画になっている。ffmpegで静止画に分解してみる。

>ffmpeg -i tipsy.mp4 -f image2 -vf fps=fps=1 div\tipsy_%05d.jpg

フラグが埋め込まれている画像が抽出できた。
f:id:satou-y:20180212221518j:plain

evlz{my-very_trip_was_dad_with_first}ctf

Typical (Crypto 75)

$ nc 35.200.197.38 8003
Your Ciphertext is:2b111136050a201a033f2c24 Your key is:4a525455
Enter plaintext in hex:

XORで復号すればよさそう。

import socket
import re

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('35.205.196.143', 8003))

round = 1
while True:
    print 'Round %d' % round
    data = s.recv(256)
    print data
    if 'Thanks for playing' in data:
        break

    pattern = 'Your Ciphertext is:(.+) Your key is:(.+)'
    m = re.match(pattern, data)
    cipher = m.group(1)
    key = m.group(2)
    plain = ''
    for i in range(0, len(cipher), 2):
        code = int(cipher[i:i+2], 16) ^ int(key[i%len(key):i%len(key)+2], 16)
        plain += '%x' % code
    print plain
    print plain.decode('hex')
    s.sendall(plain + '\n')
    round += 1

最後までいってもフラグが表示されないので、送信する平文をhexデコードして表示してみる。途中でフラグが表示されていた。

       :
Round 5
Your Ciphertext is:2e0e0e1f2c343413271f2f27110a3a212f1a21082e2710043920371f39193f1e Your key is:4b78626557445872447a
Enter plaintext in hex:
65766c7a7b706c616365645f736f6d6577686572655f72616e646f6d7d637466
evlz{placed_somewhere_random}ctf
       :
evlz{placed_somewhere_random}ctf

Primeates (Crypto 200)

$ nc 35.200.197.38 8005
N is: 1414105071933482316700542439837927693320680478605460052939094829508938028079161646629323226988356049045316777515223180430106838398770488537890345507827495508103790674199471015282663027025736696273099161565154972925237786001169295774985507681276675232117968877551566249431664097185905356884899854698377908208111958407402412421368604606422248087172330445861763290357089580920253721692338495985837659109342710795237403676248263107315674673015668263081380091946949603
e is: 3
Cipher text is: 378298893916598086874607404131390876390122525545713488720877944575185623279732971227842503543642027704686114550783317830373635343922547497016866577366754346946921713513140776458160982993092663936827


1.Encryption
2.Decryption
3.Enter Password
>>>

何回実行しても、Nは変わるが、Cipher textは変わらない。Cipher textの3乗根をPasswordに指定する。3乗根の計算は以下のコードで算出する。

import gmpy

e = 3
c = 378298893916598086874607404131390876390122525545713488720877944575185623279732971227842503543642027704686114550783317830373635343922547497016866577366754346946921713513140776458160982993092663936827

m = gmpy.root(c, e)[0]
print m
$ nc 35.200.197.38 8005
N is: 1556966064738208400509493889892686349363489102225804549807540113183147949410123615020634270850732169222047692200989559328466901758582142413451080329406518012869438788032010715643691401333758281416262070700828076273991929765138786003451444813134304298899337023715344919957484024244711896668243088204509206541173746225660925052442509687915349585308402279785205845661319001248671557084729608451727086671989197567391148915766568036635887854580846722040783466634494953
e is: 3
Cipher text is: 378298893916598086874607404131390876390122525545713488720877944575185623279732971227842503543642027704686114550783317830373635343922547497016866577366754346946921713513140776458160982993092663936827


1.Encryption
2.Decryption
3.Enter Password
>>>3
Enter the password 723233204932732303232804824329562012733423232323723208322321218403
evlz{my_very_oracle_attack}ctf

Cipher textの3乗根を指定すると、フラグが表示された。

evlz{my_very_oracle_attack}ctf