发现cnstars只写关于crackme_7.exe中serial的算法分析,故献上自己的TrackBar的算法分析。cnstars的原文链接为:http://bbs.pediy.com/showthread.php?t=27259。可以去那边下载附件,十分感谢提供资源让我们这些菜鸟学习。
--------------------------------------------------------------------------------------------------------
言归正传...
我们在0044C14C下断点。。。
0044C14C /$ 55 push ebp
0044C14D |. 8BEC mov ebp, esp
0044C14F |. 83C4 98 add esp, -68
0044C152 |. 53 push ebx
0044C153 |. 33D2 xor edx, edx
0044C155 |. 8955 C4 mov dword ptr [ebp-3C], edx
0044C158 |. 8955 FC mov dword ptr [ebp-4], edx
0044C15B |. 8955 F8 mov dword ptr [ebp-8], edx
0044C15E |. 8BD8 mov ebx, eax
0044C160 |. 33C0 xor eax, eax
0044C162 |. 55 push ebp
0044C163 |. 68 44C34400 push 0044C344
0044C168 |. 64:FF30 push dword ptr fs:[eax]
0044C16B |. 64:8920 mov dword ptr fs:[eax], esp
0044C16E |. 8D55 C4 lea edx, dword ptr [ebp-3C]
0044C171 |. 8B83 80030000 mov eax, dword ptr [ebx+380]
0044C177 |. E8 A896FDFF call 00425824
0044C17C |. 8B45 C4 mov eax, dword ptr [ebp-3C]
0044C17F |. E8 B0C0FBFF call 00408234
0044C184 |. DD5D E8 fstp qword ptr [ebp-18] ; 保存第一位x1
0044C187 |. 9B wait
0044C188 |. 8D55 C4 lea edx, dword ptr [ebp-3C]
0044C18B |. 8B83 98030000 mov eax, dword ptr [ebx+398]
0044C191 |. E8 8E96FDFF call 00425824
0044C196 |. 8B45 C4 mov eax, dword ptr [ebp-3C]
0044C199 |. E8 96C0FBFF call 00408234
0044C19E |. DD5D E0 fstp qword ptr [ebp-20] ; 保存第二位x2
0044C1A1 |. 9B wait
0044C1A2 |. 8D55 C4 lea edx, dword ptr [ebp-3C]
0044C1A5 |. 8B83 9C030000 mov eax, dword ptr [ebx+39C]
0044C1AB |. E8 7496FDFF call 00425824
0044C1B0 |. 8B45 C4 mov eax, dword ptr [ebp-3C]
0044C1B3 |. E8 7CC0FBFF call 00408234
0044C1B8 |. DD5D D8 fstp qword ptr [ebp-28] ; 保存第三位x3
0044C1BB |. 9B wait
0044C1BC |. 8D55 C4 lea edx, dword ptr [ebp-3C]
0044C1BF |. 8B83 A0030000 mov eax, dword ptr [ebx+3A0]
0044C1C5 |. E8 5A96FDFF call 00425824
0044C1CA |. 8B45 C4 mov eax, dword ptr [ebp-3C]
0044C1CD |. E8 62C0FBFF call 00408234
0044C1D2 |. DD5D D0 fstp qword ptr [ebp-30] ; 保存第四位x4
0044C1D5 |. 9B wait
0044C1D6 |. 8D55 C4 lea edx, dword ptr [ebp-3C]
0044C1D9 |. 8B83 A4030000 mov eax, dword ptr [ebx+3A4]
0044C1DF |. E8 4096FDFF call 00425824
0044C1E4 |. 8B45 C4 mov eax, dword ptr [ebp-3C]
0044C1E7 |. E8 48C0FBFF call 00408234
0044C1EC |. DD5D C8 fstp qword ptr [ebp-38] ; 保存第五位x5
0044C1EF |. 9B wait
0044C1F0 |. DD45 E0 fld qword ptr [ebp-20] ; 取出第二位x2
0044C1F3 |. 83C4 F4 add esp, -0C
0044C1F6 |. DB3C24 fstp tbyte ptr [esp]
0044C1F9 |. 9B wait
0044C1FA |. B8 03000000 mov eax, 3 ;算法开始
0044C1FF |. E8 ECF6FCFF call 0041B8F0 ; x2^3
0044C204 |. D805 50C34400 fadd dword ptr [44C350] ; x2^3+5.000000
0044C20A |. D9FA fsqrt ; sqrt(x2^3+5)
0044C20C |. E8 F365FBFF call 00402804 ; cos(sqrt(x2^3+5))
0044C211 |. DB7D B8 fstp tbyte ptr [ebp-48] ; 保存结果,记为res1
0044C214 |. 9B wait
0044C215 |. D905 54C34400 fld dword ptr [44C354] ; 1.000000
0044C21B |. DC45 E8 fadd qword ptr [ebp-18] ; x1+1
0044C21E |. D9FA fsqrt ; sqrt(x1+1)
0044C220 |. D9E0 fchs ; -sqrt(x1+1)
0044C222 |. DB6D B8 fld tbyte ptr [ebp-48]
0044C225 |. DEC1 faddp st(1), st ; res1 - sqrt(x1+1)
0044C227 |. DB7D AC fstp tbyte ptr [ebp-54] ; 保存结果,记为res2
0044C22A |. 9B wait
0044C22B |. D905 58C34400 fld dword ptr [44C358] ; 3.000000
0044C231 |. DC4D D8 fmul qword ptr [ebp-28] ; 3*x3
0044C234 |. D805 54C34400 fadd dword ptr [44C354] ; 3*x3 + 1.000000
0044C23A |. D9ED fldln2 ; ln2
0044C23C |. D9C9 fxch st(1)
0044C23E |. D9F1 fyl2x ; log(3*x3+1)*ln2
0044C240 |. DB6D AC fld tbyte ptr [ebp-54]
0044C243 |. DEC1 faddp st(1), st ; res2 + log(3*x3+1)*ln2
0044C245 |. DB7D A0 fstp tbyte ptr [ebp-60] ; 保存结果,记为res3
0044C248 |. 9B wait
0044C249 |. D905 5CC34400 fld dword ptr [44C35C] ; 2.000000
0044C24F |. DC45 D0 fadd qword ptr [ebp-30] ; x4 + 2
0044C252 |. D9FA fsqrt ; sqrt(x4+2)
0044C254 |. DB6D A0 fld tbyte ptr [ebp-60]
0044C257 |. DEE1 fsubrp st(1), st ; res4 = res3 - sqrt(x4+2)
0044C259 |. D905 58C34400 fld dword ptr [44C358] ; 3.000000
0044C25F |. DC4D C8 fmul qword ptr [ebp-38] ; 3.000000*x5
0044C262 |. D835 5CC34400 fdiv dword ptr [44C35C] ; 3.000000*x5/2.000000
0044C268 |. DEC1 faddp st(1), st ; res5 = res4 + 3.000000*x5/2.000000
0044C26A |. DB2D 60C34400 fld tbyte ptr [44C360] ; 0.37
0044C270 |. DEC1 faddp st(1), st ; res5 + 0.37
0044C272 |. D80D 6CC34400 fmul dword ptr [44C36C] ; (res5 + 0.37) * 1000
0044C278 |. DD5D F0 fstp qword ptr [ebp-10] ; 保存结果,记为res6
0044C27B |. 9B wait
0044C27C |. DD45 F0 fld qword ptr [ebp-10]
0044C27F |. E8 9065FBFF call 00402814
0044C284 |. 8945 98 mov dword ptr [ebp-68], eax
0044C287 |. 8955 9C mov dword ptr [ebp-64], edx
0044C28A |. DF6D 98 fild qword ptr [ebp-68] ; 舍弃res6小数点后的有效数字
0044C28D |. 83C4 F4 add esp, -0C
0044C290 |. DB3C24 fstp tbyte ptr [esp]
0044C293 |. 9B wait
0044C294 |. 8D45 FC lea eax, dword ptr [ebp-4]
0044C297 |. E8 68BFFBFF call 00408204 ; 化为整数,记为res
0044C29C |. 8D45 FC lea eax, dword ptr [ebp-4]
0044C29F |. E8 5CFCFFFF call 0044BF00 ; 关键判断,按f7进入
0044C2A4 |. 8B45 FC mov eax, dword ptr [ebp-4]
0044C2A7 |. BA 78C34400 mov edx, 0044C378
0044C2AC |. E8 D378FBFF call 00403B84 ; 判断结果是不是bab2bab5,如果是就大功告成了!!!
0044C29F处的关键调用...
------------------------------------------------------------------------------------------------------
0044BF00 /$ 53 push ebx
0044BF01 |. 56 push esi
0044BF02 |. 57 push edi
0044BF03 |. 51 push ecx
0044BF04 |. 8BF0 mov esi, eax
0044BF06 |. 8B06 mov eax, dword ptr [esi]
0044BF08 |. E8 677BFBFF call 00403A74
0044BF0D |. 8B15 98EE4400 mov edx, dword ptr [44EE98] ; cnstars_.0044F040
0044BF13 |. 8902 mov dword ptr [edx], eax
0044BF15 |. 8B06 mov eax, dword ptr [esi]
0044BF17 |. E8 587BFBFF call 00403A74
0044BF1C |. 84C0 test al, al
0044BF1E |. 76 38 jbe short 0044BF58
0044BF20 |. 880424 mov byte ptr [esp], al
0044BF23 |. B3 01 mov bl, 1
0044BF25 |> B8 1C000000 /mov eax, 1C
0044BF2A |. E8 516AFBFF |call 00402980 ; 调用四次,分别为3,9,6,d
0044BF2F |. 0D 80000000 |or eax, 80 ; 即eax分别为83,89,86,8d
0044BF34 |. 8BFB |mov edi, ebx
0044BF36 |. 81E7 FF000000 |and edi, 0FF
0044BF3C |. 8B16 |mov edx, dword ptr [esi] ; [esi]为res
0044BF3E |. 0FB6543A FF |movzx edx, byte ptr [edx+edi-1]
0044BF43 |. 33C2 |xor eax, edx ; 由0044C2AC处的调用可知,当eax分别为b5,ba,b2,ba时正确
0044BF45 |. 50 |push eax ; 即我们算出来的res应为6347
0044BF46 |. 8BC6 |mov eax, esi
0044BF48 |. E8 F77CFBFF |call 00403C44
0044BF4D |. 5A |pop edx
0044BF4E |. 885438 FF |mov byte ptr [eax+edi-1], dl
0044BF52 |. 43 |inc ebx
0044BF53 |. FE0C24 |dec byte ptr [esp]
0044BF56 |.^ 75 CD \jnz short 0044BF25
0044BF58 |> 5A pop edx
0044BF59 |. 5F pop edi
0044BF5A |. 5E pop esi
0044BF5B |. 5B pop ebx
0044BF5C \. C3 retn
------------------------------------------------------------------------------------------------------
最后附上求res的算法...
#include<cmath>
#include<stdlib.h>
#include <iostream>
using namespace std;
int main()
{
const double e = 2.718281828;
int i,j,k,l,m;
double x;
for(i=0; i<10; i++)
for(j=0; j<10; j++)
for(k=0; k<10; k++)
for(l=0; l<10; l++)
for(m=0; m<10; m++)
{
x = cos(sqrt(double(j*j*j) + 5))
- sqrt(double(i)+1)
+ log(k * 3.0 + 1)/log(2.0) * log(2.0)/log(e)
- sqrt(l + 2.0)
+ m*3.0 / 2.0
- 5.977;
if (fabs(x) <= 0.001 && x > 0)
cout << i << j << k << l << m << endl;
}
return 0;
}
运算结果:
14435
15245
37245
44405
55205
57225
60157