-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathRTT-Tunnel-Helper.sh
177 lines (150 loc) · 4.25 KB
/
RTT-Tunnel-Helper.sh
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
#!/bin/bash -e
echo
echo "=== azadrah.org ==="
echo "=== https://github.com/azadrahorg ==="
echo "=== RTT-Tunnel-Helper ==="
echo
sleep 1
function exit_badly {
echo "$1"
exit 1
}
error() {
echo -e " \n $red Something Bad Happen $none \n "
}
if [ "$EUID" -ne 0 ]
then echo "Please run as root."
exit
fi
if pgrep -x "RTT" > /dev/null; then
echo "Tunnel is running!. you must stop the tunnel before update. (pkill RTT)"
echo "Kiling RTT..."
sleep 5
pkill RTT
echo "Done"
fi
DISTRO="$(awk -F= '/^NAME/{print tolower($2)}' /etc/os-release|awk 'gsub(/[" ]/,x) + 1')"
DISTROVER="$(awk -F= '/^VERSION_ID/{print tolower($2)}' /etc/os-release|awk 'gsub(/[" ]/,x) + 1')"
valid_os()
{
case "$DISTRO" in
"debiangnu/linux"|"ubuntu")
return 0;;
*)
echo "OS $DISTRO is not supported"
return 1;;
esac
}
if ! valid_os "$DISTRO"; then
echo "Bye."
exit 1
else
[[ $(id -u) -eq 0 ]] || exit_badly "Please re-run as root (e.g. sudo ./path/to/this/script)"
fi
update_os() {
apt-get -o Acquire::ForceIPv4=true update
apt-get -o Acquire::ForceIPv4=true install -y software-properties-common
add-apt-repository --yes universe
add-apt-repository --yes restricted
add-apt-repository --yes multiverse
apt-get -o Acquire::ForceIPv4=true install -y moreutils dnsutils tmux screen nano wget curl socat jq qrencode unzip lsof
}
rtt_instller() {
case $(uname -m) in
x86_64) URL="https://github.com/radkesvat/ReverseTlsTunnel/releases/download/V5.0/v5.0_linux_amd64.zip" ;;
arm) URL="https://github.com/radkesvat/ReverseTlsTunnel/releases/download/V5.0/v5.0_linux_arm64.zip" ;;
aarch64) URL="https://github.com/radkesvat/ReverseTlsTunnel/releases/download/V5.0/v5.0_linux_arm64.zip" ;;
*) echo "Unable to determine system architecture."; exit 1 ;;
esac
wget $URL -O v5.0_linux_amd64.zip
unzip -o v5.0_linux_amd64.zip
chmod +x RTT
rm v5.0_linux_amd64.zip
mkdir /usr/local/bin/rtt
mv RTT /usr/local/bin/rtt
}
CHS=3
IRIP=$(dig -4 +short myip.opendns.com @resolver1.opendns.com)
EXIP=0.0.0.0
IRPORT=23-65535
IRPORTTT=443
TOIP=127.0.0.1
TOPORT=multiport
iranserver() {
cat >/etc/systemd/system/tunnel.service <<-EOF
[Unit]
Description=Reverse TLS Tunnel
[Service]
Type=idle
User=root
WorkingDirectory=/usr/local/bin/rtt
ExecStart=/usr/local/bin/rtt/RTT --iran --lport:$IRPORT --sni:$SNI --password:$TOPASS
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl --now enable tunnel.service
systemctl start tunnel.service
}
externalserver() {
cat >/etc/systemd/system/tunnel.service <<-EOF
[Unit]
Description=Reverse TLS Tunnel
[Service]
Type=idle
User=root
WorkingDirectory=/usr/local/bin/rtt
ExecStart=/usr/local/bin/rtt/RTT --kharej --iran-ip:$EXIP --iran-port:$IRPORTTT --toip:$TOIP --toport:$TOPORT --password:$TOPASS --sni:$SNI --terminate:$TERM
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl --now enable tunnel.service
systemctl start tunnel.service
}
echo "Select Server Location:"
echo "1.Iran(Internal)"
echo "2.kharej(External)"
echo "3.Exit"
read -r -p "Select Number(Default is: 3):" CHS
case $CHS in
1) echo "Be carefull SSH port must under 23"
echo "Multiport is activated all ports above 22 were forwarded"
read -r -p "RTT PASS(Default is: zzazza@@@zzazza): " TOPASS
TOPASS=${TOPASS:-"zzazza@@@zzazza"}
read -r -p "RTT SNI(Default is: parsianhospital.com): " SNI
SNI=${SNI:-"parsianhospital.com"}
read -r -p "RTT Restart Time(Default is: 24): " TERM
TERM=${TERM:-"24"}
sleep 3
update_os
rtt_instller
iranserver
echo
echo "=== Finished ==="
echo
sleep 3
exit ;;
2) echo "Be carefull SSH port must under 23"
echo "Multiport is activated all ports above 22 were forwarded"
read -r -p "RTT IP(Enter Iran IP): " EXIP
read -r -p "RTT PASS(Default is: zzazza@@@zzazza): " TOPASS
TOPASS=${TOPASS:-"zzazza@@@zzazza"}
read -r -p "RTT SNI(Default is: parsianhospital.com): " SNI
SNI=${SNI:-"parsianhospital.com"}
read -r -p "RTT Restart Time(Default is: 24): " TERM
TERM=${TERM:-"24"}
sleep 3
update_os
rtt_instller
externalserver
echo
echo "=== Finished ==="
echo
sleep 3
exit ;;
3) exit_badly ;;
*) echo "Done."; exit 1 ;;
esac