2016-03-13 01:00 - 2016-03-14 05:00 (JST)に開催されたSunshine CTF 2016のwrite-upです。

なお、今回は以下のメンバー編成で参加しました。

  • mayth (土曜日を寝て潰す担当)
  • op (たまに現れていくらかの助言と違法語句を残して去って行く担当)

ESTはクソ。

Forensics 50: Butterfly Effect

butterfly.pngが与えられる。

ImgSteganoにファイルを読み込ませて"Image > Enhanced LSB"とするとフラグが現れた。

sun{RE4DY_THE_4CID_M4GNET!}

Exploitation 50: alligatorsim95

Don’t try to automate adding X eggs at a time

legends circulate in florida of an alligator that had laid millions of eggs. use this simulator to try to achieve the same greatness

※プログラムは与えられない。

指定されたIPアドレス/ポートにncで接続すると、アリゲーターのAAと共に文章が流れてくる。

-> u r... AN ALLIGATOR!!
.. simulating alligator lifecycle ..
.. simulating alligator throwing physics..
-> you got 1337 eggz in ur nest, how many you gonna lay alligator??

この後に整数値を入力すると、その数だけ卵の数(上記の通り初期値1337)が増える。ただし上限は50。それを超えると拒否され再度同様のプロンプトが現れる。接続を切られるのは以下の通り。

  • echoとかで入力を機械的に流し込もうとしたとき (“Don’t try to automate adding X eggs at a time”)
  • 0や数字として解釈出来ない数を与えたとき
  • 一定時間が経過したとき

この条件下で卵の数を大きくする問題。

色々入力を試すと、0はダメだが負数を受け付けること、また、負数であれば絶対値がいくら大きくてもよいことがわかった。 これを利用すると整数オーバーフローを引き起こすことができる。そうすると卵の数は非常に大きな値となり、フラグを得ることができる。

-> u r... AN ALLIGATOR!!
.. simulating alligator lifecycle ..
.. simulating alligator throwing physics..
-> you got 1337 eggz in ur nest, how many you gonna lay alligator?? -2147483647
~~ producing eggz ~~
.. simulating alligator lifecycle ..
.. simulating alligator throwing physics..
-> you got -2147482310 eggz in ur nest, how many you gonna lay alligator?? -10
~~ producing eggz ~~
.. simulating alligator lifecycle ..
.. simulating alligator throwing physics..
-> you got -2147482320 eggz in ur nest, how many you gonna lay alligator?? -40000
~~ producing eggz ~~
-> dang 2147444976 is a lotta eggs
-> as a god among gators here is ur crown:
sun{int_0verflow_i5_a_g0od_st4rt}

sun{int_0verflow_i5_a_g0od_st4rt}

Exploitation 55: Dance

Some prefer the stanky leg, others prefer the dab, but what dance moves do you have?

IPアドレスとポート番号が指定される。当初プログラムは与えられなかったが、後にフラグ部分を潰したバイナリが配布された。

サーバーに接続すると以下のような文字が流れてくる。

welcome to the pro club. you just paid a door fee and have no respect. earn ur cred on the dancefloor!
give us ur sick dance moves like so:
whip,naenae,whip,whip,naenae<ENTER>

whipnaenaeをカンマ区切りで並べて送信すると

do the naenae
(\)
  \(:O)
   /||\_
_/¯    ¯\_

こんな感じで対応したアクションと愉快なAAが流れてくる。

当初何をさせたいのかさっぱりわからなかったが、バイナリが配布されたのでそれを読んだ。

その結果、こちらからの入力を受け取るバッファについて、memsetで80bytesをNULLで初期化しているにも関わらず、fgetsで最大89bytesまで読み込むようになっていることがわかった。また、0で初期化された特定の変数の値が書き換わっているときにフラグが表示されるようになっていることがわかった。

入力の読み込みはだいたい次のようなロジックになっている。

while (strlen(buf) > 0) {
  if (*buf == 'n') {
    buf += 7;
    donaenae();
  } else if (*buf == 'w') {
    buf += 5;
    dowhip();
  }
}
check_flag();

先頭しか見てないっぽいので適当に80文字の"n"を送り付けたところ、フラグが得られた。

% ruby -e 'puts "n" * 0x50' | nc ****
welcome to the pro club. you just paid a door fee and have no respect. earn ur cred on the dancefloor!
give us ur sick dance moves like so:
whip,naenae,whip,whip,naenae<ENTER>
do the naenae
(\)
  \(:O)
   /||\_
_/¯    ¯\_
(snip)
do the naenae
(\)
  \(:O)
   /||\_
_/¯    ¯\_
girl u can dance w the best of em. the pw to our vip lounge is: sun{d4nc3_0n_th3_s7ack}

cool dance! come again!

sun{d4nc3_0n_th3_s7ack}

Misc 50: Find Floridaman

In other news… Floridaman did what with an alligator?

Remember, this has the normal flag format.

Hint: You need only look at comments from Florida-based news websites.

Hint: Gator went threw a window!

Hint: “Flori-duh”

NOTE: Flag was posted before the 12th

フロリダマンを探すマン。

問題オープン当初は最初の2文だけだったのが、誰も解かないからか次々にヒントが追加されて結局ヒントが3つになった。

ヒントが3つになってから、そのヒントを元に"Flori-duh Alligator"で探してみると、次の記事が見つかった。

Wendy’s alligator-thrower is only fulfilling his Flori-duh destiny

この記事のReader Commentsにフラグがある。

Summerc137 3 days ago May the Lord have mercy on this man. That poor woman in the drivethrough! sun{1s_th1s_even_real_l1fe?}

sun{1s_th1s_even_real_l1fe?}

ちなみにこの事件、なんでも1mちょっとあるアリゲーターをWendy’sのドライブスルーの窓から投げ込んだのだそうな。さすがアメリカ。