HackIM 2016 Writeup

この大会は2016/1/30 1:30(JST)~2016/2/1 1:30(JST)に開催されました。
今回も個人で参戦。結果は1400点で320位でした。
参加チームは1836チームいたようですので、
あまり時間をかけなかった割には解けた方かなと思います。。
解けた問題4問をWriteupとして書いておきます。

Crypto Question 1 (Crypto 500pts)

f:id:satou-y:20160201200523p:plain
添付ファイルを解凍すると Heart_clear.txt と Heart_crypt.txt と Mind_crypt.txtの3ファイルが入っている。どうやらHeart_clear.txt の内容を暗号化すると、Heart_crypt.txt の内容になっているので、同じアルゴリズムで暗号化しているMind_crypt.txt の内容を復号する問題ということらしい。

平文と暗号文を比較してみると、文字の長さは変わらなく、同じ文字でも異なる位置だと違う文字になっている。さらに問題文の中に「The biggiest question is seX OR success?」という文面があるので、XORを指していると思われる。

鍵を取り出すために、プログラムを作成する。

f_clear = open('Heart_clear.txt', 'rb')
data_clear = f_clear.read()
f_clear.close()

f_crypt = open('Heart_crypt.txt', 'rb')
data_crypt = f_crypt.read()
f_crypt.close()

key = ''
for i in range(len(data_clear)):
    code = ord(data_clear[i:i+1]) ^ ord(data_crypt[i:i+1])
    key += chr(code)

f_key = open('key.txt', 'wb')
f_key.write(key)
f_key.close()

これで鍵が「Its right there what you are looking for.[0x0a]」であることがわかるので、この鍵で問題の暗号文を復号する。

key = 'Its right there what you are looking for.'
lf = 0x0a
key_len = len(key) + 1

f_mcrypt = open('Mind_crypt.txt', 'rb')
data_mcrypt = f_mcrypt.read()
f_mcrypt.close()

dec = ''
for i in range(len(data_mcrypt)):
    key_index = i % key_len
    if key_index == key_len - 1:
        key_code = lf
    else:
        key_code = ord(key[key_index:key_index+1])
    code = ord(data_mcrypt[i:i+1]) ^ key_code
    dec += chr(code)

print dec

復号の結果、https://play.google.com/store/apps/collection/promotion_3001629_watch_live_games?hl=en というURLになる。このURLにあるページのタイトルがフラグであった。
f:id:satou-y:20160201202949p:plain

Never Miss a Game

Crypto Question 2 (Crypto 400pts)

f:id:satou-y:20160201203629p:plain
添付ファイルの暗号はすべて表示可能な文字なので、XORは考えにくい。問題文の中に「The Operation was as smooth as CAESAR had Conquested Gaul」という文面があることからシーザー暗号であることが予想できる。
シーザー暗号解読機サイトで単語毎に確認していくと鍵は16である可能性が高そうなことがわかる。このことから復号するプログラムを作成、実行する。

import string
al = list(string.ascii_lowercase)

fe = open('The_extract.txt', 'r')
e_data = list(fe.read().lower())
fe.close()

dec = ''
for i in range(len(e_data)):
    if e_data[i].isalpha():
        i_enc = al.index(e_data[i])
        i_dec = (i_enc + 16) % 26
        dec += al[i_dec]
    else:
        dec += e_data[i]

fd = open('decode.txt', 'w')
fd.write(dec)
fd.close()

復号すると、このような文章。

dr. sarah tu races against time to block the most dangerous internet malware ever created, a botnet called qualnto. while sarah is closed off in her computer lab, her sister, hanna, is brutally attacked and left in a coma. as sarah reels with guilt over not being there for her sister, a web of deception closes in, threatening her and everyone she loves.


hanna’s condition is misleading. in her coma state, she is able to build a psychic bridge with fbi special agent jason mcneil. her cryptic messages plague jason to keep sarah safe.


tough and street-smart jason mcneil doesn’t believe in visions or telepathic messages, and he fights the voice inside his head. his first impression of dr. sarah tu is another stiletto wearing ice-dragon on the war path―until he witnesses her facade crumble after seeing her sister’s bloody, tortured body. jason’s protective instinct kicks in. he falls for sarah―hard.


when an extremenly dangerous arms dealer and cybercriminal discovers that sarah blocked his botnet, he kidnps sarah. placed in an impossible position, will she destroy the botnet to protect national security or release it to save the man she loves

調べると「In the Shadow of Greed」という本のものらしく、このタイトルがフラグであった。

In the Shadow of Greed

Crypto Question 4 (Crypto 200pts)

f:id:satou-y:20160201205827p:plain
添付ファイルの中はmd5の値が8個並んでいる。それぞれ元の文字をGoogleなどで調べる。

d80517c8069d7702d8fdd89b64b4ed3b:Carrie
088aed904b5a278342bba6ff55d0b3a8:Grease
56cdd7e9e3cef1974f4075c03a80332d:Perfect
0a6de9d8668281593bbd349ef75c1f49:Shout
972e73b7a882d0802a4e3a16946a2f94:Basic
1cc84619677de81ee6e44149845270a3:Actor
b95086a92ffcac73f9c828876a8366f0:Aircraft
b068931cc450442b63f5b3d276ea4297:name

この単語をヒントに調べると、John Travoltaという俳優が「Carrie」「Grease」「Perfect」「Shout」の映画に出演しているらしいということがわかる。所有しているAircraftの名前は「Jett Clipper Ella」であることもわかり、これがフラグであった。

Jett Clipper Ella

Trivia Question 3 (Trivia 300pts)

f:id:satou-y:20160201210936p:plain
問題には「Bill Gates loves Cipher.」とだけ書かれ、次の暗号の画像が添付されている。

f:id:satou-y:20160201211046p:plain
アルファベットと対応しているのだろうということは想像できたが、どう対応すべきか調べるのに時間がかかった。結局Googleの画像検索からBill's symbol substitution cipherのページにたどり着き、1つ1つアルファベットにしてフラグをゲットすることができた。
f:id:satou-y:20160201211728p:plain

AGLISURAKSHAKIVASTU