最近学习了一下加解密的基本知识,基础不行看的好累啊,找了一个简单的CrackMe练练手,
只弄了了个大概,细节还不是很清楚,新手可以看看交流一下,老鸟也可以看看给点意见,如有
错误请指出,虚心接受各位的建议。下面开始了:
首先用peid看看,没壳,用delphi写的。运行一下要输入name和serial,随便输入试试看,弹出了wrong code的提示窗口。好,已经了解了基本信息。
用OD打开,可以用查找字符串“wrong code”快速定位到相关代码处;也可以ctrl+N查找相关API函数然后设断,看到了一个GetWindowTextA,设函数断点,但不知为什么没断下,同时试了一下消息断点也么用(囧,目测是delphi这类程序的原因),望高人指点一二。
就用了最简单的查找字符串到达了关键代码,F2下断点F9运行程序输入”cjh“、”123“断下:
004416FB |. 68 A8174400 push 004417A8
00441700 |. 64:FF30 push dword ptr fs:[eax]
00441703 |. 64:8920 mov dword ptr fs:[eax], esp
00441706 |. 8D55 FC lea edx, dword ptr [ebp-4]
00441709 |. 8B83 C8020000 mov eax, dword ptr [ebx+2C8]
0044170F |. E8 901AFEFF call 004231A4
00441714 |. 8B45 FC mov eax, dword ptr [ebp-4] ; 输入的注册码“123”
00441717 |. 50 push eax
00441718 |. 8D55 F4 lea edx, dword ptr [ebp-C]
0044171B |. 8B83 C4020000 mov eax, dword ptr [ebx+2C4]
00441721 |. E8 7E1AFEFF call 004231A4
00441726 |. FF75 F4 push dword ptr [ebp-C] ; 输入的name“cjh”
00441729 |. 8D55 F0 lea edx, dword ptr [ebp-10]
0044172C |. 8B83 C4020000 mov eax, dword ptr [ebx+2C4]
00441732 |. E8 6D1AFEFF call 004231A4
00441737 |. FF75 F0 push dword ptr [ebp-10]
0044173A |. 68 BC174400 push 004417BC ; 625
0044173F |. 68 C8174400 push 004417C8 ; g
00441744 |. 68 D4174400 push 004417D4 ; 72
00441749 |. 8D45 F8 lea eax, dword ptr [ebp-8]
0044174C |. BA 05000000 mov edx, 5
00441751 |. E8 9E23FCFF call 00403AF4 ; 计算注册码F7跟进去
00441756 |. 8B55 F8 mov edx, dword ptr [ebp-8] ; 计算出的注册码“cjhcjh625g72”
00441759 |. 58 pop eax
0044175A |. E8 E523FCFF call 00403B44 ; 比较计算出注册码和输入的注册码F7跟进去
0044175F |. 75 17 jnz short 00441778 ; 关键跳转点,不等就跳走
00441761 |. 6A 00 push 0
00441763 |. 66:8B0D D8174>mov cx, word ptr [4417D8]
0044176A |. B2 02 mov dl, 2
0044176C |. B8 E4174400 mov eax, 004417E4 ; right code
00441771 |. E8 02FBFFFF call 00441278
00441776 |. EB 15 jmp short 0044178D
00441778 |> 6A 00 push 0
0044177A |. 66:8B0D D8174>mov cx, word ptr [4417D8]
00441781 |. B2 01 mov dl, 1
00441783 |. B8 F8174400 mov eax, 004417F8 ; wrong code(跳到这里)
00441788 |. E8 EBFAFFFF call 00441278
0044178D |> 33C0 xor eax, eax
0044178F |. 5A pop edx
00441790 |. 59 pop ecx
00441791 |. 59 pop ecx
从上面的关键注释一目了然,算法明显看出来就是将用户名叠加一次然后加一串固定后缀,
本人菜菜,就不具体分析算法的实现了,代码在下面。
计算注册码的子程序:
00403AF4 $ 53 push ebx
00403AF5 . 56 push esi
00403AF6 . 52 push edx
00403AF7 . 50 push eax
00403AF8 . 89D3 mov ebx, edx
00403AFA . 31C0 xor eax, eax
00403AFC > 8B4C94 10 mov ecx, dword ptr [esp+edx*4+10]
00403B00 . 85C9 test ecx, ecx
00403B02 . 74 03 je short 00403B07
00403B04 . 0341 FC add eax, dword ptr [ecx-4]
00403B07 > 4A dec edx
00403B08 .^ 75 F2 jnz short 00403AFC
00403B0A . E8 69FDFFFF call 00403878
00403B0F . 50 push eax
00403B10 . 89C6 mov esi, eax
00403B12 > 8B449C 14 mov eax, dword ptr [esp+ebx*4+14]
00403B16 . 89F2 mov edx, esi
00403B18 . 85C0 test eax, eax
00403B1A . 74 0A je short 00403B26
00403B1C . 8B48 FC mov ecx, dword ptr [eax-4]
00403B1F . 01CE add esi, ecx
00403B21 . E8 86ECFFFF call 004027AC
00403B26 > 4B dec ebx
00403B27 .^ 75 E9 jnz short 00403B12
00403B29 . 5A pop edx
00403B2A . 58 pop eax
00403B2B . 85D2 test edx, edx
00403B2D . 74 03 je short 00403B32
00403B2F . FF4A F8 dec dword ptr [edx-8]
00403B32 > E8 D5FCFFFF call 0040380C
00403B37 . 5A pop edx
00403B38 . 5E pop esi
00403B39 . 5B pop ebx
00403B3A . 58 pop eax
00403B3B . 8D2494 lea esp, dword ptr [esp+edx*4]
00403B3E . FFE0 jmp eax
00403B40 . C3 ret
比较计算出的注册码与输入的注册码:
00403B44 /$ 53 push ebx
00403B45 |. 56 push esi
00403B46 |. 57 push edi
00403B47 |. 89C6 mov esi, eax
00403B49 |. 89D7 mov edi, edx
00403B4B |. 39D0 cmp eax, edx
00403B4D |. 0F84 8F000000 je 00403BE2
00403B53 |. 85F6 test esi, esi
00403B55 |. 74 68 je short 00403BBF
00403B57 |. 85FF test edi, edi
00403B59 |. 74 6B je short 00403BC6
00403B5B |. 8B46 FC mov eax, dword ptr [esi-4]
00403B5E |. 8B57 FC mov edx, dword ptr [edi-4]
00403B61 |. 29D0 sub eax, edx
00403B63 |. 77 02 ja short 00403B67
00403B65 |. 01C2 add edx, eax
00403B67 |> 52 push edx
00403B68 |. C1EA 02 shr edx, 2
00403B6B |. 74 26 je short 00403B93
00403B6D |> 8B0E /mov ecx, dword ptr [esi]
00403B6F |. 8B1F |mov ebx, dword ptr [edi]
00403B71 |. 39D9 |cmp ecx, ebx
00403B73 |. 75 58 |jnz short 00403BCD
00403B75 |. 4A |dec edx
00403B76 |. 74 15 |je short 00403B8D
00403B78 |. 8B4E 04 |mov ecx, dword ptr [esi+4]
00403B7B |. 8B5F 04 |mov ebx, dword ptr [edi+4]
00403B7E |. 39D9 |cmp ecx, ebx
00403B80 |. 75 4B |jnz short 00403BCD
00403B82 |. 83C6 08 |add esi, 8
00403B85 |. 83C7 08 |add edi, 8
00403B88 |. 4A |dec edx
00403B89 |.^ 75 E2 \jnz short 00403B6D
00403B8B |. EB 06 jmp short 00403B93
00403B8D |> 83C6 04 add esi, 4
00403B90 |. 83C7 04 add edi, 4
00403B93 |> 5A pop edx
00403B94 |. 83E2 03 and edx, 3
00403B97 |. 74 22 je short 00403BBB
00403B99 |. 8B0E mov ecx, dword ptr [esi]
00403B9B |. 8B1F mov ebx, dword ptr [edi]
00403B9D |. 38D9 cmp cl, bl
00403B9F |. 75 41 jnz short 00403BE2
00403BA1 |. 4A dec edx
00403BA2 |. 74 17 je short 00403BBB
00403BA4 |. 38FD cmp ch, bh
00403BA6 |. 75 3A jnz short 00403BE2
00403BA8 |. 4A dec edx
00403BA9 |. 74 10 je short 00403BBB
00403BAB |. 81E3 0000FF00 and ebx, 0FF0000
00403BB1 |. 81E1 0000FF00 and ecx, 0FF0000
00403BB7 |. 39D9 cmp ecx, ebx
00403BB9 |. 75 27 jnz short 00403BE2
00403BBB |> 01C0 add eax, eax
00403BBD |. EB 23 jmp short 00403BE2
00403BBF |> 8B57 FC mov edx, dword ptr [edi-4]
00403BC2 |. 29D0 sub eax, edx
00403BC4 |. EB 1C jmp short 00403BE2
00403BC6 |> 8B46 FC mov eax, dword ptr [esi-4]
00403BC9 |. 29D0 sub eax, edx
00403BCB |. EB 15 jmp short 00403BE2
00403BCD |> 5A pop edx
00403BCE |. 38D9 cmp cl, bl
00403BD0 |. 75 10 jnz short 00403BE2
00403BD2 |. 38FD cmp ch, bh
00403BD4 |. 75 0C jnz short 00403BE2
00403BD6 |. C1E9 10 shr ecx, 10
00403BD9 |. C1EB 10 shr ebx, 10
00403BDC |. 38D9 cmp cl, bl
00403BDE |. 75 02 jnz short 00403BE2
00403BE0 |. 38FD cmp ch, bh
00403BE2 |> 5F pop edi
00403BE3 |. 5E pop esi
00403BE4 |. 5B pop ebx
00403BE5 \. C3 ret
本人的第一篇破文,也是看雪的第一帖,写的不够详细大家凑合着看,有意见请指出。
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)