老大,还没分析完呢。我继续分析了一下,又写了个注册机:P (3千字)
//-----------kg.cpp--------------------#include "windows.h"
#include "Kg.h"
#pragma comment(linker,"/OPT:NOWIN98")
#pragma comment(linker,"/ENTRY:WinMain")
#pragma comment(linker, "/SECTION:Mini,")
#pragma comment(linker, "/MERGE:.data=Mini")
#pragma comment(linker, "/MERGE:.text=Mini")
#pragma comment(linker, "/MERGE:.rdata=Mini")
HWND hWnd;
HINSTANCE hInst;
unsigned int iSum=0,iStrLen=0;
int iCheckNum=0;
unsigned char szName[20]; //名字的最大长度
unsigned char szSN[0x60];
unsigned char M[0x40];
unsigned char T[4][0x10]={
// t1[0x10]=
{
0xD8,0x00,0xFE,0x00,
0x8E,0x00,0x66,0x00,
0x2F,0x00,0xDE,0x00,
0x43,0x00,0xA5,0x00
},
// t2[0x10]=
{
0xD3,0x00,0x1F,0x00,
0x78,0x00,0x6F,0x00,
0x38,0x00,0x8F,0x00,
0x65,0x00,0x5A,0x00
},
// t3[0x10]=
{
0x00,0x10,0x00,0xF1,
0x00,0xA5,0x00,0x2F,
0x00,0x1F,0x00,0xCB,
0x00,0x98,0x00,0xF3
},
// t4[0x10]=
{
0x00,0xEF,0x00,0xE0,
0x00,0x73,0x00,0x78,
0x00,0x73,0x00,0x34,
0x00,0x77,0x00,0x33
}
};
void FillM()
{
int i;
for (i=0;i<0x3d;i++)M[i]=(i-1)*3;
}
void CvtName() //1.转换名字应该是strlen-2次循环。
{
int i,l,c=2,t;
l=iStrLen;
strcpy((char *)M,(const char *)szName);
M[l]=0;
for(i=0;i<l-2;i++){
t=M[i]*M[i+2]-M[i+1]-c;
c+=2;
iSum=iSum+t+3;
}
}
void CvtSN()
{
unsigned char i;
i='0';
szSN[1]=i;
szSN[0xa]=i;
szSN[0xc]=i;
i=iCheckNum&0xff;
szSN[0xe]=(i%9)+'A';
szSN[0x16]=(i%7)+'A';
szSN[0x17]='\0';
}
void KeyGen()
{
unsigned i,j,t,q,p,s,high,low;
iSum=0;
iCheckNum=0;
FillM();
CvtName();
s=iSum%0x100;
for(i=0,j=0;i<0x3c;i++){
high=i%4;
low=(i%0x20)>>1;
q=T[high][low];
high=((i+s)^q)%0x3b;
t=M[high];
high=((t+i)%0x12)%4;
low=((t+i)%0x12/*%0x20*/)>>1;
p=T[high][low]; //mod 12,then mod 20???
M[i]=((t^p)+t)^(M[i+1]<<1);
szSN[j++]=((i%5)&1)?M[i]%10+'0':M[i]%26+'A';
if(i%5==4)szSN[j++]='-';
if(i){
if((i<iStrLen)&&(j<iStrLen))iCheckNum+=szName[i-1]*szName[j];
}
}
CvtSN();
}
LRESULT CALLBACK MainProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_COMMAND:
switch(wParam)
{
case IDC_GEN:
GetDlgItemText(hWnd,IDE_NAME,(char *)szName,0x39);
iStrLen=strlen((const char *)szName);
KeyGen();
SetDlgItemText(hWnd,IDE_SN,(char *)szSN);
break;
case IDC_EXIT:
EndDialog(hWnd,0);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
hInst=hInstance;
ExitProcess(DialogBox(hInstance,(LPTSTR)IDD_DLGMAIN,0,(DLGPROC)MainProc));
return 0;
}
//----kg.h---------
#define IDD_DLGMAIN 1000
#define IDE_NAME 1001
#define IDE_SN 1002
#define IDC_GEN 1003
#define IDC_EXIT 1004
//----kg.rc--------
#include "Kg.h"
#include "resource.h"
#include "windows.h"
IDD_DLGMAIN DIALOGEX 0, 0, 180, 73
STYLE WS_POPUP | WS_CAPTION
CAPTION "Uedit10.00c Keygen by 5,555"
FONT 9, "宋体"
BEGIN
EDITTEXT IDE_NAME,48,11,116,12,NOT WS_BORDER,WS_EX_STATICEDGE
EDITTEXT IDE_SN,48,29,116,12,ES_AUTOHSCROLL | ES_READONLY | NOT
WS_BORDER,WS_EX_STATICEDGE
PUSHBUTTON "生成",IDC_GEN,11,52,42,16,0,WS_EX_STATICEDGE
PUSHBUTTON "退出",IDC_EXIT,78,52,42,16,0,WS_EX_STATICEDGE
RTEXT "注册码:",-1,8,31,31,8
RTEXT "用户名:",-1,8,13,31,8
END
