crackmes.one - babyrev writeup (zh-TW)

題目概覽
- 目標:輸入正確 password 與 secret code,印出 flag
- 題目連結: https://crackmes.one/crackme/6784f8a84d850ac5f7dc5173
偵查與定位
在 main
看到固定流程:
- 讀字串
fgets(s, 32, stdin); // 會保留結尾的 '\n'
- 讀整數
__isoc99_scanf("%d", &code); // 存到 local_40 / v4
- 雙重檢查
if (code == 1337) // 0x539
if (!strcmp(s, "Sup3rS3cr3tP455W0rd\n"))
// 印旗子
- 旗子輸出(XOR 迴圈)
- Hex-Rays:
for (i = 0; i <= 0x1A; ++i)
putchar((char)(flag[i] ^ (i + 105)));
- Ghidra(語意相同):
for (i = 0; i < 0x1b; i++)
putchar( (flag[i] ^ (i + 0x69)) );
0x69 = 105
,長度 27(i=0..26
)。
通關輸入
- secret code:
1337
- password:
Sup3rS3cr3tP455W0rd
,然後按 Enter
(因為fgets
比對的是含\n
的字串"Sup3rS3cr3tP455W0rd\n"
)
└─$ ./babyrev
Welcome to baby rev challenge
Input the password:
Sup3rS3cr3tP455W0rd
Input the secret code now:
1337
Correct!
Here is your flag
CTFlearn{Redacted}
經驗分享
這一題之所以收錄,是因為題目作者介紹了一個好用的工具:
Decompiler Explorer
Decompiler Explorer is an interactive online decompiler which shows equivalent C-like output of decompiled programs from many popular decompilers.

這個工具其實就是整合了市面上的反編譯工具,好比作者常用的ghidra也是其中之一,在沒有機密問題的情況下,只要上傳檔案就可以快速得到反編譯的結果。
