forked from aria81g/ReverseTlsTunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRtTunnel.sh
123 lines (105 loc) · 3.16 KB
/
RtTunnel.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
#!/bin/bash
# Function to check if wget is installed, and install it if not
check_dependencies() {
if ! command -v wget &> /dev/null; then
echo "wget is not installed. Installing..."
sudo apt-get install wget
fi
}
#Check installed service
check_installed() {
if [ -f "/etc/systemd/system/tunnel.service" ]; then
echo "The service is already installed."
exit 1
fi
}
# Function to download and install RTT
install_rtt() {
wget "https://raw.githubusercontent.com/radkesvat/ReverseTlsTunnel/master/install.sh" -O install.sh && chmod +x install.sh && bash install.sh
}
# Function to configure arguments based on user's choice
configure_arguments() {
read -p "Which server do you want to use? (Enter '1' for Iran or '2' for Kharej) : " server_choice
read -p "Please Enter SNI (default : splus.ir): " sni
sni=${sni:-splus.ir}
if [ "$server_choice" == "2" ]; then
read -p "Please Enter (IRAN IP) : " server_ip
read -p "Please Enter Password (Please choose the same password on both servers): " password
arguments="--kharej --iran-ip:$server_ip --iran-port:443 --toip:127.0.0.1 --toport:multiport --password:$password --sni:$sni --terminate:24"
elif [ "$server_choice" == "1" ]; then
read -p "Please Enter Password (Please choose the same password on both servers): " password
arguments="--iran --lport:442-65535 --sni:$sni --password:$password --terminate:24"
else
echo "Invalid choice. Please enter '1' or '2'."
exit 1
fi
}
# Function to handle installation
install() {
check_dependencies
check_installed
install_rtt
# Change directory to /etc/systemd/system
cd /etc/systemd/system
configure_arguments
# Create a new service file named tunnel.service
cat <<EOL > tunnel.service
[Unit]
Description=my tunnel service
[Service]
User=root
WorkingDirectory=/root
ExecStart=/root/RTT $arguments
Restart=always
[Install]
WantedBy=multi-user.target
EOL
# Reload systemctl daemon and start the service
sudo systemctl daemon-reload
sudo systemctl start tunnel.service
sudo systemctl enable tunnel.service
}
# Function to handle uninstallation
uninstall() {
# Check if the service is installed
if [ ! -f "/etc/systemd/system/tunnel.service" ]; then
echo "The service is not installed."
return
fi
# Stop and disable the service
sudo systemctl stop tunnel.service
sudo systemctl disable tunnel.service
# Remove service file
sudo rm /etc/systemd/system/tunnel.service
sudo systemctl reset-failed
sudo rm RTT
sudo rm install.sh
echo "Uninstallation completed successfully."
}
#ip
myip=$(hostname -I | awk '{print $1}')
# Main menu
clear
echo "By --> Peyman * Github.com/Ptechgithub * "
echo "Your IP is: ($myip) "
echo ""
echo " --------#- Reverse Tls Tunnel -#--------"
echo "1) Install"
echo "2) Uninstall"
echo "0) Exit"
echo " ----------------------------------------"
read -p "Please choose: " choice
case $choice in
1)
install
;;
2)
uninstall
;;
0)
exit
;;
*)
echo "Invalid choice. Please try again."
;;
esac