forked from malwares/Botnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuntThreads.pas
More file actions
272 lines (241 loc) · 7.75 KB
/
Copy pathuntThreads.pas
File metadata and controls
272 lines (241 loc) · 7.75 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
unit untThreads;
interface
uses
windows,
untFunctions,
untGlobalDeclare;
const
max_threads = 500;
thread_syn = 1;
thread_scan = 2;
thread_other = 3;
type
tthreadtype = record
threadhandle :thandle;
threadtype :integer;
threadname :string;
end;
var
otherhandle :array[0..max_threads] of tthreadtype;
threadhandle :array[0..max_threads] of tthreadtype;
threadcount :integer;
function thread_start(intthreads, inttype: integer; name: string; pproc, pparam: pointer; endallother: boolean): integer;
function thread_stop(intthreads, inttype: integer; threadname: string): integer;
function thread_info: string;
function thread_allinfo: string;
function thread_exist(handle: thandle; name: string): boolean;
function thread_stophandle(handle: thandle): integer;
function thread_stopname(name: string): integer;
implementation
function thread_exist(handle: thandle; name: string): boolean;
var
iloop :integer;
begin
result := false;
for iloop := 0 to max_threads -1 do
if handle > 0 then
begin
if (otherhandle[iloop].threadhandle = handle) or
(otherhandle[iloop].threadname = name) or
(threadhandle[iloop].threadhandle = handle) or
(threadhandle[iloop].threadname = name) then
begin
result := true;
break;
end;
end else
begin
if (otherhandle[iloop].threadname = name) or
(threadhandle[iloop].threadname = name) then
begin
result := true;
break;
end;
end;
end;
function thread_allinfo: string;
var
iloop :integer;
begin
result := '[threads] ';
for iloop := 0 to max_threads -1 do
if otherhandle[iloop].threadhandle > 0 then
result := result + otherhandle[iloop].threadname+'['+inttostr(otherhandle[iloop].threadhandle)+'] ';
delete(result, length(result), 1);
end;
function thread_info: string;
var
scanner_thread :integer;
attack_thread :integer;
other_thread :integer;
iloop :integer;
begin
scanner_thread := 0;
attack_thread := 0;
other_thread := 0;
for iloop := 0 to max_threads -1 do
begin
if otherhandle[iloop].threadhandle > 0 then
inc(other_thread);
if threadhandle[iloop].threadhandle > 0 then
if threadhandle[iloop].threadtype = 1 then
inc(attack_thread)
else if threadhandle[iloop].threadtype = 2 then
inc(scanner_thread);
end;
result := '[threads] ' +
inttostr(scanner_thread) + ' scanner thread(s). ' +
inttostr(attack_thread) + ' syn attack thread(s). ' +
inttostr(other_thread) + ' other thread(s).';
end;
function thread_stopname(name: string): integer;
var
iloop :integer;
exitcode :cardinal;
temphandle :cardinal;
begin
result := 0;
for iloop := 0 to max_threads -1 do
if (threadhandle[iloop].threadname = name) then
begin
temphandle := threadhandle[iloop].threadhandle;
threadhandle[iloop].threadhandle := 0;
threadhandle[iloop].threadtype := 0;
threadhandle[iloop].threadname := '';
getexitcodethread(temphandle, exitcode);
if terminatethread(temphandle, exitcode) then
begin
inc(result);
dec(threadcount);
end;
closehandle(temphandle);
end else
if (otherhandle[iloop].threadname = name) then
begin
temphandle := otherhandle[iloop].threadhandle;
otherhandle[iloop].threadhandle := 0;
otherhandle[iloop].threadtype := 0;
otherhandle[iloop].threadname := '';
getexitcodethread(temphandle, exitcode);
if terminatethread(temphandle, exitcode) then
begin
inc(result);
dec(threadcount);
end;
closehandle(temphandle);
end;
if threadcount < 0 then threadcount := 0;
end;
function thread_stophandle(handle: thandle): integer;
var
iloop :integer;
exitcode :cardinal;
begin
result := 0;
for iloop := 0 to max_threads -1 do
if (threadhandle[iloop].threadhandle = handle) then
begin
getexitcodethread(threadhandle[iloop].threadhandle, exitcode);
if terminatethread(threadhandle[iloop].threadhandle, exitcode) then
begin
inc(result);
dec(threadcount);
end;
closehandle(threadhandle[iloop].threadhandle);
threadhandle[iloop].threadhandle := 0;
threadhandle[iloop].threadtype := 0;
threadhandle[iloop].threadname := '';
end else
if (otherhandle[iloop].threadhandle = handle) then
begin
getexitcodethread(otherhandle[iloop].threadhandle, exitcode);
if terminatethread(otherhandle[iloop].threadhandle, exitcode) then
begin
inc(result);
dec(threadcount);
end;
closehandle(otherhandle[iloop].threadhandle);
otherhandle[iloop].threadhandle := 0;
otherhandle[iloop].threadtype := 0;
otherhandle[iloop].threadname := '';
end;
if threadcount < 0 then threadcount := 0;
end;
function thread_stop(intthreads, inttype: integer; threadname: string): integer;
var
iloop :integer;
exitcode :cardinal;
begin
result := 0;
for iloop := 0 to intthreads -1 do
if (threadhandle[iloop].threadhandle > 0) and
((inttype = 0) or (threadhandle[iloop].threadtype = inttype) or
(threadhandle[iloop].threadname = threadname)) then
begin
getexitcodethread(threadhandle[iloop].threadhandle, exitcode);
if terminatethread(threadhandle[iloop].threadhandle, exitcode) then
begin
inc(result);
dec(threadcount);
end;
closehandle(threadhandle[iloop].threadhandle);
threadhandle[iloop].threadhandle := 0;
threadhandle[iloop].threadtype := 0;
threadhandle[iloop].threadname := '';
end;
if threadcount < 0 then threadcount := 0;
end;
function thread_start(intthreads, inttype: integer; name: string; pproc, pparam: pointer; endallother: boolean): integer;
var
iloop :integer;
jloop :integer;
threadid :dword;
exitcode :cardinal;
begin
if endallother then
thread_stop(max_threads, inttype, name);
result := 0;
for iloop := 0 to intthreads -1 do
for jloop := 0 to max_threads -1 do
if inttype = 3 then
begin
if otherhandle[jloop].threadhandle = 0 then
begin
otherhandle[jloop].threadhandle := createthread(nil, 0, pproc, pparam, 0, threadid);
if otherhandle[jloop].threadhandle > 0 then
begin
otherhandle[jloop].threadtype := inttype;
otherhandle[jloop].threadname := name;
inc(result);
inc(threadcount);
break;
end else
begin
getexitcodethread(otherhandle[jloop].threadhandle, exitcode);
if terminatethread(otherhandle[jloop].threadhandle, exitcode) then
otherhandle[jloop].threadhandle := 0;
end;
end;
end else
begin
if threadhandle[jloop].threadhandle = 0 then
begin
threadhandle[jloop].threadhandle := createthread(nil, 0, pproc, pparam, 0, threadid);
if threadhandle[jloop].threadhandle > 0 then
begin
threadhandle[jloop].threadtype := inttype;
threadhandle[jloop].threadname := name;
inc(result);
inc(threadcount);
break;
end else
begin
getexitcodethread(threadhandle[jloop].threadhandle, exitcode);
if terminatethread(threadhandle[jloop].threadhandle, exitcode) then
threadhandle[jloop].threadhandle := 0;
end;
end;
end;
if threadcount < 0 then threadcount := 0;
end;
end.