reversing: Half (SECCON Beginners CTF 2023)

項目 内容
配点 500 ⇒ 50
正解チーム 599 / 778


【問題】


バイナリファイルってなんのファイルなのか調べてみよう!

あとこのファイルってどうやって中身を見るんだろう...?

Half.tar.gz f532a2ee8c9018ab2bb82d275b6a6838f54af630


【手順】

[解法1] Strings

 与えられたファイル(Half)を file コマンドを使用して属性を調査すると、

half: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=e2b1484a1db68e68d01130084882316fb34d86ad, for GNU/Linux 3.2.0, not stripped

また、strings コマンドで文字列を調査すると、

2004 Enter the FLAG:
202d ctf4b{ge4_t0_kn0w_the
2043 _bin4ry_fi1e_with_s4ring3}
3010 GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

となるので、flag は

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3}

 実際に、コマンドにこの flag を入力すると、

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3} ★

[解法2] IDA Pro

 与えられたファイル(Half)を IDA Pro を使用して逆アセンブルすると、

プログラムは、入力文字列を

> "ctf4b{ge4_t0_kn0w_the"

> "_bin4ry_fi1e_with_s4ring3}"

と順に比較し、両者が含まれている場合に、「Correct!」と表示する。よって Flag は両者を結合した、

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3}

 実際に、コマンドにこの flag を入力すると、

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3} ★

[解法3] Ghidra

 与えられたファイル(Half)を Ghidra を使用してデコンパイルすると、

主要部分は、

if (sVar2 == 0x2f) {
uStack_80 = 0x10125b;
iVar1 = strncmp(local_78,"ctf4b{ge4_t0_kn0w_the",0x15);
if (iVar1 == 0) {
uStack_80 = 0x10126b;
sVar2 = strlen(local_78);
uStack_80 = 0x101285;
iVar1 = strcmp(acStack_92 + sVar2,"_bin4ry_fi1e_with_s4ring3}");
if (iVar1 == 0) {
uStack_80 = 0x101295;
puts("Correct!");
return 0;
}

で、プログラムは、入力文字列を

> "ctf4b{ge4_t0_kn0w_the"

> "_bin4ry_fi1e_with_s4ring3}"

と順に比較し、両者が含まれている場合に、「Correct!」と表示する。よって Flag は両者を結合した、

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3}

 実際に、コマンドにこの flag を入力すると、

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3} ★



【正解】

ctf4b{ge4_t0_kn0w_the_bin4ry_fi1e_with_s4ring3}


【解説】



【Appendix】

A1 使用ツール
カテゴリ ツール名 説明 備考
---- ---- ---- ----
バイナリ解析 file ファイル属性調査
バイナリ解析 strings 文字列調査
バイナリ解析 Stirling バイナリエディタ
バイナリ解析 IDA Pro アセンブラ
バイナリ解析 Ghidra コンパイラ
バイナリ解析 独自ツール flag 探索
A2 使用サービス
カテゴリ サービス名 説明 備考
---- ---- ---- ----

A3 参考資料
対象 URL等
---- ----
A4 Writeup

■ドキュメント

著者 URL
---- ----