-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheggdrop_tcl_addbot.bats
210 lines (184 loc) · 8.87 KB
/
eggdrop_tcl_addbot.bats
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
@test "Eggdrop setup" {
run cp $WORK_DIR/tests/eggdrop_tcl_addbot* $HOME/eggdrop/
[ $status -eq 0 ]
run cp $WORK_DIR/tests/eggdrop_botnet_partyline-noipv6* $HOME/noipv6/
[ $status -eq 0 ]
run cp $WORK_DIR/tests/cmd_accept.tcl $HOME/eggdrop/scripts/
[ $status -eq 0 ]
cp $WORK_DIR/tests/cmd_accept.tcl $HOME/noipv6/scripts/cmd_accept4.tcl
run sed -i 's/45678/54321/g' $HOME/noipv6/scripts/cmd_accept4.tcl
[ $status -eq 0 ]
cd $HOME/eggdrop
run ./eggdrop -m eggdrop_tcl_addbot.conf
[ $status -eq 0 ]
cd $HOME/noipv6
run ./eggdrop eggdrop_botnet_partyline-noipv6.conf
echo $output
[ $status -eq 0 ]
}
@test "addbot adds bot record in 'addbot handle ipv4address' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot 1.1.1.1}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {1.1.1.1 3333 3333}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv6address' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 3333 3333}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv4address botport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot 1.1.1.1 5555}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {1.1.1.1 5555 5555}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv6address botport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5 6666}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 6666 6666}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv4 address botport userport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot 1.1.1.1 5555 6666}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {1.1.1.1 5555 6666}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv6 address botport userport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5 6666 7777}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 6666 7777}"* ]]
}
@test "addbot adds bot record in 'addbot handle ipv4address:botport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot 1.1.1.1:4444}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {1.1.1.1 4444 4444}"* ]]
}
#@test "addbot adds bot record in 'addbot handle ipv4address/botport' format" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot 1.1.1.1/4444}" |nc localhost 45678'
# [[ "${output}" == *"0 {1}"* ]]
# run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
# [[ "${output}" == *"0 {1.1.1.1 4444 4444}"* ]]
#}
#@test "addbot adds bot record in 'addbot handle ipv6address/botport' format" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5/4444}" |nc localhost 45678'
# [[ "${output}" == *"0 {1}"* ]]
# run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
# [[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 4444}"* ]]
#}
#@test "addbot adds bot record in 'addbot handle ipv4address/botport/userport' format" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot 1.1.1.1/4444/5555}" |nc localhost 45678'
# [[ "${output}" == *"0 {1}"* ]]
# run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
# [[ "${output}" == *"0 {1.1.1.1 4444 5555}"* ]]
#}
#@test "addbot adds bot record in 'addbot handle ipv6address/botport/userport' format" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5/4444/5555}" |nc localhost 45678'
# [[ "${output}" == *"0 {1}"* ]]
# run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
# [[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 5555}"* ]]
#}
#@test "addbot rejects bot record in 'addbot handle ipaddress botport' format" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot 1.1.1.1 5555}" |nc localhost 45678'
# [[ "${output}" == *"1 {wrong # args: should be \"addbot handle address\"}"* ]]
#}
@test "addbot ignores additional arguments if address arg uses :s" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot 1.1.1.1:4444/5555 6666}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {1.1.1.1 4444 5555}"* ]]
}
@test "addbot allows bot record in 'addbot handle \[ipv6address\]:botport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot \[fe80::69ec:cfe4:81de:4fe5\]:4444}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 4444}"* ]]
}
@test "addbot allows bot record in 'addbot handle \[ipv6address\]:botport/userport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot \[fe80::69ec:cfe4:81de:4fe5\]:4444/5555}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 5555}"* ]]
}
@test "addbot allows bot record in 'addbot handle \[ipv6address\] botport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot \[fe80::69ec:cfe4:81de:4fe5\] 4444}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 4444}"* ]]
}
@test "addbot allows bot record in 'addbot handle \[ipv6address\] botport userport' format" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot \[fe80::69ec:cfe4:81de:4fe5\] 4444 5555}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 4444 5555}"* ]]
}
@test "addbot allows bot record in 'addbot handle ipv6address/' format with default ports" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5/}" |nc localhost 45678'
[[ "${output}" == *"0 {1}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 3333 3333}"* ]]
}
@test "reject ipv4 with braces" {
echo "{deluser testbot}" |nc localhost 45678
run bash -c 'echo "{addbot testbot \[1.1.1.1\] |nc localhost 45678'
}
@test "Non-IPv6 bot rejects IPv6 address" {
echo "{deluser testbot}" |nc localhost 54321
run bash -c 'echo "{addbot testbot fe80::69ec:cfe4:81de:4fe5}" |nc localhost 54321'
[[ "${output}" == *"0 {0}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"1 {No such user.}"* ]]
}
@test "Non-SSL Eggdrop rejects TLS port" {
skip
}
@test "addbot rejects port < 1" {
run bash -c 'echo "{addbot testbot 1.1.1.1 0}" |nc localhost 54321'
[[ "${output}" == *"0 {0}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"1 {No such user.}"* ]]
}
@test "Eggdrop rejects port > 65565" {
run bash -c 'echo "{addbot testbot 1.1.1.1 65536}" |nc localhost 54321'
[[ "${output}" == *"0 {0}"* ]]
run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
[[ "${output}" == *"1 {No such user.}"* ]]
}
#@test "Eggdrop rejects >5 addbot arguments" {
# echo "{deluser testbot}" |nc localhost 45678
# run bash -c 'echo "{addbot testbot 1.1.1.1 3333 4444 5555}" |nc localhost 45678'
# [[ "${output}" == *"1 {wrong # args: should be "addbot handle address ?telnet-port ?relay-port??"}"* ]]
# run bash -c 'echo "{getuser testbot botaddr}" |nc localhost 45678'
# [[ "${output}" == *"0 {fe80::69ec:cfe4:81de:4fe5 3333 3333}"* ]]
#}
@test "Kill Eggdrop" {
ps x|grep "[e]ggdrop "
if [ $? -eq 0 ]; then
pkill eggdrop
fi
if [ -e $HOME/eggdrop/tempuser.user ]; then
rm $HOME/eggdrop/tempsuer.user
fi
}