Kaspersky Industrial CTF Quals 2017 Writeup

この大会は2017/10/6 23:00(JST)~2017/10/8 23:00(JST)に開催されました。
今回もチームで参戦。結果は1900点で696チーム中39位でした。
自分で解けた問題をWriteupとして書いておきます。

Security Home Cameras (Crypto 300)

16バイトごとのXORになっていると推定して、復号する。

with open('secret_encrypted.png', 'rb') as f:
    data = f.read()

PNG_HEAD = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
    0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52]

key = []
for i in range(len(PNG_HEAD)):
    key.append(ord(data[i]) ^ PNG_HEAD[i])

flag = ''
for i in range(len(data)):
    code = ord(data[i]) ^ key[i%len(key)]
    flag += chr(code)

with open('flag.png', 'wb') as f:
    f.write(flag)

f:id:satou-y:20171011220336p:plain

KLCTF{it_was_just_atbash_encryption}