直接爆破
-
根據
start
入口定位到main
函數,看到了一些被賦值的元數據:.text:00005652C48B552D mov [rdx], al .text:00005652C48B552F add rdx, 1 ; Add .text:00005652C48B5533 mov byte ptr [rbp-120h], 68h ; 'h' .text:00005652C48B553A mov byte ptr [rbp-11Fh], 6Fh ; 'o' .text:00005652C48B5541 mov byte ptr [rbp-11Eh], 65h ; 'e' .text:00005652C48B5548 mov byte ptr [rbp-11Dh], 6Ch ; 'l' .text:00005652C48B554F mov byte ptr [rbp-11Ch], 81h .text:00005652C48B5556 mov byte ptr [rbp-11Bh], 69h ; 'i' .text:00005652C48B555D mov byte ptr [rbp-11Ah], 7Ah ; 'z' .text:00005652C48B5564 mov byte ptr [rbp-119h], 3Dh ; '=' .text:00005652C48B556B mov byte ptr [rbp-118h], 3Bh ; ';' .text:00005652C48B5572 mov byte ptr [rbp-117h], 79h ; 'y' .text:00005652C48B5579 mov byte ptr [rbp-116h], 6Bh ; 'k' .text:00005652C48B5580 mov byte ptr [rbp-115h], 73h ; 's' .text:00005652C48B5587 mov byte ptr [rbp-114h], 38h ; '8' .text:00005652C48B558E mov byte ptr [rbp-113h], 39h ; '9' .text:00005652C48B5595 mov byte ptr [rbp-112h], 7Bh ; '{' .text:00005652C48B559C mov byte ptr [rbp-111h], 70h ; 'p' .text:00005652C48B55A3 mov byte ptr [rbp-110h], 7Bh ; '{' .text:00005652C48B55AA mov byte ptr [rbp-10Fh], 48h ; 'H' .text:00005652C48B55B1 mov byte ptr [rbp-10Eh], 73h ; 's' .text:00005652C48B55B8 mov byte ptr [rbp-10Dh], 7Ch ; '|' .text:00005652C48B55BF mov byte ptr [rbp-10Ch], 85h .text:00005652C48B55C6 mov byte ptr [rbp-10Bh], 47h ; 'G' .text:00005652C48B55CD mov byte ptr [rbp-10Ah], 7Ch ; '|' .text:00005652C48B55D4 mov byte ptr [rbp-109h], 96h .text:00005652C48B55DB lea rax, [rbp-160h] ; Load Effective Address .text:00005652C48B55E2 mov rdi, rax
-
查看逆向代碼:
這段都是STL庫函數操作,因此比較復雜。我們試圖略過這些代碼,因為他們太復雜
(其實可以看到這些庫函數操作都相同,並且重復了24次——正好是flag的長度)std::allocator<char>::allocator(&v11); std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(); sub_5652C48B6876(v13, v15); std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char>>::~basic_string(v15); std::allocator<char>::~allocator(&v11); sub_5652C48B6936(v13);
(重復的代碼)
我們輸入一些字符串進去試試,在for ( i = 0; i <= 23; ++i )
下斷點
(IDA動態調試內容在此不表)
輸入25個零:
0000000000000000000000000
查看IDA調試的變量地址:
根據此地址跟蹤到相應位置:
可以看到按照數字順序產生的數據,並且我們輸入的都是相同的數據,故而猜測邏輯為:
對輸入的數據進行移位變換,然后加上一個迭代變量。據此可以進行代碼人工識別
(這里可以多輸入一些數據進行試驗,筆者實驗了
A~Z
和a~z
,0~9
所有字符,都符合這樣的假說) -
raw代碼人工識別:
#include <stdio.h> #include "defs.h" char raw[] = { 0x68, 0x6F, 0x65, 0x6C, 0x81, 0x69, 0x7A, 0x3D, 0x3B, 0x79, 0x6B, 0x73, 0x38, 0x39, 0x7B, 0x70, 0x7B, 0x48, 0x73, 0x7C, 0x85, 0x47, 0x7C, 0x96 }; int main(int argc, char** argv) { for (int i = 0; i < 128; i++)//目的是嘗試不同的移位可能,最多有128種。 { for (int j = 0; j < 24; j++)//對raw進行更新 { printf("%c", (raw[j] - j) - i); } printf("\n"); } return 0; }
flag{br41n_f**k_i5_go0d}