SECCON2017 オンライン予選 Writeup

もともとは○uportの脆弱性を報告した話を書く予定でしたが、とある事情から公開できなくなったので、急遽この記事を書いています。(○uportに関しては需要があればいつか書きます。)
まだ大雑把にしか書けていないので、詳細は今週中には更新します。

概要

この記事はKogCoderのSECCON2017オンライン予選のWriteupです。

KogCoderは1000点で232位でした。

回答した問題は以下のとおりです。

Title Genre Point
Run me! Programming 100
putchar music Programming 100
Qubic Rube Programming 300
SHA-1 is dead Crypto 100
Powerful_Shell Binary 300
Thank you for playing! Thank you! 100

Run me!

RunMe.py

import sys
sys.setrecursionlimit(99999)
def f(n):
    return n if n < 2 else f(n-2) + f(n-1)
print "SECCON{" + str(f(11011))[:32] + "}"

@uragouが解きました。
フィボナッチ数列の11011項目の下32桁を求めるプログラムですが、計算量が大きいので計算が終わりません。メモ化再帰等高速なプログラムを実装し実行すれば、答えが出ます。

フィボナッチ数列 - syttruの日記
この記事の出力部分を書き換えて上げれば出来ます。

SECCON{65076140832331717667772761541872}

putchar music

This one line of C program works on Linux Desktop. What is this movie's title?
Please answer the flag as SECCON{MOVIES_TITLE}, replace all alphabets with capital letters, and spaces with underscores.

main(t,i,j){unsigned char p[]="###<f_YM\204g_YM\204g_Y_H #<f_YM\204g_YM\204g_Y_H #+-?[WKAMYJ/7 #+-?[WKgH #+-?[WKAMYJ/7hk\206\203tk\\YJAfkkk";for(i=0;t=1;i=(i+1)%(sizeof(p)-1)){double x=pow(1.05946309435931,p[i]/6+13);for(j=1+p[i]%6;t++%(8192/j);)putchar(t>>5|(int)(t*x));}}

コードを保存しgcc putchar_music.c -lmとするとコンパイルできます。
実行ファイルをaplayにパイプを繋いで実行すると、star warsの曲が流れるので、

SECCON{STAR_WARS}

がフラグです。

KogCoderメンバーはStar Warsを見たことがなかったので、最初はドラクエと勘違いしていました。

Qubic Rube

Please continue to solve Rubic's Cube and read QR code.
http://qubicrube.pwn.seccon.jp:33654/

@uragouRとペアプロで作りました。

恒例のQRコード問題です。

ルービックキューブにQRコードが書かれているので、完成させてQRコードを読み込むと次の問題のURLがわかります。50問解くとフラグが貰えます。

まともにルービックキューブを解いてもいいですが、QRコードの形になるものを考えると、
3つの角になる四角のあるものが3枚、

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

中央になるものが1枚、

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

辺になるものが4枚と、

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

残りの一つの角

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

に区別できるので、総当りしても1面辺り高々

3!×4×4!=576通りなので、総当りでQRコードを読み込めるものを探しました。

50問目のQRコードがこちらです。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

SECCON{Thanks to Denso Wave for inventing the QR code}

SHA-1 is dead

SHA-1 is dead
http://sha1.pwn.seccon.jp/
Upload two files satisfy following conditions:

  1. file1 != file2
  2. SHA1(file1) == SHA1(file2)
  3. SHA256(file1) <> SHA256(file2)
  4. 2017KiB < sizeof(file1) < 2018KiB
  5. 2017KiB < sizeof(file2) < 2018KiB

1KiB = 1024 bytes

@uragouRが解きました

条件を満たすSHA1の衝突するファイルを作成し、アップロードするとフラグが貰えます。
sha1-collisionを使って作成しました。エラーが出ますが、無視して実行するよう変更すると、ファイルが作成できます。画像サイズを調整して指示にあったサイズのファイルを作成すれば終了です。

SECCON{SHA-1_1995-2017?}

Powerful_Shell

Crack me.
powerful_shell.ps1-1fb3af91eafdbebf3b3efa3b84fcc10cfca21ab53db15c98797b500c739b0024

Power Shellのファイルが渡されます。
実行すると、このような画面が表示されます。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

コードを見ると、その場でコードを生成して実行しているようなので、生成したコードを表示してみます。
すると、

$secret=@(440,440,493,440,440,493,440,493,523,493,440,493,440,349)

というコードがあるのがわかります。これが音の周波数なことは自明なので、この順番に音を押していくと次へ進みます。

今度はパスワードを要求されるので、入力する必要があります。
こちらもコードを生成しているので、表示してみます。

${;}=+$();${=}=${;};${+}=++${;};${@}=++${;};${.}=++${;};${[}=++${;};
${]}=++${;};${(}=++${;};${)}=++${;};${&}=++${;};${|}=++${;};
${"}="["+"$(@{})"[${)}]+"$(@{})"["${+}${|}"]+"$(@{})"["${@}${=}"]+"$?"[${+}]+"]";
${;}="".("$(@{})"["${+}${[}"]+"$(@{})"["${+}${(}"]+"$(@{})"[${=}]+"$(@{})"[${[}]+"$?"[${+}]+"$(@{})"[${.}]);
${;}="$(@{})"["${+}${[}"]+"$(@{})"[${[}]+"${;}"["${@}${)}"];"${"}${.}${(}+${"}${(}${|}+${"}${(}${)}+${"}${(}${)}+${"}${)}${|}+${"}${)}${&}+${"}${(}${+}+${"}${&}${@}+${"}${+}${=}${+}+${"}${|}${)}+${"}${+}${=}${=}+${"}${[}${]}+${"}${)}${@}+${"}${+}${+}${+}+${"}${+}${+}${]}+${"}${+}${+}${(}+${"}${.}${@}+${"}${[}${]}+${"}${&}${=}+${"}${+}${+}${[}+${"}${+}${+}${+}+${"}${+}${=}${|}+${"}${+}${+}${@}+${"}${+}${+}${(}+${"}${.}${@}+${"}${.}${|}+${"}${(}${|}+${"}${+}${+}${=}+${"}${+}${+}${(}+${"}${+}${=}${+}+${"}${+}${+}${[}+${"}${.}${@}+${"}${+}${+}${(}+${"}${+}${=}${[}+${"}${+}${=}${+}+${"}${.}${@}+${"}${+}${+}${@}+${"}${|}${)}+${"}${+}${+}${]}+${"}${+}${+}${]}+${"}${+}${+}${|}+${"}${+}${+}${+}+${"}${+}${+}${[}+${"}${+}${=}${=}+${"}${.}${|}+${"}${+}${.}+${"}${+}${=}+${"}${)}${.}+${"}${+}${=}${@}+${"}${[}${=}+${"}${.}${(}+${"}${(}${|}+${"}${(}${)}+${"}${(}${)}+${"}${)}${|}+${"}${)}${&}+${"}${.}${@}+${"}${[}${]}+${"}${+}${=}${+}+${"}${+}${+}${.}+${"}${.}${@}+${"}${.}${|}+${"}${&}${=}+${"}${[}${&}+${"}${+}${+}${|}+${"}${(}${|}+${"}${+}${+}${[}+${"}${.}${(}+${"}${)}${@}+${"}${]}${+}+${"}${[}${|}+${"}${[}${|}+${"}${.}${|}+${"}${[}${+}+${"}${+}${@}${.}+${"}${+}${.}+${"}${+}${=}+${"}${|}+${"}${&}${)}+${"}${+}${+}${[}+${"}${+}${=}${]}+${"}${+}${+}${(}+${"}${+}${=}${+}+${"}${[}${]}+${"}${)}${@}+${"}${+}${+}${+}+${"}${+}${+}${]}+${"}${+}${+}${(}+${"}${.}${@}+${"}${.}${|}+${"}${)}${+}+${"}${+}${+}${+}+${"}${+}${+}${+}+${"}${+}${=}${=}+${"}${.}${@}+${"}${)}${[}+${"}${+}${+}${+}+${"}${|}${&}+${"}${.}${.}+${"}${.}${|}+${"}${]}${|}+${"}${+}${.}+${"}${+}${=}+${"}${|}+${"}${&}${)}+${"}${+}${+}${[}+${"}${+}${=}${]}+${"}${+}${+}${(}+${"}${+}${=}${+}+${"}${[}${]}+${"}${)}${@}+${"}${+}${+}${+}+${"}${+}${+}${]}+${"}${+}${+}${(}+${"}${.}${@}+${"}${.}${[}+${"}${&}${.}+${"}${(}${|}+${"}${(}${)}+${"}${(}${)}+${"}${)}${|}+${"}${)}${&}+${"}${+}${@}${.}+${"}${.}${(}+${"}${(}${|}+${"}${(}${)}+${"}${(}${)}+${"}${)}${|}+${"}${)}${&}+${"}${+}${@}${]}+${"}${.}${[}+${"}${+}${.}+${"}${+}${=}+${"}${+}${@}${]}|${;}"|&${;}

難読化されていて読めないので、デバッガを使いながら実行していくと、

If($ECCON -eq 'POwEr$H311')

で比較しているのがわかるので、パスワードとしてこれを入力すると、フラグが得られます。

SECCON{POwEr$H311}

Thank you for playing!

SECCON{We have done all the challenges. Enjoy last 12 hours. Thank you!}

Ctrl-c & Ctrl-v

SECCON{We have done all the challenges. Enjoy last 12 hours. Thank you!}