Fravia's TOOLS OF OUR TRADE Messageboard ~ Moderated
SICE Key Generator code
Wednesday, 24-Feb-99 04:02:57
I used BC 4.5 and TASM 5 to compile.
Enjoy,
WH.
//********************* SIWREG.C ********************************
#include
#include
#include
//char *RefSN = "1900-0000DD-9B";
char *Header = "1900-";
char *My4digits = "0000";
char *Footer = "xx-xx";
//extern char SerNum_Buf40[40];
//extern char SerCpy_Buf8[8];
extern char SerChk_Buf4[4];
//extern int dSerCpyBufIdx;
//extern int dSerNumBufIdx;
//extern char *KeyTbl[8];
extern int DigitCheck(char *pSerNumStr);
//extern void Make_SerCpy(void);
//extern void Encrypt_SerCpy(void);
void main (int argc, char *argv[])
{
char RefSN[20];
char SN[20];
int i, j;
char *p;
printf("\n\tTHIS PROGRAMM GENERATES WIN95 SOFT-ICE REG NUMBER\n");
printf("\tBASED ON 4 DIGIT NUMBER THE USER HAVE TO PROVIDE\n");
printf("\tON THE COMMAND PROMPT.\n\n");
printf("**** Check phase ****\n");
memset(SN, 0, sizeof(SN));
memset(RefSN, 0, sizeof(RefSN));
sprintf(RefSN,"%s%s%s", Header, My4digits, Footer);
i=0; j=0;
while (RefSN[i] != '\0') {
if(RefSN[i] != '-') {
SN[j++] = RefSN[i];
}
i++;
}
printf("%s -> %s\n",RefSN, SN);
DigitCheck(SN);
p = Footer;
for(i=0; i<4; i++) {
if(i == 2) *p++ = '-';
sprintf(p++,"%c", SerChk_Buf4[i]);
}
Footer[5] = '\0';
sprintf(RefSN, "%s%s%s",Header,My4digits, Footer);
printf("The SN should be: %s\n",RefSN);
memset(SN, 0, sizeof(SN));
i = 0; j = 0;
while (RefSN[i] != '\0') {
if(RefSN[i] != '-') {
SN[j++] = RefSN[i];
}
i++;
}
printf("check: %s ->",RefSN);
if(DigitCheck(SN) == 1) printf(" OK\n");
else printf(" BAD\n");
printf("\n**** Your number phase ****\n");
if(argc <= 1) {
printf("usage: siwreg xxxx\n");
printf(" xxxx - 4 digits\n");
return;
}
if(strlen(argv[1]) != 4) {
printf("ERROR: Not a 4 digits number ...\n");
return;
}
printf("You entered: %s\n",argv[1]);
strcpy(My4digits, argv[1]);
memset(SN, 0, sizeof(SN));
memset(RefSN, 0, sizeof(RefSN));
sprintf(Footer,"%s","xx-xx");
sprintf(RefSN,"%s%s%s", Header, My4digits, Footer);
i=0; j=0;
while (RefSN[i] != '\0') {
if(RefSN[i] != '-') {
SN[j++] = RefSN[i];
}
i++;
}
printf("%s -> %s\n",RefSN, SN);
DigitCheck(SN);
p = Footer;
for(i=0; i<4; i++) {
if(i == 2) *p++ = '-';
sprintf(p++,"%c", SerChk_Buf4[i]);
}
Footer[5] = '\0';
sprintf(RefSN, "%s%s%s",Header,My4digits, Footer);
printf("The SN should be: %s\n",RefSN);
memset(SN, 0, sizeof(SN));
i = 0; j = 0;
while (RefSN[i] != '\0') {
if(RefSN[i] != '-') {
SN[j++] = RefSN[i];
}
i++;
}
printf("check: %s ->",RefSN);
if(DigitCheck(SN) == 1) printf(" OK\n");
else printf(" BAD\n");
}
;******************** SIWREG_A.ASM **************************
p386n
model flat
.DATA
public _SerNum_Buf40
_SerNum_Buf40 db 40 dup(?)
public _dSerCpyBufIdx
_dSerCpyBufIdx dd ?
public _dSerNumBufIdx
_dSerNumBufIdx dd ?
public _SerCpy_Buf8
_SerCpy_Buf8 db 8 dup(?)
public _SerChk_Buf4
_SerChk_Buf4 db 4 dup(?)
public _dErrFlag
_dErrFlag dd ?
Key1_Tab16 db 15, 1, 11, 3, 8, 4
db 13, 7, 12, 0, 0, 0
db 0, 0, 0, 0
Key2_Tab16 db 10, 12, 1, 8, 2, 0
db 9, 15, 5, 11, 0, 0
db 0, 0, 0, 0
Key3_Tab16 db 9, 5, 12, 2, 7, 6
db 15, 4, 14, 10, 0, 0
db 0, 0, 0, 0
Key4_Tab16 db 3, 4, 12, 11, 1, 10
db 13, 8, 0, 14, 0, 0
db 0, 0, 0, 0
Key5_Tab16 db 13, 1, 6, 11, 8, 10
db 14, 4, 3, 12, 0, 0
db 0, 0, 0, 0
Key6_Tab16 db 7, 11, 6, 10, 5, 9
db 4, 8, 0, 3, 0, 0
db 0, 0, 0, 0
Key7_Tab16 db 0, 13, 3, 15, 10, 8
db 2, 12, 4, 6, 0, 0
db 0, 0, 0, 0
Key8_Tab16 db 9, 5, 13, 1, 3, 11
db 12, 4, 2, 8, 0, 0
db 0, 0, 0, 0
public _KeyTbl
_KeyTbl dd offset Key1_Tab16
dd offset Key2_Tab16
dd offset Key3_Tab16
dd offset Key4_Tab16
dd offset Key5_Tab16
dd offset Key6_Tab16
dd offset Key7_Tab16
dd offset Key8_Tab16
pCtypeTbl dd offset __ctype+2
__ctype dw 0, 20h, 20h, 20h, 20h
dw 20h, 20h, 20h, 20h, 20h
dw 28h, 28h, 28h, 28h, 28h
dw 20h, 20h, 20h, 20h, 20h
dw 20h, 20h, 20h, 20h, 20h
dw 20h, 20h, 20h, 20h, 20h
dw 20h, 20h, 20h, 48h, 10h
dw 10h, 10h, 10h, 10h, 10h
dw 10h, 10h, 10h, 10h, 10h
dw 10h, 10h, 10h, 10h, 84h
dw 84h, 84h, 84h, 84h, 84h
dw 84h, 84h, 84h, 84h, 10h
dw 10h, 10h, 10h, 10h, 10h
dw 10h, 81h, 81h, 81h, 81h
dw 81h, 81h, 1, 1, 1
dw 1, 1, 1, 1, 1
dw 1, 1, 1, 1, 1
dw 1, 1, 1, 1, 1
dw 1, 1, 10h, 10h, 10h
dw 10h, 10h, 10h, 82h, 82h
dw 82h, 82h, 82h, 82h, 2
dw 2, 2, 2, 2, 2
dw 2, 2, 2, 2, 2
dw 2, 2, 2, 2, 2
dw 2, 2, 2, 2, 10h
dw 10h, 10h, 10h, 20h, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0
dw 0, 0, 0
dUseCtype_Eq1 dd 1
.CODE
; Exported entry 1. DigitCheck
; int DigitCheck(char *pSerNumStr)
;{
; int eax;
; _____________________________________________________________
; S u b r o u t i n e
public _DigitCheck
_DigitCheck proc near ; CODE XREF: _VBDigitCh
pSerNumStr = dword ptr 8
push esi
mov ecx, -1
push edi
sub eax, eax
mov edi, [esp+4+pSerNumStr]
repne scasb
not ecx
sub edi, ecx
mov eax, ecx
shr ecx, 2
mov esi, edi
mov edi, offset _SerNum_Buf40
repe movsd
mov ecx, eax
and ecx, 3
repe movsb
; strcpy(_SerNum_Buf40, pSerNumStr);
call _Make_SerCpy
; Make_SerCpy();
call _Encrypt_SerCpy
; Encrypt_SerCpy();
xor eax, eax
mov _dErrFlag, 1
; eax = 0;
; do {
loop_10001144:
mov cl, (_SerCpy_Buf8+4)[eax]
xor cl, _SerCpy_Buf8[eax]
or cl, _SerCpy_Buf8+7
mov _SerChk_Buf4[eax], cl
; SerChk_Buf4[eax] = (char)((SerCpy_Buf8[eax+4] ^ SerCpy_Buf8[eax]) | SerCpy_Buf8[7]);
or cl, 30h
mov _SerChk_Buf4[eax], cl
; SerChk_Buf4[eax] |= 0x30;
cmp cl, 39h
jbe short IsDigit_1000117
add cl, 7
mov _SerChk_Buf4[eax], cl
; if(SerChk_Buf4[eax] > 0x39) SerChk_Buf4[eax] += 7;
IsDigit_1000117:
mov dl, (_SerNum_Buf40+8)[eax]
mov cl, _SerChk_Buf4[eax]
cmp dl, cl
jz short OK_1000118F
;
or cl, 20h
mov _dSerNumBufIdx, eax
cmp cl, dl
;jnz short ErrRet0_100011A
jz short OK_1000118F
mov _dErrFlag, 0
; if(SerNum_Buf40[eax+8] != SerChk_Buf4[eax]) {
; _dSerNumBufIdx = eax;
; if(SerNum_Buf40[eax+8] != (SerChk_Buf4[eax] | 0x20)) dErrFlag = 0;
; }
OK_1000118F:
inc eax
mov _dSerNumBufIdx, eax
cmp eax, 4
jl short loop_10001144
; eax++;
; _dSerNumBufIdx = eax;
; } while(eax < 4);
mov eax, _dErrFlag;
pop edi
pop esi
retn
; return dErrFlag;
;}
;ErrRet0_100011A:
; xor eax, eax
; pop edi
; pop esi
; retn
_DigitCheck endp
; Exported entry 2. HexStrToNum
; ____________________________________________
; S u b r o u t i n e
public HexStrToNum
HexStrToNum proc near
pHexStr = dword ptr 4
mov eax, [esp+pHexStr]
; push 10h
; push 0
; push eax
; call _strtoul
; add esp, 0Ch
retn
HexStrToNum endp
; _____________________________________________________________
; S u b r o u t i n e
public _Make_SerCpy
_Make_SerCpy proc near ; CODE XREF: _DigitChec
push esi
xor eax, eax
push edi
;
mov esi, 1
mov edi, 8
mov _dSerCpyBufIdx, eax
mov _dSerNumBufIdx, eax
loop1_100011E8:
; cmp dUseCtype_Eq1, esi ; 1 ?
; jle short else_1000120A
;
; push 4
; mov eax, _dSerNumBufIdx
; xor ecx, ecx
; mov cl, _SerNum_Buf40[eax]
; push ecx
; call __isctype
; add esp, 8
; jmp short endif_10001226
;else_1000120A:
mov eax, _dSerNumBufIdx
xor ecx, ecx
mov edx, pCtypeTbl
mov cl, _SerNum_Buf40[eax]
xor eax, eax
mov ax, [edx+ecx*2]
and eax, 4
;endif_10001226:
test eax, eax
jz short endw1_10001259
;
cmp _dSerNumBufIdx, edi ; 8 ?
jge short endw1_10001259
;
mov eax, _dSerNumBufIdx
inc _dSerNumBufIdx
mov cl, _SerNum_Buf40[eax]
and cl, 0Fh
mov eax, _dSerCpyBufIdx
inc _dSerCpyBufIdx
mov _SerCpy_Buf8[eax], cl
jmp short loop1_100011E8
endw1_10001259:
cmp _dSerCpyBufIdx, 8
jge short return_endw2_2A
;
xor ecx, ecx
dec _dSerCpyBufIdx
mov _dSerNumBufIdx, 7
loop2_10001274:
cmp _dSerCpyBufIdx, ecx ; 0 ?
jge short else2_10001289
mov eax, _dSerNumBufIdx ; 7
mov _SerCpy_Buf8[eax], cl
jmp short endif2_100012A6
else2_10001289:
mov eax, _dSerCpyBufIdx
mov esi, _dSerNumBufIdx
dec _dSerCpyBufIdx
mov dl, _SerCpy_Buf8[eax]
mov _SerCpy_Buf8[esi], dl
endif2_100012A6:
dec _dSerNumBufIdx
jns short loop2_10001274
return_endw2_2A:
pop edi
pop esi
retn
_Make_SerCpy endp
; _____________________________________________________________
; S u b r o u t i n e
public _Encrypt_SerCpy
_Encrypt_SerCpy proc near ; CODE XREF: _DigitChec
push ebx
;
mov edx, 8
mov _dSerNumBufIdx, 0
loop_100012D0:
mov ecx, _dSerNumBufIdx
mov eax, _dSerNumBufIdx
add ecx, offset _SerCpy_Buf8
xor ebx, ebx
mov eax, _KeyTbl[eax*4]
mov bl, [ecx]
mov al, [eax+ebx]
mov [ecx], al
inc _dSerNumBufIdx
cmp _dSerNumBufIdx, edx ; 8 ?
jl short loop_100012D0
;
pop ebx
retn
_Encrypt_SerCpy endp
END
WH