【原帖】
http://bbs.pediy.com/showthread.php?s=&threadid=26221
【分析】
呵呵,不难。
00401180 /. 55 push ebp
00401181 |. 8BEC mov ebp, esp
00401183 |. 837D 0C 02 cmp dword ptr [ebp+C], 2
00401187 |. 75 0C jnz short 00401195
00401189 |. 6A 00 push 0 ; /ExitCode = 0
0040118B |. E8 7A020000 call <jmp.&user32.PostQuitMessage> ; \PostQuitMessage
00401190 |. E9 20020000 jmp 004013B5
00401195 |> 837D 0C 10 cmp dword ptr [ebp+C], 10
00401199 |. 75 0D jnz short 004011A8
0040119B |. FF75 08 push dword ptr [ebp+8] ; /hWnd
0040119E |. E8 2B020000 call <jmp.&user32.DestroyWindow> ; \DestroyWindow
004011A3 |. E9 0D020000 jmp 004013B5
004011A8 |> 817D 0C 11010>cmp dword ptr [ebp+C], 111
004011AF |. 0F85 EB010000 jnz 004013A0
004011B5 |. 8B45 10 mov eax, [ebp+10]
004011B8 |. 837D 14 00 cmp dword ptr [ebp+14], 0
004011BC |. 0F84 F3010000 je 004013B5
004011C2 |. 8B55 10 mov edx, [ebp+10]
004011C5 |. C1EA 10 shr edx, 10
004011C8 |. 66:0BD2 or dx, dx
004011CB |. 0F85 CD010000 jnz 0040139E
004011D1 |. 66:83F8 67 cmp ax, 67
004011D5 |. 0F85 C3010000 jnz 0040139E
004011DB |. 6A 19 push 19 ; /Count = 19 (25.)
004011DD |. 68 9A304000 push 0040309A ; |Buffer = keygen.0040309A
004011E2 |. 6A 66 push 66 ; |ControlID = 66 (102.)
004011E4 |. FF75 08 push dword ptr [ebp+8] ; |hWnd
004011E7 |. E8 F4010000 call <jmp.&user32.GetDlgItemTextA> ; \GetDlgItemTextA
004011EC |. 83F8 08 cmp eax, 8
004011EF |. 0F85 A9010000 jnz 0040139E
004011F5 |. 6A 1E push 1E ; /Count = 1E (30.)
004011F7 |. 68 7C304000 push 0040307C ; |Buffer = keygen.0040307C
004011FC |. 6A 65 push 65 ; |ControlID = 65 (101.)
004011FE |. FF75 08 push dword ptr [ebp+8] ; |hWnd
00401201 |. E8 DA010000 call <jmp.&user32.GetDlgItemTextA> ; \GetDlgItemTextA
00401206 |. 83F8 05 cmp eax, 5
00401209 |. 0F82 8F010000 jb 0040139E
0040120F |. 8D05 7C304000 lea eax, [40307C] ; name
00401215 |. 8D48 04 lea ecx, [eax+4]
00401218 |. 33D2 xor edx, edx
0040121A |> 0211 /add dl, [ecx]
0040121C |. 41 |inc ecx
0040121D |. 8039 00 |cmp byte ptr [ecx], 0
00401220 |.^ 75 F8 \jnz short 0040121A
00401222 |. 33C9 xor ecx, ecx
00401224 |. 8ACA mov cl, dl
00401226 |. 8AEA mov ch, dl
00401228 |. 0FC9 bswap ecx
0040122A |. 8ACA mov cl, dl
0040122C |. 8AEA mov ch, dl
0040122E |. 8B00 mov eax, [eax]
00401230 |. 33C8 xor ecx, eax
00401232 |. 0FC9 bswap ecx
00401234 |. 81C1 06200203 add ecx, 3022006
0040123A |. 0FC9 bswap ecx
0040123C |. 81E9 DEC0ADDE sub ecx, DEADC0DE
00401242 |. 0FC9 bswap ecx
00401244 |. FEC1 inc cl
00401246 |. FEC5 inc ch
00401248 |. 0FC9 bswap ecx
0040124A |. FEC9 dec cl
0040124C |. FECD dec ch
0040124E |. 0FC9 bswap ecx
00401250 |. 81F1 2083B8ED xor ecx, EDB88320
00401256 |. 0FC9 bswap ecx
00401258 |. 81C1 78A46AD7 add ecx, D76AA478
0040125E |. 0FC9 bswap ecx
00401260 |. 81E9 CEFA0BB0 sub ecx, B00BFACE
00401266 |. 0FC9 bswap ecx
00401268 |. 81C1 EFBEAD0B add ecx, 0BADBEEF
0040126E |. 0FC9 bswap ecx
00401270 |. 41 inc ecx
00401271 |. 0FC9 bswap ecx
00401273 |. 49 dec ecx
00401274 |. 0FC9 bswap ecx
00401276 |. 03C8 add ecx, eax
00401278 |. 0FC9 bswap ecx
0040127A |. 66:41 inc cx
0040127C |. 0FC9 bswap ecx
0040127E |. 66:41 inc cx
00401280 |. 0FC9 bswap ecx
00401282 |. 890D C8304000 mov [4030C8], ecx
上面取name进行变换送到[4030C8]
00401288 |. 33C9 xor ecx, ecx
0040128A |. 8D05 9A304000 lea eax, [40309A]
00401290 |> 33DB /xor ebx, ebx
00401292 |. 8A18 |mov bl, [eax]
00401294 |. 80FB 00 |cmp bl, 0 ; Switch (cases 0..46)
00401297 |. 74 3A |je short 004012D3
00401299 |. 80FB 30 |cmp bl, 30
0040129C |. 0F82 FC000000 |jb 0040139E
004012A2 |. 80FB 39 |cmp bl, 39
004012A5 |. 77 0D |ja short 004012B4
004012A7 |. 80EB 30 |sub bl, 30 ; Cases 30 ('0'),31 ('1'),32 ('2'),33 ('3'),34 ('4'),35 ('5'),36 ('6'),37 ('7'),38 ('8'),39 ('9') of switch 00401294
004012AA |. 8899 B8304000 |mov [ecx+4030B8], bl
004012B0 |. 40 |inc eax
004012B1 |. 41 |inc ecx
004012B2 |.^ EB DC |jmp short 00401290
004012B4 |> 80FB 41 |cmp bl, 41
004012B7 |. 0F82 E1000000 |jb 0040139E
004012BD |. 80FB 46 |cmp bl, 46
004012C0 |. 0F87 D8000000 |ja 0040139E
004012C6 |. 80EB 37 |sub bl, 37 ; Cases 41 ('A'),42 ('B'),43 ('C'),44 ('D'),45 ('E'),46 ('F') of switch 00401294
004012C9 |. 8899 B8304000 |mov [ecx+4030B8], bl
004012CF |. 40 |inc eax
004012D0 |. 41 |inc ecx
004012D1 |.^ EB BD \jmp short 00401290
把serial转成对应的8个BYTE
004012D3 |> 33C0 xor eax, eax ; Case 0 of switch 00401294
004012D5 |. 33DB xor ebx, ebx
004012D7 |. 33C9 xor ecx, ecx
004012D9 |. 33D2 xor edx, edx
004012DB |. 0FB699 B83040>movzx ebx, byte ptr [ecx+4030B8]
004012E2 |. C1E3 04 shl ebx, 4
004012E5 |. 41 inc ecx
004012E6 |. 0FB691 B83040>movzx edx, byte ptr [ecx+4030B8]
004012ED |. 03DA add ebx, edx
004012EF |. 80F3 12 xor bl, 12
004012F2 |. 80C3 34 add bl, 34
004012F5 |. 81E3 FF000000 and ebx, 0FF
1,2个BYTE组成一个BYTE XOR 12 +34
004012FB |. 41 inc ecx
004012FC |. 03C3 add eax, ebx
004012FE |. C1E0 08 shl eax, 8
00401301 |. 0FB699 B83040>movzx ebx, byte ptr [ecx+4030B8]
00401308 |. C1E3 04 shl ebx, 4
0040130B |. 41 inc ecx
0040130C |. 0FB691 B83040>movzx edx, byte ptr [ecx+4030B8]
00401313 |. 03DA add ebx, edx
00401315 |. 80F3 56 xor bl, 56
00401318 |. 80C3 78 add bl, 78
0040131B |. 81E3 FF000000 and ebx, 0FF
3,4个BYTE组成一个BYTE XOR 56 +78
00401321 |. 41 inc ecx
00401322 |. 03C3 add eax, ebx
00401324 |. C1E0 08 shl eax, 8
00401327 |. 0FB699 B83040>movzx ebx, byte ptr [ecx+4030B8]
0040132E |. C1E3 04 shl ebx, 4
00401331 |. 41 inc ecx
00401332 |. 0FB691 B83040>movzx edx, byte ptr [ecx+4030B8]
00401339 |. 03DA add ebx, edx
0040133B |. 80F3 90 xor bl, 90
0040133E |. 80C3 AB add bl, 0AB
00401341 |. 81E3 FF000000 and ebx, 0FF
5,6个BYTE组成一个BYTE XOR 90 +AB
00401347 |. 41 inc ecx
00401348 |. 03C3 add eax, ebx
0040134A |. C1E0 08 shl eax, 8
0040134D |. 0FB699 B83040>movzx ebx, byte ptr [ecx+4030B8]
00401354 |. C1E3 04 shl ebx, 4
00401357 |. 41 inc ecx
00401358 |. 0FB691 B83040>movzx edx, byte ptr [ecx+4030B8]
0040135F |. 03DA add ebx, edx
00401361 |. 80F3 CD xor bl, 0CD
00401364 |. 80C3 EF add bl, 0EF
00401367 |. 81E3 FF000000 and ebx, 0FF
7,8个BYTE组成一个BYTE XOR CD +EF
0040136D |. 41 inc ecx
0040136E |. 03C3 add eax, ebx
00401370 |. 0FC8 bswap eax
00401372 |. 8B1D C8304000 mov ebx, [4030C8]
00401378 |. 3BD8 cmp ebx, eax //比较
0040137A |. 75 22 jnz short 0040139E
0040137C |. 6A 40 push 40 ; /Style = MB_OK|MB_ICONASTERISK|MB_APPLMODAL
0040137E |. 68 50304000 push 00403050 ; |沥翠!!
00401383 |. 68 19304000 push 00403019 ; |http://hansir.co.to肺 捞悼窍技夸:)
00401388 |. 6A 00 push 0 ; |hOwner = NULL
0040138A |. E8 75000000 call <jmp.&user32.MessageBoxA> ; \MessageBoxA
0040138F |. 68 3E304000 push 0040303E ; /荐绊 窍继嚼聪促!!沥翠!!
00401394 |. FF75 08 push dword ptr [ebp+8] ; |hWnd
00401397 |. E8 86000000 call <jmp.&user32.SetWindowTextA> ; \SetWindowTextA
0040139C |. EB 00 jmp short 0040139E
0040139E |> EB 15 jmp short 004013B5 ; Default case of switch 00401294
004013A0 |> FF75 14 push dword ptr [ebp+14] ; /lParam
004013A3 |. FF75 10 push dword ptr [ebp+10] ; |wParam
004013A6 |. FF75 0C push dword ptr [ebp+C] ; |Message
004013A9 |. FF75 08 push dword ptr [ebp+8] ; |hWnd
004013AC |. E8 17000000 call <jmp.&user32.DefWindowProcA> ; \DefWindowProcA
004013B1 |. C9 leave
004013B2 |. C2 1000 retn 10
004013B5 |> 33C0 xor eax, eax
004013B7 |. C9 leave
004013B8 \. C2 1000 retn 10
注册机:
#include "stdafx.h"
#include <WINDOWS.H>
#include <STDIO.H>
#define GETBYTE(x, y) (DWORD)(BYTE)(((x)>>(8*(y)))) //获得DWORD中的某个BYTE
#define BIG_ENDDIAN(X) (GETBYTE(X,0)<<24)|(GETBYTE(X,1)<<16)|(GETBYTE(X,2)<<8)|(GETBYTE(X,3)) //转换BIG_ENDDIAN
int main(int argc, char* argv[])
{
printf("KeyGen By NightFox\n");
char* name="hansir";
printf("Username:hansir\n");
int len=strlen(name);
BYTE temp=0;
for(int i=4;i<len;i++)
{
temp+=(BYTE)name[i];
}
DWORD ecx=temp<<24|temp<<16|temp<<8|temp; //temp填充
ecx^=*((DWORD*)name); //XOR name前4位
ecx=BIG_ENDDIAN(ecx);
ecx+=0x3022006;
ecx=BIG_ENDDIAN(ecx);
ecx-=0xDEADC0DE;
ecx=BIG_ENDDIAN(ecx);
BYTE ecx0=(BYTE)GETBYTE(ecx,0);
BYTE ecx1=(BYTE)GETBYTE(ecx,1);
ecx0++;
ecx1++;
ecx=(ecx&0xffff0000)|(ecx1<<8)|(ecx0);
ecx=BIG_ENDDIAN(ecx);
ecx0=(BYTE)GETBYTE(ecx,0);
ecx1=(BYTE)GETBYTE(ecx,1);
ecx0--;
ecx1--;
ecx=(ecx&0xffff0000)|(ecx1<<8)|(ecx0);
ecx=BIG_ENDDIAN(ecx);
ecx^=0xEDB88320;
ecx=BIG_ENDDIAN(ecx);
ecx+=0xD76AA478;
ecx=BIG_ENDDIAN(ecx);
ecx-=0xB00BFACE;
ecx=BIG_ENDDIAN(ecx);
ecx+=0x0BADBEEF;
ecx=BIG_ENDDIAN(ecx);
ecx++;
ecx=BIG_ENDDIAN(ecx);
ecx--;
ecx=BIG_ENDDIAN(ecx);
ecx+=*((DWORD*)name); //XOR name前4位
ecx=BIG_ENDDIAN(ecx);
WORD ecxword0=LOWORD(ecx);
ecxword0++;
ecx=(ecx&0xffff0000)|ecxword0;
ecx=BIG_ENDDIAN(ecx);
ecxword0=LOWORD(ecx);
ecxword0++;
ecx=(ecx&0xffff0000)|ecxword0;
ecx=BIG_ENDDIAN(ecx);
//结果逆变换
BYTE a=(BYTE)GETBYTE(ecx,0);
BYTE b=(BYTE)GETBYTE(ecx,1);
BYTE c=(BYTE)GETBYTE(ecx,2);
BYTE d=(BYTE)GETBYTE(ecx,3);
a=(a-0x34)^0x12;
b=(b-0x78)^0x56;
c=(c-0xAB)^0x90;
d=(d-0xEF)^0xCD;
printf("Serial:%02X%02X%02X%02X",a,b,c,d);
return 0;
}
【总结】
难度只能说2,序列号:23D9EE4C
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!