-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsa.cpp
66 lines (47 loc) · 1.34 KB
/
rsa.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "StdAfx.h"
#include "register.h"
#include "..\\rsa\\rsaeuro.h"
#include "..\\rsa\\rsa.h"
#include "..\\rsa\\public_key.cpp"
// 612686236 - ex-USSR registration
/*
*
*
*/
char* GetFunctionName( void* decr_str, int fnId )
{
unsigned int decryptedLength;
// Decrypt with public key
RSAPublicDecrypt( (unsigned char*)decr_str, &decryptedLength, (unsigned char*)FunctionNames, sizeof(bin_FunctionNames), publicKey);
return ((char*)decr_str)+25*fnId;
}
/*
*
*
*/
unsigned long GetRegistrationNameCRC( )
{
char s[4096];
char* ptr = GetFunctionName( s, 0 ); // get license file name
char decryptedString[1024];
unsigned int status, decryptedLength;
decryptedString[0] = 0;
HANDLE hFile = CreateFile( ptr, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
ZeroMemory( s, sizeof(s) );
if ( hFile==INVALID_HANDLE_VALUE )
return 0;
DWORD dwNumberOfBytesRead;
ReadFile( hFile, &s, 4096, &dwNumberOfBytesRead, 0 );
CloseHandle( hFile );
// Decrypt with public key
status = RSAPublicDecrypt( (unsigned char*)decryptedString, &decryptedLength, (unsigned char*)&s[1893], 128, publicKey);
if (status)
{
return 0;
}
// Display decrypted string
decryptedString[decryptedLength] = 0;
unsigned long crc = Register->getcrc( decryptedString );
ZeroMemory( decryptedString, sizeof(decryptedString) );
return crc;
}