forked from Weera1234/DNS-AGN
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslowdns-ssh
292 lines (292 loc) · 8.84 KB
/
slowdns-ssh
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
#!/bin/bash
clear
fun_bar () {
comando[0]="$1"
comando[1]="$2"
(
[[ -e $HOME/fim ]] && rm $HOME/fim
${comando[0]} -y > /dev/null 2>&1
${comando[1]} -y > /dev/null 2>&1
touch $HOME/fim
) > /dev/null 2>&1 &
tput civis
echo -ne " \033[1;33mWAIT \033[1;37m- \033[1;33m["
while true; do
for((i=0; i<18; i++)); do
echo -ne "\033[1;31m#"
sleep 0.1s
done
[[ -e $HOME/fim ]] && rm $HOME/fim && break
echo -e "\033[1;33m]"
sleep 1s
tput cuu1
tput dl1
echo -ne " \033[1;33mWAIT \033[1;37m- \033[1;33m["
done
echo -e "\033[1;33m]\033[1;37m -\033[1;32m OK !\033[1;37m"
tput cnorm
}
echo -e "\033[1;31m════════════════════════════════════════════════════\033[0m"
tput setaf 7 ; tput setab 4 ; tput bold ; printf '%40s%s%-12s\n' "INSTALLING SLOW DNS SSH" ; tput sgr0
echo -e "\033[1;31m════════════════════════════════════════════════════\033[0m"
echo -e ""
echo -e " This script will install the"
echo -e " slowdns for DNS tunneling with SSH."
echo -e ""
echo -e " \033[1;33mInstaller made by @Laael and Modded/Translated by @KhaledAGN ❤️ \033[1;37m"
echo -e ""
echo -e "\033[1;31m════════════════════════════════════════════════════\033[0m"
echo ""
echo -e "UPDATING PACKAGE LIST..."
fun_att () {
apt update && apt upgrade -y
}
fun_bar 'fun_att'
echo -e "INSTALLING AND UPDATING NECESSARY PACKAGES..."
install_pkgs () {
apt install screen -y
apt install cron -y
apt install iptables -y
service cron reload
service cron restart
service iptables reload
service iptables restart
}
fun_bar 'install_pkgs'
echo -e "CONFIGURING IPTABLES..."
ipt_set () {
cd /etc
mv rc.local rc.local.bkp
wget https://github.com/khaledagn/SlowDNS/raw/main/rc.local
chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local
}
fun_bar 'ipt_set'
clear
echo ""
echo -e "\033[1;31m ATTENTION IN THIS STAGE! \033[1;33m"
echo ""
echo -ne "\033[1;32m ENTER YOUR NS (NAMESERVER)\033[1;37m: "; read nameserver
cd /etc/slowdns
touch infons
echo $nameserver > infons
set_ns () {
sleep 1
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/ssh/startdns
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/ssh/restartdns
chmod +x startdns
chmod +x restartdns
sed -i "s;1234;$nameserver;g" /etc/slowdns/startdns > /dev/null 2>&1
sed -i "s;1234;$nameserver;g" /etc/slowdns/restartdns > /dev/null 2>&1
cp startdns /bin/
cp restartdns /bin/
}
fun_bar 'set_ns'
echo ""
echo "Checking for existence of key"
sleep 2
echo ""
echo " Please wait... "
sleep 2
cd
key1="/root/server.key"
key2="/root/server.pub"
if [ -f $key1 ] && [ -f $key2 ]
then
echo -e "Key file found!"
sleep 1
echo ""
key () {
echo "How do you want to get your key?"
echo ""
echo "[ 1 ] | Use existing key in file"
echo "[ 2 ] | Delete file and generate new key"
echo "[ 3 ] | Delete file and use default key"
echo "[ x ] | Abort installation"
echo ""
echo -ne "Enter an option: " && read option
case $option in
1) Option1 ;;
2) Option2 ;;
3) Option3 ;;
x) OptionX ;;
*) "Unknown command" ; echo ; key;;
esac
}
Option1 () {
echo -ne "Restoring existing key..." && sleep 2 && echo "OK!"
echo ""
echo -e "FINISHING..."
finish_ist () {
cd /etc/slowdns
iptables -I INPUT -p udp --dport 5300 -j ACCEPT
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 5300
./startdns
}
fun_bar 'finish_ist'
clear
echo -e "\033[1;31m INSTALLATION COMPLETED!\033[0m"
echo ""
echo -ne "\033[1;33mYOUR NS:\033[0m " && cat /etc/slowdns/infons
echo ""
echo -ne "\033[1;33mYOUR PUBLIC KEY:\033[0m " && cat /root/server.pub
echo ""
echo -ne "\033[1;33mTERMUX COMMAND:\033[0m curl -sO https://github.com/khaledagn/DNS-AGN/raw/main/files/slowdns && chmod +x slowdns && ./slowdns " && cat /etc/slowdns/infons /root/server.pub
echo ""
echo -e "\033[1;33m YOUR KEY is saved in the file /root/server.pub\033[0m"
echo -e "\033[1;33mKeep it in a safe place, you may need it in the future!\033[0m"
echo ""
read -p "Press [Enter] to return to the menu or CTRL+C to exit"
slowdns
}
Option2 () {
cd
rm server.key server.pub
echo "Generating new key"
cd /etc/slowdns/
./dns-server -gen-key -privkey-file /root/server.key -pubkey-file /root/server.pub
echo -e "FINISHING..."
finish_ist () {
iptables -I INPUT -p udp --dport 5300 -j ACCEPT
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 5300
./startdns
cd
}
fun_bar 'finish_ist'
clear
echo -e "\033[1;31m INSTALLATION COMPLETED!\033[0m"
echo ""
echo -ne "\033[1;33mYOUR NS:\033[0m " && cat /etc/slowdns/infons
echo ""
echo -ne "\033[1;33mYOUR PUBLIC KEY:\033[0m " && cat /root/server.pub
echo ""
echo -ne "\033[1;33mTERMUX COMMAND:\033[0m curl -sO https://github.com/khaledagn/DNS-AGN/raw/main/files/slowdns && chmod +x slowdns && ./slowdns " && cat /etc/slowdns/infons /root/server.pub
echo ""
echo -e "\033[1;33m YOUR KEY is saved in the file /root/server.pub\033[0m"
echo -e "\033[1;33mKeep it in a safe place, you may need it in the future!\033[0m"
echo ""
read -p "Press [Enter] to return to the menu or CTRL+C to exit"
slowdns
}
Option3 () {
echo -e "Downloading default key pair..."
cd
rm server.key server.pub
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/server.key
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/server.pub
sleep 1
echo -e "Download Completed"
sleep 1
cd /etc/slowdns/
echo -e "FINISHING..."
finish_ist () {
iptables -I INPUT -p udp --dport 5300 -j ACCEPT
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 5300
./startdns
cd
}
fun_bar 'finish_ist'
clear
echo -e "\033[1;31m INSTALLATION COMPLETED!\033[0m"
echo ""
echo -ne "\033[1;33mYOUR NS:\033[0m " && cat /etc/slowdns/infons
echo ""
echo -ne "\033[1;33mSUA KEY:\033[0m " && cat /root/server.pub
echo ""
echo -ne "\033[1;33mTERMUX COMMAND:\033[0m curl -sO https://github.com/khaledagn/DNS-AGN/raw/main/files/slowdns && chmod +x slowdns && ./slowdns " && cat /etc/slowdns/infons /root/server.pub
echo ""
echo -e "\033[1;33m YOUR KEY is saved in the file /root/server.pub\033[0m"
echo -e "\033[1;33mKeep it in a safe place, you may need it in the future!\033[0m"
echo ""
read -p "Press [Enter] to return to the menu or CTRL+C to exit"
slowdns
}
OptionX () {
exit
}
key
else
echo -e "There is no key in the logs"
echo ""
key_gen () {
echo "How do you want to get your key?"
echo ""
echo "[ 1 ] | Generate on installation"
echo "[ 2 ] | Use the default key"
echo "[ x ] | Abort installation"
echo ""
echo -ne "Enter an option: " && read opc_key
case $opc_key in
1) opc_key1 ;;
2) opc_key2 ;;
x) opc_keyx ;;
*) "Unknown command" ; echo ; key_gen;;
esac
}
opc_key1 () {
echo "Generating your key..."
cd /etc/slowdns/
./dns-server -gen-key -privkey-file /root/server.key -pubkey-file /root/server.pub
echo -e "FINISHING..."
finish_ist () {
iptables -I INPUT -p udp --dport 5300 -j ACCEPT
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 5300
./startdns
cd
}
fun_bar 'finish_ist'
clear
echo -e "\033[1;31m INSTALLATION COMPLETED!\033[0m"
echo ""
echo -ne "\033[1;33mYOUR NS:\033[0m " && cat /etc/slowdns/infons
echo ""
echo -ne "\033[1;33mYOUR PUBLIC KEY:\033[0m " && cat /root/server.pub
echo ""
echo -ne "\033[1;33mTERMUX COMMAND:\033[0m curl -sO https://github.com/khaledagn/DNS-AGN/raw/main/files/slowdns && chmod +x slowdns && ./slowdns " && cat /etc/slowdns/infons /root/server.pub
echo ""
echo -e "\033[1;33m YOUR KEY is saved in the file /root/server.pub\033[0m"
echo -e "\033[1;33mKeep it in a safe place, you may need it in the future!\033[0m"
echo ""
read -p "Press [Enter] to return to the menu or CTRL+C to exit"
slowdns
}
opc_key2 () {
echo -e "Downloading default key pair..."
cd
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/server.key
wget https://raw.githubusercontent.com/khaledagn/DNS-AGN/main/server.pub
sleep 1
echo -e "Download Completed"
sleep 1
cd /etc/slowdns/
echo -e "FINISHING..."
finish_ist () {
iptables -I INPUT -p udp --dport 5300 -j ACCEPT
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 5300
./startdns
cd
}
fun_bar 'finish_ist'
clear
echo -e "\033[1;31m INSTALLATION COMPLETED!\033[0m"
echo ""
echo -ne "\033[1;33mYOUR NS:\033[0m " && cat /etc/slowdns/infons
echo ""
echo -ne "\033[1;33mYOUR PUBLIC KEY:\033[0m " && cat /root/server.pub
echo ""
echo -ne "\033[1;33mTERMUX COMMAND:\033[0m curl -sO https://github.com/khaledagn/DNS-AGN/raw/main/files/slowdns && chmod +x slowdns && ./slowdns " && cat /etc/slowdns/infons /root/server.pub
echo ""
echo -e "\033[1;33m YOUR KEY is saved in the file /root/server.pub\033[0m"
echo -e "\033[1;33mKeep it in a safe place, you may need it in the future!\033[0m"
echo ""
read -p "Press [Enter] to return to the menu or CTRL+C to exit"
slowdns
}
opc_keyx () {
echo "Aborting installation"
sleep 2
slowdns
}
key_gen
fi