iHack 2020 Writeup

この大会は2020/6/21 6:30(JST)~2020/6/21 15:00(JST)に開催されました。
今回もチームで参戦。結果は290点で78チーム中54位でした。
自分で解けた問題をWriteupとして書いておきます。

Introduction to pwntools reloaded (pwning 100)

$ nc pwn64.ctf.ihack.computer 1234
OCTAL VALUE: 115 110 150 104 122 125 132 102 116 147 075 075 
What is the good number?

実質プログラムの問題。8進数をデコードし、ASCIIコードとして文字にする。さらにbase64デコードすると、16進数文字列になるので、10進数に変換して答える。

from pwn import *

p = remote('pwn64.ctf.ihack.computer', 1234)

data = p.recvline().rstrip()
print data

codes = data.split(': ')[1].split(' ')
print codes
msg = ''.join([chr(int(code, 8)) for code in codes])
msg = msg.decode('base64')
msg = str(int(msg, 16))

data = p.recvline().rstrip()
print data

print msg
p.sendline(msg)
data = p.recvline().rstrip()
print data
data = p.recvline().rstrip()
print data
data = p.recvline().rstrip()
print data

実行結果は以下の通り。

[+] Opening connection to pwn64.ctf.ihack.computer on port 1234: Done
OCTAL VALUE: 115 110 150 105 116 104 144 107 122 147 075 075
['115', '110', '150', '105', '116', '104', '144', '107', '122', '147', '075', '075']
What is the good number?
870399
Good answer!
Weel done! This is your flag:
FLAG_2JYJZH0gn2pAa4JW2xQC
[*] Closed connection to pwn64.ctf.ihack.computer port 1234
FLAG_2JYJZH0gn2pAa4JW2xQC

The Chronos Encrypter (Malware The Flag 90)

mtf{から始まることを前提に鍵を出してみる。

with open('flag.txt', 'rb') as f:
    ct = f.read()

head_flag = 'mtf{'

key = ''
for i in range(len(head_flag)):
    code = ord(ct[i]) ^ ord(head_flag[i])
    key += chr(code)

print key

実行すると、以下のようになる。

1590

時刻のことも問題に記載されていたので、UNIXTIMEが鍵になっていると推測できる。

29 May 2020 12:23:13 PM GMT
⇒ UNIXTIME = 1590754993

これをXOR鍵として復号する。

with open('flag.txt', 'rb') as f:
    ct = f.read()

key = '1590754993'

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

print flag
mtf{chr0n05_n07_cr0nu5}