-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetStartUp.cpp
More file actions
105 lines (94 loc) · 2.41 KB
/
Copy pathSetStartUp.cpp
File metadata and controls
105 lines (94 loc) · 2.41 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
#include <bits/stdc++.h>
#include <windows.h>
void checkStartUp();
bool ElevatePrivileges();
std::string getPath(bool filename=false);
int main(){
checkStartUp();
if(!ElevatePrivileges()){
printf("Please run in root.");
Sleep(5000);
return 0;
}
std::string cmd = "cmd /k \"reg add HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /v SeewoHelper /t REG_SZ /d \"\\\""+getPath()+"SeewoHelper.exe\\\" /start /background\" /f\"";
std::cout<<"Running: "<<cmd<<std::endl;
Sleep(1000);
printf(".");
Sleep(1000);
printf(".");
Sleep(1000);
printf(".\n");
Sleep(1000);
system(cmd.c_str());
std::ofstream file("StartUpSet.txt");
file<<"110001000010001 110011000101111 1001000000000110 1000011101110110";
file.close();
return 0;
}
void checkStartUp(){
HKEY hKey;
LSTATUS status;
DWORD dwType = REG_SZ;
TCHAR szBuffer[256];
DWORD dwBufferSize = sizeof(szBuffer);
RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_READ, &hKey);
status = RegGetValue(hKey, NULL, TEXT("SeewoHelper"), RRF_RT_REG_SZ, &dwType, szBuffer, &dwBufferSize);
std::wcout << "KEY: " << szBuffer << std::endl;
if(status == ERROR_SUCCESS){
printf("StartUp already set.\n");
std::ofstream file("StartUpSet.txt");
file<<"110001000010001 110011000101111 1001000000000110 1000011101110110";
file.close();
Sleep(5000);
exit(0);
}
}
bool ElevatePrivileges(){
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
return false;
}
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue)) {
CloseHandle(hToken);
return false;
}
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL)) {
CloseHandle(hToken);
return false;
}
if (GetLastError() != ERROR_SUCCESS) {
CloseHandle(hToken);
return false;
}
CloseHandle(hToken);
return true;
}
std::string getPath(bool fileName){
char path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
int end;
for(int i=1; i<MAX_PATH; i++){
if(path[i]=='\0'){
end=i-1;
break;
}
}
if(!fileName){
for(int i=end; i>=0; i--){
if(path[i]=='\\'){
end=i;
break;
}
}
}
std::string strPath="";
for(int i=0; i<=end; i++){
strPath+=path[i];
}
return strPath;
}