-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBackDoorProgram-WindowsSystemPowerExplorer.cpp
249 lines (186 loc) · 6.52 KB
/
BackDoorProgram-WindowsSystemPowerExplorer.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
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
#include <iostream>
#include <windows.h>
#include <string.h>
using namespace std;
void DisplayProgramHelp()
{
std :: cout << "" << endl;
std :: cout << "Command: /HELP or /help or -DISPLAYHELP or -displayhelp or --DISPLAYCOMMANDHELP or --displaycommandhelp \n命令: /HELP or /help or -DISPLAYHELP or -displayhelp or --DISPLAYCOMMANDHELP or --displaycommandhelp" << endl;
std :: cout << "Function: Show command help for this program. \n功能: 显示这个程序的命令帮助" << endl;
std :: cout << "#" << endl;
std :: cout << "Command: -WINOFF or -winoff or --POWEROFF or --poweroff \n命令: -WINOFF 或 -winoff 或 --POWEROFF 或 --poweroff" << endl;
std :: cout << "Function: Stop the Windows system and turn off the power. \n功能:停止Windows系统,关闭电源" << endl;
std :: cout << "#" << endl;
std :: cout << "Command: Command: -WINREBOOT or -winreboot or --REBOOTSTRAP or --rebootstrap \n命令: -WINREBOOT 或 -winreboot 或 --REBOOTSTRAP 或 --rebootstrap" << endl;
std :: cout << "Function: Restart boot Windows system. \n功能:重启Windows系统" << endl;
std :: cout << "#" << endl;
std :: cout << "Command: -WINLOCK or -winlock or --LOGOUTUSER or --logoutuser \n 命令: -WINLOCK 或 -winlock 或 --LOGOUTUSER 或 --logoutuser" << endl;
std :: cout << "Function: Windows system log out the current user. \n功能:Windows系统注销当前用户" << endl;
std :: cout << "#" << endl;
std :: cout << "This program is compiled by Twilight-Dream-Of-Magic" << endl;
std :: cout << "" << endl;
system("Pause");
}
void WidowsSystemShutDown()
{
//DisplayProgramHelp();
std :: cout << "From Progress: WindowsSystem --> Shut Down" << endl;
Sleep(1000);
HANDLE handle_Token;
TOKEN_PRIVILEGES token_ps;
std :: cout << "Work Progressing: 25%" << endl;
Sleep(1000);
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&handle_Token))
{
return;
}
std :: cout << "Work Progressing: 50%" << endl;
Sleep(1000);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&token_ps.Privileges[0].Luid);
//Get local unique means to set access token permissions for a specific Windows system 获取本地唯一的手段,用来设置特定Windows系统的访问令牌权限
std :: cout << "Work Progressing: 75%" << endl;
Sleep(1000);
token_ps.PrivilegeCount = 1;
token_ps.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(handle_Token,FALSE,&token_ps,0,(PTOKEN_PRIVILEGES)NULL,0);
//Elevated Windows system token access 提升Windows系统令牌的访问权限
std :: cout << "Work Progressing: 100%" << endl;
Sleep(1000);
ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE,0);
//Stop the Windows system and turn off the power 停止Windows系统,关闭电源
}
void WidowsSystemResetBoot()
{
//DisplayProgramHelp();
std :: cout << "From Progress: WindowsSystem --> Reset Boot" << endl;
Sleep(1000);
HANDLE handle_Token;
TOKEN_PRIVILEGES token_ps;
std :: cout << "Work Progressing: 25%" << endl;
Sleep(1000);
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&handle_Token))
{
return;
}
std :: cout << "Work Progressing: 50%" << endl;
Sleep(1000);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&token_ps.Privileges[0].Luid);
std :: cout << "Work Progressing: 75%" << endl;
Sleep(1000);
token_ps.PrivilegeCount = 1;
token_ps.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(handle_Token,FALSE,&token_ps,0,(PTOKEN_PRIVILEGES)NULL,0);
std :: cout << "Work Progressing: 100%" << endl;
Sleep(1000);
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);
//Restart boot Windows system 重启Windows系统
}
void WidowsSystemLogoutUser()
{
//DisplayProgramHelp();
std :: cout << "From Progress: WindowsSystem --> Logout User" << endl;
Sleep(1000);
HANDLE handle_Token;
TOKEN_PRIVILEGES token_ps;
std :: cout << "Work Progressing: 25%" << endl;
Sleep(1000);
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&handle_Token))
{
return;
}
std :: cout << "Work Progressing: 50%" << endl;
Sleep(1000);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&token_ps.Privileges[0].Luid);
std :: cout << "Work Progressing: 75%" << endl;
Sleep(1000);
token_ps.PrivilegeCount = 1;
token_ps.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(handle_Token,FALSE,&token_ps,0,(PTOKEN_PRIVILEGES)NULL,0);
std :: cout << "Work Progressing: 100%" << endl;
Sleep(1000);
ExitWindowsEx(EWX_LOGOFF|EWX_FORCE,0);
//Windows system log out the current user Windows系统注销当前用户
}
int main(int argc, char* argv[])
{
if(argc == 2 && strcmp(argv[1],"-WINOFF") == 0)
{
WidowsSystemShutDown();
}
if(argc == 2 && strcmp(argv[1],"-WINREBOOT") == 0)
{
WidowsSystemResetBoot();
}
if(argc == 2 && strcmp(argv[1],"-WINLOCK") == 0)
{
WidowsSystemLogoutUser();
}
if(argc == 2 && strcmp(argv[1],"-winoff") == 0)
{
WidowsSystemShutDown();
}
if(argc == 2 && strcmp(argv[1],"-winreboot") == 0)
{
WidowsSystemResetBoot();
}
if(argc == 2 && strcmp(argv[1],"-winlock") == 0)
{
WidowsSystemLogoutUser();
}
if(argc == 2 && strcmp(argv[1],"--POWEROFF") == 0)
{
WidowsSystemShutDown();
}
if(argc == 2 && strcmp(argv[1],"--REBOOTSTRAP") == 0)
{
WidowsSystemResetBoot();
}
if(argc == 2 && strcmp(argv[1],"--LOGOUTUSER") == 0)
{
WidowsSystemLogoutUser();
}
if(argc == 2 && strcmp(argv[1],"--poweroff") == 0)
{
WidowsSystemShutDown();
}
if(argc == 2 && strcmp(argv[1],"--rebootstrap") == 0)
{
WidowsSystemResetBoot();
}
if(argc == 2 && strcmp(argv[1],"--logoutuser") == 0)
{
WidowsSystemLogoutUser();
}
if(argc == 2 && strcmp(argv[1],"/HELP") == 0)
{
DisplayProgramHelp();
}
if(argc == 2 && strcmp(argv[1],"-DISPLAYHELP") == 0)
{
DisplayProgramHelp();
}
if(argc == 2 && strcmp(argv[1],"--DISPLAYCOMMANDHELP") == 0)
{
DisplayProgramHelp();
}
if(argc == 2 && strcmp(argv[1],"/help") == 0)
{
DisplayProgramHelp();
}
if(argc == 2 && strcmp(argv[1],"-displayhelp") == 0)
{
DisplayProgramHelp();
}
if(argc == 2 && strcmp(argv[1],"--displaycommandhelp") == 0)
{
DisplayProgramHelp();
}
else if (argc == 1)
{
std :: cout << "Your method of using this program is incorrect, please use the" << " /help " << "command to view the manual." << endl;
std :: cout << "你的使用本程序的方法不正确,请使用" << " /help " << "命令查看手册。" << endl;
system("Pause");
return 0;
}
return 0;
}