Created
January 29, 2021 18:47
-
-
Save nezza/a25bee13f25a1733a4c7a1d3d1cf5882 to your computer and use it in GitHub Desktop.
Windows 95 OEM Key check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined2 __stdcall16far check_oem_key(char *key,int len) | |
{ | |
int key_length; | |
int is_oem; | |
int first_3_digits_int; | |
int second_2_digits_int; | |
undefined2 check_result; | |
int i; | |
int i_; | |
char first_three_digits [4]; | |
char second_two_digits [3]; | |
char kc; | |
key_length = LSTRLEN(key); | |
if ((((key_length == 0x17) && (key[5] == '-')) && (key[9] == '-')) && | |
((key[0x11] == '-' && (is_oem = check_oem_str(3,0x11704f9d,key + 6,len), is_oem == 0)))) { | |
/* Check first 5 digits, must be numeric */ | |
i = 0; | |
do { | |
kc = key[i]; | |
if (kc < '0') { | |
return 0; | |
} | |
if ('9' < kc) { | |
return 0; | |
} | |
i = i + 1; | |
} while (i < 5); | |
/* */ | |
copy_partial(3,key,len,first_three_digits); | |
first_three_digits[3] = '\0'; | |
first_3_digits_int = atoi(first_three_digits); | |
if ((first_3_digits_int != 0) && | |
(first_3_digits_int < 367 | |
/* check if between 1 and 366 */)) { | |
copy_partial(2,key + 3,len,second_two_digits); | |
second_two_digits[2] = '\0'; | |
second_2_digits_int = atoi(second_two_digits); | |
if (((second_2_digits_int < 3) || (94 < second_2_digits_int)) && | |
(((key[10] == '0' && ('0' < key[0x10])) && (key[0x10] < '8')))) { | |
i_ = 0x12; | |
while ((kc = key[i_], '/' < kc && (kc < ':'))) { | |
i_ = i_ + 1; | |
if (0x16 < i_) { | |
/* jump to part after oem- */ | |
check_result = mod7_check(key + 10,len); | |
return check_result; | |
} | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Nice! :D
gist with .c extension and syntax highlighting: https://gist.github.com/fawaf/ddf043bbb34da93aa7b4408b6a19ff57
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will the gist link remain intact if you change the file extension to .c? Then we would have syntax highlighting.