-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.sh
160 lines (160 loc) · 4.39 KB
/
connect.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
#!/bin/bash
### By Kelvyn Rodrigues <3
# _ __ _ ____ _ _
#| |/ /___| |_ ___ _ _ __ | _ \ ___ __| |_ __(_) __ _ _ _ ___ ___
#| ' // _ \ \ \ / / | | | '_ \ | |_) / _ \ / _` | '__| |/ _` | | | |/ _ \/ __|
#| . \ __/ |\ V /| |_| | | | | | _ < (_) | (_| | | | | (_| | |_| | __/\__ \
#|_|\_\___|_| \_/ \__, |_| |_| |_| \_\___/ \__,_|_| |_|\__, |\__,_|\___||___/
# |___/ |___/
#
path_htb="$HOME/.connect/path_htb.txt"
path_sp="$HOME/.connect/path_sp.txt"
path_thm="$HOME/.connect/path_thm.txt"
path_release_arena="$HOME/.connect/path_release_arena.txt"
case "$1" in # Checking options
-h | --htb)
if [[ -e $path_htb ]] # Checking file to connect in the VPN
then
cat $path_htb | sh # Executing the file that contain the command
else
read -p "Path of your HackTheBox VPN file: " path
if [[ -e ~/.connect ]]
then
echo "Connecting..."
else
mkdir ~/.connect
fi
echo "sudo openvpn $path" > $path_htb
cat $path_htb | sh
fi
exit 0
;;
-s | --start)
if [[ -e $path_sp ]]
then
cat $path_sp | sh
else
read -p "Path of your StartPoint VPN file: " path
if [[ -e ~/.connect ]]
then
echo "Connecting..."
else
mkdir ~/.connect
fi
echo "sudo openvpn $path" > $path_sp
cat $path_sp | sh
fi
exit 0
;;
-t | --thm)
if [[ -e $path_thm ]]
then
cat $path_thm | sh
else
read -p "Path of your TryHackMe VPN file: " path
if [[ -e ~/.connect ]]
then
echo "Connecting..."
else
mkdir ~/.connect
fi
echo "sudo openvpn $path" > $path_thm
cat $path_thm | sh
fi
exit 0
;;
-r | --release-arena)
if [[ -e $path_release_arena ]]
then
cat $path_release_arena | sh
else
read -p "Path of your ReleaseArenaHTB VPN file: " path
if [[ -e ~/.connect ]]
then
echo "Connecting..."
else
mkdir ~/.connect
fi
echo "sudo openvpn $path" > $path_release_arena
cat $path_release_arena | sh
fi
exit 0
;;
-v | --version)
echo "Connect version 1.1"
exit 0
;;
-R | --reset-vpn)
echo "1 - HTB"
echo "2 - StartPointHTB"
echo "3 - TryHackMe"
echo "4 - ReleaseArenaHTB"
read -p "VPN file to remove: " file
if [[ $file == 1 ]]
then
if [[ -e ~/.connect/path_htb.txt ]]
then
rm ~/.connect/path_htb.txt
echo "File removed"
else
echo "File not found"
fi
elif [[ $file == 2 ]]
then
if [[ -e ~/.connect/path_sp.txt ]]
then
rm ~/.connect/path_sp.txt
echo "File removed"
else
echo "File not found"
fi
elif [[ $file == 3 ]]
then
if [[ -e ~/.connect/path_thm.txt ]]
then
rm ~/.connect/path_thm.txt
echo "File removed"
else
echo "File not found"
fi
elif [[ $file == 4 ]]
then
if [[ -e ~/.connect/path_release_arena.txt ]]
then
rm ~/.connect/path_release_arena.txt
echo "File removed"
else
echo "File not found"
fi
else
echo "Invalid option!"
fi
exit 0
;;
-help | --help)
echo "Usage: $0 -h
[-h | --htb] Connect to HackTheBox VPN
[-s | --start] Connect to StartPointHTB VPN
[-t | --thm] Connect to TryHackMe VPN
[-r | --release-arena] Connect to ReleaseArenaHTB VPN
[-R | --reset-vpn] Remove a configuration file and reset it to connect to a new VPN file
[-v | --version] Display the version of your connect file
[-help | --help] Display this message"
exit 0
;;
*)
if test -n "$1"
then
echo Opção inválida: $1
exit 1
fi
;;
esac
echo "Usage: $0 -h
[-h | --htb] Connect to HackTheBox VPN
[-s | --start] Connect to StartPointHTB VPN
[-t | --thm] Connect to TryHackMe VPN
[-r | --release-arena] Connect to ReleaseArenaHTB VPN
[-R | --reset-vpn] Remove a configuration file and reset it to connect to a new VPN file
[-v | --version] Display the version of your connect file
[-help | --help] Display this message"