#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib,"Crypt32.lib")
#include <Windows.h>
#include <dpapi.h>
#include <iostream>
#include <cwchar>
#include <atlstr.h>
unsigned int convert(int* a1, unsigned int a5);
int main() {
DATA_BLOB DataIn;
std::cout << sizeof(DATA_BLOB) << std::endl;
DATA_BLOB DataOut;
DATA_BLOB pOptionalEntropy;
char dest[100] = {0};
BYTE bpkey[310]
{
0x01,0x00,0x00,0x00,0xD0,0x8C,0x9D,0xDF,0x01,0x15,0xD1,0x11,0x8C,0x7A,0x00,0xC0,
0x4F,0xC2,0x97,0xEB,0x01,0x00,0x00,0x00,0xC0,0x6E,0xDE,0xB1,0x74,0x52,0xCB,0x46,
0x9F,0xF5,0x92,0x73,0x39,0x9D,0x52,0x72,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x00,0x00,0x10,0x66,0x00,0x00,0x00,0x01,0x00,0x00,0x20,0x00,0x00,0x00,0x03,0x9F,
0x65,0xE0,0x95,0xEC,0x94,0xE1,0x55,0x78,0x8D,0x0F,0x7F,0xF6,0x79,0x98,0x16,0xEF,
0xB3,0xB8,0x11,0x2A,0x6E,0x9B,0xD1,0xCC,0x37,0xC5,0xFB,0x36,0x4F,0x7F,0x00,0x00,
0x00,0x00,0x0E,0x80,0x00,0x00,0x00,0x02,0x00,0x00,0x20,0x00,0x00,0x00,0x0C,0x92,
0xA1,0xB9,0x50,0x34,0x45,0xE9,0xF4,0xEC,0x1D,0x8E,0xF2,0x51,0x6D,0xA1,0x95,0x1A,
0xB9,0xE5,0x93,0x27,0xEB,0x44,0x61,0x37,0xAD,0xD4,0x73,0xB4,0x04,0xC6,0x60,0x00,
0x00,0x00,0xA1,0x60,0x4E,0xA4,0x84,0x8A,0x7A,0x21,0x3A,0xC9,0x32,0x94,0xD0,0x0E,
0x94,0x77,0x22,0x2B,0x05,0x42,0xB5,0xE7,0x3B,0x4B,0x2F,0x7E,0x1B,0x8A,0x77,0x79,
0x30,0x98,0xFD,0xBB,0x06,0x22,0xAE,0x8C,0x0F,0xAA,0x9D,0xA8,0x27,0x57,0x79,0x18,
0x8E,0x6A,0x8E,0xBD,0x4C,0x43,0xEF,0xF8,0x5B,0x7C,0xED,0x8E,0x1A,0xA0,0x63,0x8D,
0x9E,0xBA,0xE2,0x60,0xA8,0x99,0xCE,0xFC,0xE7,0xE8,0x80,0xC0,0xFA,0x71,0x58,0x6A,
0xC2,0x08,0x9A,0x4F,0x1B,0xFC,0x47,0x88,0x56,0x0D,0xE4,0x06,0x1A,0x53,0x66,0xFC,
0x70,0x7C,0x40,0x00,0x00,0x00,0x40,0xEB,0xD0,0x8F,0xE7,0x12,0xF6,0x7F,0xAB,0x9A,
0x92,0x00,0xDA,0xA1,0x1B,0xB4,0xF2,0x66,0x54,0xE7,0x92,0x10,0xFD,0xB0,0xC0,0x6B,
0xEC,0xDF,0x20,0x11,0x63,0xB1,0xA0,0x08,0xE0,0x31,0xE5,0x4A,0x05,0xF8,0x59,0x61,
0x91,0x2D,0x93,0xC0,0x90,0xB0,0x41,0xBF,0x14,0x53,0xEA,0x65,0x1E,0xC5,0x95,0x98,
0xFA,0x5A,0xB8,0x70,0xFA,0x64
};
BYTE url[66]{
0x68,0x00,0x74,0x00,0x74,0x00,0x70,0x00,0x3A,0x00,0x2F,0x00,0x2F,0x00,0x77,0x00,
0x77,0x00,0x77,0x00,0x2E,0x00,0x33,0x00,0x76,0x00,0x62,0x00,0x6F,0x00,0x6F,0x00,
0x6B,0x00,0x73,0x00,0x2E,0x00,0x63,0x00,0x6F,0x00,0x6D,0x00,0x2F,0x00,0x6C,0x00,
0x6F,0x00,0x67,0x00,0x69,0x00,0x6E,0x00,0x2E,0x00,0x70,0x00,0x68,0x00,0x70,0x00
};
DataIn.pbData = (byte*)bpkey;
DataIn.cbData = 310;
DataOut.cbData = 0;
DataOut.pbData = 0;
pOptionalEntropy.pbData = (BYTE*)url;
pOptionalEntropy.cbData = 66;
if (CryptUnprotectData(
&DataIn,
0,
&pOptionalEntropy, // Optional entropy
NULL, // Reserved
NULL, // Here, the optional
// prompt structure is not
// used.
1,
&DataOut))
{
convert((int*)DataOut.pbData, DataOut.cbData);
//printf("%s", result);
LocalFree(DataOut.pbData);
}
else
{
printf("%d", GetLastError());
printf("Decryption error!");
}
system("pause");
return 0;
}
unsigned int convert(int* a1, unsigned int a5)
{
int *v5; // esi@1
unsigned int result; // eax@1
int v7; // edi@1
BYTE * v8; // eax@2
size_t v9; // eax@3
int v10; // ebx@3
WCHAR* v13;
size_t v11; // edi@4
WCHAR* v12; // [sp+8h] [bp-4h]@3
v5 = (int *)(a1 + 1);
printf("%x\t%x\n", v5,a1);
int v6 = *v5 + *a1;
if (v6 + 2 < a5) {
v8 = (BYTE*)a1 + a5;
//printf("%x", v8);
*(v8 - 1) = 0;
*(v8 - 2) = 0;
//do
//{
printf("%x\n", v6);
v12 = (WCHAR*)(v6/4 + a1);
printf("%ls\n", v12);
v9 = wcslen(v12);
v10 = v6 + 2 * v9 + 2;
result = v10+2;
if (result > a5)
return 1;
printf("%x\n", v10);
v13 = (WCHAR*)(v10 + (BYTE*)a1);
printf("%ls", v13);
v11 = 2 * wcslen((const wchar_t *)(v10/4 + a1));
//(**a2)(a3, a4, v12, v10 + v5);
//} while (v6 + 2 < a5);
}
return 0;
}