-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheggdrop_botnet_linking.bats
More file actions
386 lines (337 loc) · 15.1 KB
/
eggdrop_botnet_linking.bats
File metadata and controls
386 lines (337 loc) · 15.1 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
@test "Eggdrop setup" {
run cp /tmp/build/tests/eggdrop_botnet_linking* /home/eggdrop/eggdrop/
[ $status -eq 0 ]
run cp /tmp/build/tests/eggdrop_botnet_linking* /home/eggdrop/nossl/
[ $status -eq 0 ]
[ $status -eq 0 ]
run cp /tmp/build/tests/cmd_accept.tcl /home/eggdrop/eggdrop/scripts/
[ $status -eq 0 ]
cp /home/eggdrop/eggdrop/scripts/cmd_accept.tcl /home/eggdrop/eggdrop/scripts/cmd_accept2.tcl
cp /home/eggdrop/eggdrop/scripts/cmd_accept.tcl /home/eggdrop/nossl/scripts/cmd_accept3.tcl
run sed -i 's/45678/56789/g' /home/eggdrop/eggdrop/scripts/cmd_accept2.tcl
run sed -i 's/45678/34567/g' /home/eggdrop/nossl/scripts/cmd_accept3.tcl
[ $status -eq 0 ]
run ./eggdrop eggdrop_botnet_linking1.conf 3>&-
[ $status -eq 0 ]
run ./eggdrop eggdrop_botnet_linking2.conf 3>&-
[ $status -eq 0 ]
cd ../nossl
run ./eggdrop eggdrop_botnet_linking-nossl.conf 3>&-
[ $status -eq 0 ]
### Add bot1 to bot2
run bash -c 'echo "{addbot bot1 localhost:1111}" |nc localhost 56789'
[ "${output}"="0 {1}" ]
### Add bot3 to bot2
run bash -c 'echo "{addbot bot1 localhost:3311}" |nc localhost 56789'
[ "${output}"="0 {1}" ]
### Add bot2 to bot1
run bash -c 'echo "{addbot bot2 localhost:2222}" |nc localhost 45678'
[ "${output}"="0 {1}" ]
### Add bot3 to bot1
run bash -c 'echo "{addbot bot3 localhost:3311}" |nc localhost 45678'
[ "${output}"="0 {1}" ]
### Add bot1 to bot3
run bash -c 'echo "{addbot bot1 localhost:1111}" |nc localhost 34567'
[ "${output}"="0 {1}" ]
### Add bot2 to bot3
run bash -c 'echo "{addbot bot2 localhost:2222}" |nc localhost 34567'
[ "${output}"="0 {1}" ]
}
@test "SSL leaf with (-)dest port connects with SSL to SSL hub listening on (-) all" {
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1111 1111}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (-)dest port connects with SSL to SSL hub listening on (-) bots" {
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1113 1113}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (-)dest port connects with SSL to SSL hub listening on (+) all" {
skip "Failed - read client hellos, no handshake"
echo "{unlink bot1}" |nc localhost 56789
echo "{unlink bot2}" |nc localhost 45678
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1121 1121}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 3; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (-)dest port connects with SSL to SSL hub listening on (+) bots" {
skip "Failed - read client hellos, no handshake"
echo "{unlink bot1}" |nc localhost 56789
echo "{unlink bot2}" |nc localhost 45678
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1123 1123}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port connects with SSL to SSL hub listening on (-) all" {
skip "Failed - ERROR linking bot1: Only users may connect at this port."
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost +1111 +1111}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port connects with SSL to SSL hub listening on (-) bots" {
skip "Failed - No error, hub sees connection but then just fails"
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost +1113 +1113}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port connects with SSL to SSL hub listening on (+) all" {
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost +1121 +1121}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port connects with SSL to SSL hub listening on (+) bots" {
echo "{unlink bot1}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost +1123 +1123}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} == *"TLS: handshake successful. Secure connection established."* ]]
}
@test "Non-SSL leaf with (-)dest port connects without SSL to SSL hub listening on (-) all" {
echo "{unlink bot1}" |nc localhost 34567
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1111 1111}" |nc localhost 34567'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 3311'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "Non-SSL leaf with (-)dest port connects without SSL to SSL hub listening on (-) bots" {
echo "{unlink bot1}" |nc localhost 34567
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1113 1113}" |nc localhost 34567'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 3311'
echo $output
[[ ${output} == *" Linked to bot1"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "Non-SSL leaf with (-)dest port denied connection to SSL hub listening on (+) all" {
skip "Failed - denied, but no error message given"
echo "{unlink bot1}" |nc localhost 34567
sleep 3
run bash -c 'echo "{setuser bot1 botaddr localhost 1121 1121}" |nc localhost 34567'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 3311'
echo $output
[[ ${output} == *"Failed link to bot1."* ]]
}
@test "Non-SSL leaf with (-)dest port denied connection to SSL hub listening on (+) bots" {
skip "Failed - denied connection, but no error message"
echo "{unlink bot1}" |nc localhost 34567
sleep 3
run bash -c 'echo "{status}" |nc localhost 34567'
echo $output
run bash -c 'echo "{setuser bot1 botaddr localhost 1123 1123}" |nc localhost 34567'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 3311'
echo $output
[ 1 -eq 0 ]
[[ ${output} == *"Failed link to bot1."* ]]
}
@test "Non-SSL Eggdrop denies adding hub with (+)dest port " {
skip "Failed - but belongs in botnet_commandline suite"
}
@test "Eggdrop validates +bot/chaddr input" {
skip "Failed - but belongs in botnet_commandline suite"
}
@test "SSL leaf with (-)dest port connects without SSL to non-SSL hub listening on (-) all" {
echo "{unlink bot3}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot3 botaddr localhost 3313 3313}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot3"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot3"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (-)dest port connects without SSL to non-SSL hub listening on (-) bots" {
echo "{unlink bot3}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot3 botaddr localhost 3313 3313}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot3"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot3"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port denies connection to non-SSL hub listening on (-) all" {
skip "Failed - hub returned ERROR linking bot3: Only users may connect at this port."
echo "{unlink bot3}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot3 botaddr localhost +3311 +3311}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot3"; sleep 2; } | telnet localhost 2222'
echo $output
[ 1 -eq 0 ]
[[ ${output} == *" Linked to bot3"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "SSL leaf with (+)dest port denies connection to non-SSL hub listening on (-) bots" {
skip "Failed - denied connection, but no error message"
echo "{unlink bot3}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot3 botaddr localhost +3313 +3313}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot3"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot3"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "Non-SSL leaf with (-)dest port connects to non-SSL hub listening on (-) all" {
skip
echo "{unlink bot3}" |nc localhost 56789
sleep 3
run bash -c 'echo "{setuser bot3 botaddr localhost +3313 +3313}" |nc localhost 56789'
[ ${output}="0 {}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot3"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *" Linked to bot3"* ]]
[[ ${output} != *"TLS: handshake successful. Secure connection established."* ]]
}
@test "Non-SSL leaf with (-)dest port connects to non-SSL hub listening on (-) bots" {
skip
}
@test "SSL-enabled leaf denied linking to hub on - 'user' port" {
sleep 3
### Don't care about return value, in case nothing is linked
echo "{unlink bot1}" |nc localhost 56789
run bash -c 'echo "{setuser bot1 botaddr localhost 1112 1112}" |nc localhost 56789'
echo $output
[ ${output}="0 {}" ]
run bash -c 'echo "{getuser bot1 botaddr}" |nc localhost 56789'
echo $output
[ ${output}="0 {localhost 1112 1112}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".chaddr bot1 localhost 1112 1112"; echo ".whois bot1"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *"ERROR linking bot1: Only users may connect at this port."* ]]
}
@test "SSL-enabled leaf denied linking to hub on + 'user' port" {
skip "Failed - allowed link"
sleep 3
### Don't care about return value, in case nothing is linked
echo "{unlink bot1}" |nc localhost 56789
run bash -c 'echo "{setuser bot1 botaddr localhost +1112 +1112}" |nc localhost 56789'
echo $output
[ ${output}="0 {}" ]
run bash -c 'echo "{getuser bot1 botaddr}" |nc localhost 56789'
echo $output
[ ${output}="0 {localhost +1112 +1112}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".whois bot1"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *"ERROR linking bot1: Only users may connect at this port."* ]]
}
@test "Eggdrop will not attempt link to bot marked with r flag" {
echo "{unlink bot1}" |nc localhost 56789
echo "{setuser bot1 botaddr localhost 1111 1111}" |nc localhost 56789
run bash -c 'echo "{botattr bot2 -grhps}"|nc localhost 45678'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 -grhps}"|nc localhost 56789'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 +r}"|nc localhost 56789'
[ ${output}="0 {r}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *"Rejecting bot bot1"* ]]
}
@test "Bot marked with +r is not allowed to link" {
echo "{unlink bot1}" |nc localhost 56789
run bash -c 'echo "{botattr bot2 -grhps}"|nc localhost 45678'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 -grhps}"|nc localhost 56789'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot2 +r}"|nc localhost 45678'
[ ${output}="0 {r}" ]
run bash -c '{ echo "testuser1"; echo "eggdrop"; echo ".link bot1"; sleep 2; } | telnet localhost 2222'
echo $output
[[ ${output} == *"Lost Bot: bot1"* ]]
}
@test "h flag auto-attempts link to hub" {
skip
kill $(cat pid.eggdrop_botnet_linking2)
run faketime -f '+2,5y x10,0' ./eggdrop eggdrop_botnet_linking2.conf
[ $status -eq 0 ]
echo "{setuser bot1 botaddr localhost 1111 1111}" |nc localhost 56789
echo "{unlink bot1}" |nc localhost 56789
run bash -c 'echo "{botattr bot2 -grhps}"|nc localhost 45678'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 -grhps}"|nc localhost 56789'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 +h}"|nc localhost 56789'
[ ${output}="0 {h}" ]
sleep 3
run bash -c '{ sleep 6; echo "testuser1"; echo "eggdrop"; echo ".bots"; sleep 1; } | telnet localhost 1111'
echo $output
[[ ${output} == *"Bots: bot1, bot2"* ]]
kill $(cat pid.eggdrop_botnet_linking2)
run ./eggdrop eggdrop_botnet_linking2.conf
[ $status -eq 0 ]
}
@test "a flag auto-attempts if hub bot fails" {
kill $(cat pid.eggdrop_botnet_linking2)
run faketime -f '+2,5y x10,0' ./eggdrop eggdrop_botnet_linking2.conf
[ $status -eq 0 ]
echo "{setuser bot3 botaddr localhost 9999 9999}" |nc localhost 56789
echo "{unlink bot1}" |nc localhost 56789
run bash -c 'echo "{botattr bot2 -grahps}"|nc localhost 45678'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot1 -grahps}"|nc localhost 56789'
[ ${output}="0 {-}" ]
run bash -c 'echo "{botattr bot3 +h}"|nc localhost 56789'
[ ${output}="0 {h}" ]
run bash -c 'echo "{botattr bot1 +a}"|nc localhost 56789'
[ ${output}="0 {h}" ]
sleep 3
run bash -c '{ sleep 12; echo "testuser1"; echo "eggdrop"; echo ".bots"; sleep 1; } | telnet localhost 1111'
echo $output
[[ ${output} == *"Bots: bot1, bot2"* ]]
kill $(cat pid.eggdrop_botnet_linking2)
run ./eggdrop eggdrop_botnet_linking2.conf
[ $status -eq 0 ]
}
@test "Kill Eggdrop" {
ps x|grep "[e]ggdrop "
if [ $? -eq 0 ]; then
pkill eggdrop
fi
if [ -e /home/eggdrop/eggdrop/tempuser.user ]; then
rm /home/eggdrop/eggdrop/tempsuer.user
fi
}