Fobber_verifySignature.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <Windows.h>
#include <wincrypt.h>
#include <stdio.h>
#pragma comment(lib, "crypt32.lib")
//the public key used for the verification:
BYTE RSA_key[] = {
0x06, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x07, 0xDA, 0xE8, 0x1B, 0x4C, 0x16, 0x87, 0xA7, 0xE2, 0x79, 0xE8, 0xBC,
0x0E, 0xD7, 0xED, 0xE6, 0x8C, 0x87, 0x8C, 0xE7, 0xC0, 0x57, 0xAB, 0x01, 0x46, 0x0B, 0xAF, 0x0F,
0xAC, 0x28, 0xF0, 0xBE, 0xF6, 0x6A, 0xB3, 0xD2, 0xF0, 0x6E, 0x8B, 0xEB, 0xDE, 0x01, 0x6A, 0xF4,
0xF5, 0xBA, 0xAE, 0xCC, 0xE3, 0x4E, 0x2F, 0x61, 0xA8, 0x1F, 0x14, 0xE2, 0xE2, 0x2B, 0xC2, 0x4B,
0x58, 0x07, 0x14, 0xB3, 0x2C, 0xF0, 0xE6, 0x1F, 0xD8, 0xCA, 0xA0, 0xF8, 0x44, 0x0A, 0x0A, 0xF5,
0x16, 0x8F, 0x3F, 0xD8, 0xAF, 0x63, 0x7E, 0xC4, 0x3F, 0xFC, 0xC0, 0x14, 0xFB, 0x24, 0xDC, 0x38,
0xE9, 0x1D, 0xAE, 0xD0, 0xDA, 0x82, 0x6B, 0xFA, 0x68, 0x78, 0xE1, 0xDD, 0xFE, 0x5D, 0xD7, 0x9A,
0x5E, 0x8C, 0xF8, 0x24, 0x19, 0xDC, 0x55, 0xC1, 0xEC, 0x97, 0x53, 0xB5, 0xB0, 0xE4, 0xF4, 0xE9,
0x52, 0xF1, 0x22, 0xC2
};
DWORD keySize = 0x94;
BYTE clientID[] = {
0x79, 0x3B, 0xC3, 0x40, //volume id
0x9B, 0xAC, 0x80, 0x55 //install date
};
DWORD clientID_size = 8;
//The data that came in C&C response (after decryption):
BYTE pbSignature[] = {
0xD3, 0x71, 0x43, 0x61, 0x7D, 0x06, 0x84, 0xA3, 0x83, 0x75, 0xBB, 0x39, 0x10, 0x92, 0x65, 0x6B,
0x54, 0xB3, 0xC6, 0x46, 0x64, 0x94, 0x39, 0xE2, 0x4C, 0x50, 0x15, 0xCA, 0x1B, 0xD4, 0xEE, 0x11,
0x05, 0x62, 0x81, 0xD8, 0x96, 0xAC, 0x00, 0x8A, 0xA5, 0x21, 0x2F, 0x0C, 0xE7, 0x9A, 0x44, 0xCF,
0xEC, 0xCE, 0x6E, 0x38, 0x8D, 0x49, 0x99, 0x7D, 0xD3, 0x5F, 0xE0, 0xC5, 0xB5, 0xA0, 0xFB, 0xBE,
0x10, 0x96, 0x5B, 0xB9, 0x5C, 0x58, 0x16, 0x6A, 0xE2, 0x26, 0xF1, 0x97, 0x67, 0xF8, 0xB1, 0xF3,
0xDA, 0x0D, 0x78, 0x15, 0xCE, 0xB2, 0x8A, 0x90, 0x35, 0xF6, 0xB4, 0x7C, 0xD5, 0xAA, 0x43, 0x4B,
0x5B, 0xB2, 0xE4, 0xBD, 0x52, 0x6B, 0x33, 0x83, 0xB1, 0xAF, 0x5B, 0x13, 0xDF, 0xA6, 0x17, 0x96,
0xDE, 0x45, 0xBC, 0x48, 0x78, 0xF9, 0x61, 0x83, 0xC2, 0xE1, 0x70, 0x14, 0x4C, 0xBB, 0x7F, 0x19
};
DWORD dwSigLen = 0x80; // data len: at the begining of data sent by C&C (second DWORD, after decryption)
HCRYPTPROV hProv;
HCRYPTKEY hKey;
HCRYPTHASH hHash;
int main(int argc, char *argv[])
{
//PUSH 0xF0000040; dwFlags
DWORD dwFlags = CRYPT_VERIFYCONTEXT | CRYPT_SILENT;
BOOL isOk = CryptAcquireContext( &hProv, NULL, NULL, PROV_RSA_FULL, dwFlags);
if (!isOk) {
printf ("CryptAcquireContext Failed!\n");
system("pause");
return (-1);
}
printf("[+] CryptAcquireContext Success\n");
isOk = CryptImportKey(hProv, RSA_key, keySize, NULL, 0, &hKey);
if (!isOk) {
printf ("CryptImportKey Failed!\n");
system("pause");
return (-1);
}
printf("[+] CryptImportKey Success\n");
isOk = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash);
if (!isOk) {
DWORD err = GetLastError();
printf ("CryptCreateHash Failed, err = %x!\n", err);
system("pause");
return (-1);
}
printf ("[+] CryptCreateHash Success\n");
isOk = CryptHashData(hHash, clientID, clientID_size, 0);
if (!isOk) {
printf ("CryptHashData Failed!\n");
return (-1);
}
printf ("[+] CryptHashData Success\n");
isOk = CryptVerifySignature(hHash, pbSignature, dwSigLen, hKey, 0, 0);
if (!isOk) {
printf ("CryptVerifySignature Failed!\n");
return (-1);
}
printf ("[+] CryptVerifySignature Success\n");
system("pause");
return 0;
}