IceCTF 2016

4 minute read

For IceCTF 2016 write-ups in English version, you can check out CTF Time.

IceCTF 是冰島 (Iceland) 舉辦的 CTF,比賽採線上舉辦,以 Jeopardy 解題的方式進行。與其他 CTF 不同的是,這一場教育的性質比較重,除了比賽時間長達 14 天之外,名次的採計也僅限冰島國內的隊伍,所以在 CTF Time 上是沒有 rating weight 的。

因為舉辦時間長達 14 天,所以題目非常多,難度從簡單的替換式加密 (substitution cipher),到非常困難的 reverse engineering 題目都有,非常適合剛踏入 CTF 競賽的新手以及身體百戰的老手。

如果 AIS 3 2016 pre-exam 不算的話,這應該是我人生的的第一場 CTF 吧!由於和實驗室的強者學長們一起比賽,所以我們成績還不錯,最後拿下第 16 名。

以下是一些有趣的題目跟大家分享:

Alien Message

Glitch · 753 solves / 1660 · Cryptography · 40 pt

We found this suspicous image online and it looked like it had been planted there by an alien life form. Can you see if you can figure out what they’re trying to tell us?

因為 flag 格式是 IceCTF{.....},從那個 c 看的出來它大小寫只是改變大小,所以是對英文字與數字做 substitution cipher,但是訊息太少了,很難透過頻率分析去判斷字母,更何況這段 flag 還可能包含 hexspeak(https://en.wikipedia.org/wiki/Hexspeak)。

然而看著解題的人數非常多,所以學長(這題是學長解的)就 Google 一下 Alien message,果不其然找到對應的 table,順利解開。

解題的時候要看一下有多少人解開了這題,如果很多人代表這題沒這麼複雜,應該往簡單的方向想。

finalC · 542 solves / 1660 · Misc · 40 pt

There’s something about this domain… search.icec.tf, I don’t see anything, but maybe its all about the conTEXT.

這題點進去網址什麼都沒有,DNS 根本查不到,認真查了一下相關紀錄,也沒有 CNAME, A, MX 紀錄。在學姐的幫助下,DNS 竟然有一種 record 叫做 TXT record,裡面可以放一些關於你 domain 的資料,而這題就是把 flag 藏在這裡。

Kitty

finalC · 568 solves / 1660· Web · 70 pt

They managed to secure their website this time and moved the hashing to the server :(. We managed to leak this hash of the admin’s password though! c7e83c01ed3ef54812673569b2d79c4e1f6554ffeb27706e98c067de9ab12d1a. Can you get the flag? kitty.vuln.icec.tf

這題其實很基本,但對我的衝擊不小XD 題目給了經 sha256 hash 之後的密文,而思路是這樣,先把這段 hash 拿去 sha256 decrypt 看看,結果成功!就得到明文 Vo83* 了。

所以,密碼不要設定的太簡單(例如簡單的8位數字),會很容易被反查找出明文的!

l33tcrypt

finalC · 182 solves / 1660· Cryptography · 90 pt

l33tcrypt is a new and fresh encryption service. For added security it pads all information with the flag! Can you get it? nc l33tcrypt.vuln.icec.tf 6001 server.py

注意他是用 ECB mode 去加密,許多 AES cipher 的預設加密模式是 ECB,這點就是主要下手的地方。

因為它會把 flag 直接加在輸入字串的後面,又知道他的 block size 是 16 bytes,我們就可以利用 padding 的方式做攻擊,一個字一個字猜 flag ! 例如以下字串可以用來確定 flag 開頭是否為 IceCTF: (這裡先不考慮題目所述的開頭 magic word)

輸入 0123456789IceCTF0123456789

AES ECB mode, block size is 16-byte:

0123456789IceCTF -> ciphertext
0123456789IceCTF -> ciphertext
....

我們可以藉由判斷那兩塊 ciphertext 是否相同,就知道 flag 的字有沒有猜對!同理,因為它會做 padding,我們也可以判斷密文的有幾個 byte,猜出 flag 的長度。

這題的 python script 我有寫,但是實在太醜,不具可讀性,所以就不放了。

Sand Castles on the Beach

Glitch · 42 solves / 1660· Cryptography · 140 pt

We found this very mysterious image, it doesn’t look complete and there seems to be something hidden on it… does this mean anything to you? sandcastle.png. This flag is not in the standard flag format. The flag contains digits and no special characters, convert the message to lowercase and then add IceCTF{message} to it. 10331c4d

首先我們用 Google 以圖搜尋找出了原書,再來透過分析這張 png ,發現藏有奇怪的 comment 如下:

58-7-9
210-13-2
67-3-16
85-17-15
305-18-4
83-12-18
75-8-15
47-4-2
83-20-11
208-6-6
85-11-6
75-7-3
106-9-14

因為跟書有關,就覺得應該是 book cipher,這三個數字分別代表 (i-th page, j-th line, k-th word),然後取每個字的開頭組合起來。

乍聽之下很簡單,但看看解的人數就知道大有問題……首先這本書如果沒有實體書,只能網路上搜尋電子書,結果有兩個版本,且頁數不同,於是主辦方才另行加了某本電子書 md5 的開頭到題目敘述裡。

這樣還沒結束,更慘的是因為電子書排版有些問題,在計算行數、字數 (j-th line, k-th word) 時,會有模稜兩可的情況,例如某一行、某個數字到底要算幾個之類的,所以就只好一個一個盲試(這題的 flag 意義不是很充足)。

歷經苦戰,flag 字串是 n0obzr3adbo0x,還有 hexspeak 呢。

Root of All Evil

Glitch · 25 solves / 1660· Forensics · 150 pt

Oh no! Dr.Evil managed to get into one of ours servers, we don’t know what he did. I took an image of the file system, can you take a look and see what he left behind? Note to Foreign teams: Please make a ticket when you solve Root of All Evil and make sure you include proof.

這題的檔案不是很重要,我就不放了,總之解開來是一個 Unix file system 的快照:

root
├── bin
│   ├── cat
│   ├── cp
│   ├── date
│   ├── dir
│   ├── du
│   ├── evilcat
│   ├── fdisk
│   ├── file
│   ├── groups
│   ├── id
│   ├── kill
│   ├── less
│   ├── ls
│   ├── mail
│   ├── man
│   ├── pwd
│   ├── whoami
│   └── zip
├── dev
├── etc
├── home
│   ├── evil
│   │   └── .bash_history
│   └── glitch
├── lib
├── mnt
├── proc
├── root
├── run
├── srv
├── sys
├── tmp
├── usr
└── var

.bash_history 裡面有 bash fork bomb,我還不小心執行了一下,然後電腦就掛了…….

唯一的重點在 evilcat,它比一般的 cat 多了一行用 base64 encode 的字串,解出來是一個 wave 音訊檔案。 這個檔案裡面是手機 DTMF 撥號的聲音,透過 DTMF decoder 的幫助(因為線上版 decode 失敗),得到一串數字

64 12673822 *216998

透過題目的提示,他說外國隊伍要解的話要送 ticket (類似提問單) 給主辦方,就猜測是電話號碼,但根據國碼分析,這是紐西蘭的號碼…….然後就在這裡卡住了。

直到比賽結束,我才發現,原本題目的 evilcat 有更新,我不信邪還跟一位網友比對兩次 evilcatmd5 值,結果不同……,新的檔案 decode 出來是

6412673822*2192146998

這比較看得出來對稱性,答案是 GPS 座標,外國隊伍之所以不能解是因為走不到那個座標點,它在冰島,送 ticket 後官方就會給 flag。

總之這題就是這樣,題目有可能會更新,記得每次卡住後,要確認一下檔案跟上次有沒有一樣,不然就會跟我一樣慘。

註:出題者 Glitch 表示題目上傳不久它馬上就更新了,我能下載到舊的也是不簡單

Back At It Again!

finalC · 8 solves / 1660 · Cryptography · 200 pt

Steve’s back at it again with them keys! Can you get it this time? He cleaned up his broken keys on GitHub from last year, but didn’t replace them. He must have shared them somehow with a friend, who gave him an account at shell.icec.tf. Can you get access?

那個 shell.icec.tf 其實就是官方給的 web shell 界面。

首先先上 shell 逛逛,看到有一名使用者叫 steve ,跟 GitHub 上 ID 相同,所以試著登入看看,結果是 Permission denied (public key),想必是要在 GitHub 上找到 steve 的 public key,接著就卡在這直到比賽結束。

它到底藏在哪裡呢?我翻了 GitHub get public key API,他的 GitHub 並沒有放置 public key,題目中也有提到 steve 已經 “cleaned up his broken key” 了。

在比賽結束後的 IRC channel,一問之下發現藏在他的 Gist public post 裡面,只有一份就是他的 ssh public key,能找到這的人真是厲害,在我看來除了通靈,就是要把 GitHub API 能試的都試試看,盡可能倒出他的公開資訊,然後就有機會發現他的 Gist 上有東西。

下一步,題目提到他是 “broken key”,想必應該是可以分解,不過我沒有嘗試也沒有做後續確認,不能斷言是不是這樣解。若能算出他的 private key,就可以登入他的 shell 拿 flag 了吧?

後記

對於初入 CTF 界的我,這場比賽真的讓我學到了不少東西,一些基本的 web, binary 技巧等等,還有得到許多 CTF 常用 tools XD

雖然中間被主辦方雷了一些題目,但他們時常守在 IRC channel 上接受大家的提問,並認真負責的回答,這點值得尊敬,要記得這場比賽可是長達 2 周啊!特別感謝 Glitch,他應該是我問最多問題的人,他的題目也讓我卡最久。Thank you, Glitch!

這場的另一個重要意義,大概是讓我對資安更有興趣了吧!希望未來在臺灣,我們也能辦一場教育性質的 CTF 供大家參加,一起推廣資安領域。