-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
77 lines (60 loc) · 1.63 KB
/
Source.cpp
File metadata and controls
77 lines (60 loc) · 1.63 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
#include <windows.h>
#include <iostream>
#include "Source.h"
#include <string>
using namespace std;
int main() {
ShowWindow(GetConsoleWindow(), SW_HIDE);
char buffer[MAX_PATH];
DWORD length = GetCurrentDirectoryA(MAX_PATH, buffer);
if (length < 0 || length > MAX_PATH) {
MessageBoxA(NULL, "No se pudo encontrar el directorio actual", "ERROR", NULL);
return 1;
}
cout << "[+] Directorio actual: " << buffer << endl;
strcat_s(buffer, "\\AppData");
SetEnvironmentVariableA("APPDATA", buffer);
char filePath[MAX_PATH];
DWORD filePathSize = GetModuleFileNameA(NULL, filePath, MAX_PATH);
if (filePathSize == 0 || filePathSize >= MAX_PATH) {
MessageBoxA(NULL, "No se pudo obtener el nombre del archivo", "ERROR", NULL);
return 1;
}
cout << "[+] Verificando nombre del archivo" << endl;
string fileName = filePath;
size_t lastSlash = fileName.find_last_of("\\/");
if (lastSlash != string::npos) {
fileName = fileName.substr(lastSlash + 1);
}
size_t launcherPos = fileName.find("_launcher");
if (launcherPos != string::npos) {
fileName = fileName.substr(0, launcherPos);
}
else {
MessageBoxA(NULL, "El nombre del archivo no contiene '_launcher'", "ERROR", NULL);
return 1;
}
fileName += ".exe";
cout << "[+] Intentando iniciar: " << fileName << endl;
STARTUPINFOA si = { sizeof(si)};
PROCESS_INFORMATION pi;
int processCreated = CreateProcessA(
fileName.c_str(),
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi
);
if (processCreated == 0) {
MessageBoxA(NULL, "No se pudo iniciar el proceso", "ERROR", NULL);
return 1;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}