-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmenu-bridges
executable file
·573 lines (532 loc) · 21.9 KB
/
menu-bridges
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
#!/bin/bash
# shellcheck disable=SC2001,SC2154
# This file is part of TorBox, an easy to use anonymizing router based on Raspberry Pi.
# Copyright (C) 2024 radio24
# Contact: [email protected]
# Website: https://www.torbox.ch
# Github: https://github.com/radio24/TorBox
#
# Copyright (C) 2022 nyxnor (Contributor)
# Github: https://github.com/nyxnor
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it is useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# DESCRIPTION
# This file displays the bridges menu and executes all relevant scripts.
#
# SYNTAX
# ./menu-bridges
#
#
###### SET VARIABLES ######
#
# SIZE OF THE MENU
#
# How many items do you have in the main menu?
NO_ITEMS=14
#
# How many lines are only for decoration and spaces?
NO_SPACER=4
#
#Set the the variables for the menu
MENU_WIDTH=80
MENU_WIDTH_REDUX=60
MENU_HEIGHT_10=10
MENU_HEIGHT_15=15
MENU_HEIGHT_20=20
MENU_HEIGHT_25=25
# MENU_HEIGHT should not exceed 26
MENU_HEIGHT=$((8+NO_ITEMS+NO_SPACER))
MENU_LIST_HEIGHT=$((NO_ITEMS+NO_SPACER))
#Colors (don't change it!)
RED='\033[1;31m'
YELLOW='\033[1;93m'
NOCOLOR='\033[0m'
#Other variables
TORRC="/etc/tor/torrc"
BAK="/etc/tor/torrc.bak"
TORBOX_PATH="/home/torbox/torbox"
RUNFILE="$TORBOX_PATH/run/torbox.run"
TXT_DIR="$TORBOX_PATH/text"
LOOP_NUMBER=0
PING_SERVER=$(grep "^PING_SERVER=" ${RUNFILE} | sed "s|.*http\?://||g") 2>/dev/null
###########################
######## FUNCTIONS ########
# include lib
. /home/torbox/torbox/lib/torbox.lib
# This function imports the configuration and makes some preparations
read_config()
{
# Is TorBox connected to a VPN?
tun0up=$(ip link | grep tun0)
clear
if [ -z "$tun0up" ]; then
VPNSTRING1="Connect"
VPNSTRING2="to"
else
VPNSTRING1="Disconnect"
VPNSTRING2="from"
fi
# Is the automatic counteractions feature activated?
if pgrep -f "log_check.py"; then
clear
LOGCHECK="Deactivate"
LOGCHECKSTATUSb="ON"
else
clear
LOGCHECK="Activate"
LOGCHECKSTATUSb="OFF"
fi
# Is the Countermeasure against a tightly configured firewall active?
MODE_FIREWALL=$(grep -o "^ReachableAddresses " ${TORRC} | head -1)
clear
if [ "$MODE_FIREWALL" = "ReachableAddresses " ]; then
FIREWALL="ON"
else
FIREWALL="OFF"
fi
# Is the Countermeasure against a disconnection when idle feature active?
if pgrep -f "ping -q $PING_SERVER" ; then
clear
PING="ON"
else
clear
PING="OFF"
fi
# Is the OBFS4 Bridge Relay running?
MODE_BR=$(grep "^BridgeRelay" ${TORRC})
if [ "$MODE_BR" = "BridgeRelay 1" ]; then TOGGLE07b="ON"; else TOGGLE07b="OFF"; fi
# number_of_obfs4_bridges()
# How many OBFS4 bridges do we have? readarray reads into an array beginning with index 0
# Following variables can be used:
# $configured_bridges_deactivated -> An array with all deactivated OBFS4 bridges
# $configured_bridges_activated -> An array with all activated OBFS4 bridges
# $number_configured_bridges_deactivated -> Number of deactivated bridges
# $number_configured_bridges_activated -> Number of activated bridges
# $number_configured_bridges_total -> Total number of bridges
number_of_obfs4_bridges
# number_of_snowflake_bridges()
# How many Snowflake bridges do we have? readarray reads into an array beginning with index 0
# Following variables can be used:
# $configured_snowflake_bridges_deactivated -> An array with all deactivated Snowflake bridges
# $configured_snowflake_bridges_activated -> An array with all activated Snowflake bridges
# $number_configured_snowflake_bridges_deactivated -> Number of deactivated bridges
# $number_configured_snowflake_bridges_activated -> Number of activated bridges
# $number_configured_snowflake_bridges_total -> Total number of bridges
number_of_snowflake_bridges
}
######## PREPARATIONS ########
do_we_use_bridges
read_config
# Resetting
shopt -s checkwinsize
[ -f nohup.out ] && sudo rm nohup.out
stty intr ^c
trap
# Resetting run-file (the initial EXITID in the runfile has to be 0)
sudo sed -i "s/^EXITID=.*/${EXITID}/" ${RUNFILE}
###### DISPLAY THE MENU ######
clear
CHOICE=$(whiptail --cancel-button "Back" --title "TorBox v.0.5.4 - COUNTERMEASURE MENU" --menu "Choose an option (ESC -> back to the main menu) ${BRIDGESTRING}" $MENU_HEIGHT $MENU_WIDTH $MENU_LIST_HEIGHT \
"==" "=============================================[Informational]===" \
" 1" "ALL ABOUT BRIDGES AND PLUGGABLE TRANSPORTS - READ ME FIRST!" \
"==" "=============================================[OBFS4 bridges]===" \
" 2" "Activate configured OBFS4 bridges" \
" 3" "Add additional OBFS4 bridges" \
" 4" "List all $number_configured_bridges_total OBFS4 bridges" \
" 5" "Delete configured OBFS4 bridges" \
" 6" "Deactivate configured OBFS4 bridges" \
"==" "=========================================[SNOWFLAKE bridges]===" \
" 7" "Activate configured SNOWFLAKE bridges" \
" 8" "Add additional SNOWFLAKE bridges" \
" 9" "List all $number_configured_snowflake_bridges_total SNOWFLAKE bridges" \
"10" "Delete configured SNOWFLAKE bridges" \
"11" "Deactivate configured SNOWFLAKE bridges" \
"==" "==============================================[MEEK bridges]===" \
"12" "$MEEKSTRINGb MEEK-AZURE to circumvent censorship" \
"==" "======================================[More Countermeasures]===" \
"13" "Enter the advanced tor configuration editor" \
"14" "$LOGCHECK TorBox's automatic counteractions - $LOGCHECKSTATUSb" \
"15" "Change or randomize TorBox's hostname" \
"16" "Countermeasure against a tightly configured firewall - $FIREWALL" \
"17" "Countermeasure against a disconnection when idle feature - $PING" \
"18" "$VPNSTRING1 TorBox $VPNSTRING2 a VPN" \
3>&1 1>&2 2>&3)
exitstatus=$?
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
CHOICE=$(echo "$CHOICE" | tr -d ' ')
case "$CHOICE" in
# Display the read.me
1)
INPUT=$(cat $TXT_DIR/help-bridges-text)
whiptail --title "TorBox - INFO (scroll down!)" --msgbox --scrolltext "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH
;;
# Activate OBFS4 bridges to circumvent censorship
2)
if [ "$MODE_MEEK" = "Bridge meek_lite " ] || [ "$MODE_SNOW" = "Bridge snowflake " ]; then
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/no_meek-snow-please-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
if [ "$FIREWALL" = "ON" ]; then
INPUT=$(cat $TXT_DIR/no_antifirewall-please-text)
if (whiptail --title "TorBox - INFO" --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
sudo sed -i "s/^ReachableAddresses /#ReachableAddresses /g" ${TORRC}
fi
fi
if [ -z $number_configured_bridges_total ] || [ "$number_configured_bridges_total" == "0" ]; then
INPUT=$(cat $TXT_DIR/add-bridges-first-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
sudo bash bin/bridges_add_obfs4 "$MODE_BRIDGES" 0
else
deactivate_obfs4_bridges
trap "bash menu-bridges; exit 0" EXIT
exit 0
fi
fi
if [ "$MODE_BRIDGES" != "UseBridges 1" ]; then
INPUT=$(cat $TXT_DIR/activate-obfs4-bridges-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --defaultno --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
sudo bash bin/bridges_activate_obfs4
else
trap "bash menu-bridges; exit 0" EXIT
exit 0
fi
else
sudo bash bin/bridges_activate_obfs4
fi
read_config
;;
# Add OBFS4 bridges
3)
sudo bash bin/bridges_add_obfs4 "$MODE_BRIDGES" 1
read_config
;;
# List all OBFS4 bridges configured in torrc and if online display the status of the bridges
4)
list_all_obfs4_bridges
;;
# Delete OBFS4 bridges
5)
if [ -z $number_configured_bridges_total ] || [ "$number_configured_bridges_total" == "0" ]; then
clear
echo -e "${YELLOW}[!] There are no configured OBFS4 bridges -> nothing to delete!${NOCOLOR}"
sleep 5
else
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/remove-obfs4-bridges-text $MENU_HEIGHT_20 $MENU_WIDTH
sudo bash bin/bridges_remove_obfs4 "$MODE_BRIDGES"
read_config
fi
;;
# Deactivate bridges
6)
if [ -z $number_configured_bridges_total ] || [ "$number_configured_bridges_total" == "0" ]; then
clear
echo -e "${YELLOW}[!] There are no configured OBFS4 bridges -> nothing to deactivate!${NOCOLOR}"
sleep 5
else
if [ "$MODE_MEEK" = "Bridge meek_lite " ] || [ "$MODE_SNOW" = "Bridge snowflake " ]; then
clear
echo -e "${YELLOW}[!] No OBFS4 bridges are activated!${NOCOLOR}"
echo -e "${RED}[+] If you want to use OBFS4 bridges, you have to activate them first with menu entry 2 or 3.${NOCOLOR}"
sleep 5
else
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/deactivate-obfs4-bridges-text $MENU_HEIGHT_15 $MENU_WIDTH
sudo bash bin/bridges_deactivate_obfs4
read_config
fi
fi
;;
# Activate/deactivate Snowflake bridges to circumvent censorship
7)
if [ "$MODE_MEEK" = "Bridge meek_lite " ] || [ "$MODE_OBFS4" = "Bridge obfs4 " ]; then
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/no_meek-please-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
if [ "$FIREWALL" = "ON" ]; then
INPUT=$(cat $TXT_DIR/no_antifirewall-please-text)
if (whiptail --title "TorBox - INFO" --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
sudo sed -i "s/^ReachableAddresses /#ReachableAddresses /g" ${TORRC}
fi
fi
if [ -z $number_configured_snowflake_bridges_total ] || [ "$number_configured_snowflake_bridges_total" == "0" ]; then
INPUT=$(cat $TXT_DIR/add-bridges-first-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
sudo bash bin/bridges_add_snowflake "$MODE_BRIDGES" 0
else
deactivate_snowflake_bridges
trap "bash menu-bridges; exit 0" EXIT
exit 0
fi
fi
if [ "$MODE_BRIDGES" != "UseBridges 1" ]; then
INPUT=$(cat $TXT_DIR/activate-snowflake-bridges-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --defaultno --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
sudo bash bin/bridges_activate_snowflake
else
trap "bash menu-bridges; exit 0" EXIT
exit 0
fi
else
sudo bash bin/bridges_activate_snowflake
fi
read_config
;;
# Add Snowflake bridges
8)
sudo bash bin/bridges_add_snowflake "$MODE_BRIDGES" 1
read_config
;;
# List all Snowflake bridges configured in torrc and if online display the status of the bridges
9)
list_all_snowflake_bridges
;;
# Delete Snowflake bridges
10)
if [ -z $number_configured_snowflake_bridges_total ] || [ "$number_configured_snowflake_bridges_total" == "0" ]; then
clear
echo -e "${YELLOW}[!] There are no configured Snowflake bridges -> nothing to delete!${NOCOLOR}"
sleep 5
else
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/remove-snowflake-bridges-text $MENU_HEIGHT_20 $MENU_WIDTH
sudo bash bin/bridges_remove_snowflake "$MODE_BRIDGES"
read_config
fi
;;
# Deactivate Snowflake bridges
11)
if [ -z $number_configured_snowflake_bridges_total ] || [ "$number_configured_snowflake_bridges_total" == "0" ]; then
clear
echo -e "${YELLOW}[!] There are no configured Snowflake bridges -> nothing to deactivate!${NOCOLOR}"
sleep 5
else
if [ "$MODE_MEEK" = "Bridge meek_lite " ] || [ "$MODE_OBFS4" = "Bridge obfs4 " ]; then
clear
echo -e "${YELLOW}[!] No Snowflake bridges are activated!${NOCOLOR}"
echo -e "${RED}[+] If you want to use Snowflake bridges, you have to activate them first with menu entry 7 or 8.${NOCOLOR}"
sleep 5
else
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/deactivate-snowflake-bridges-text $MENU_HEIGHT_15 $MENU_WIDTH
deactivate_snowflake_bridges menu-bridges
read_config
fi
fi
;;
# Use Meek-Azure to circumvent censorship
12)
if [ "$MODE_OBFS4" = "Bridge obfs4 " ] || [ "$MODE_SNOW" = "Bridge snowflake " ]; then
whiptail --title "TorBox - INFO" --textbox $TXT_DIR/no_snow-please-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
sudo bash bin/meek-azure $MEEKSTRING $SNOWSTRING
read_config
;;
# Enter the advanced configuration editor
13)
INPUT=$(cat $TXT_DIR/advanced-bridges-text)
if (whiptail --title "TorBox - INFO" --defaultno --no-button "DON'T CHANGE" --yes-button "CHANGE NOW" --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
sudo cp ${TORRC} ${BAK}
bin/vitor
INPUT=$(cat $TXT_DIR/restart-tor-text)
if (whiptail --title "TorBox - INFO" --defaultno --no-button "NO - DON'T (RE)START" --yes-button "YES - (RE)START" --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
clear
restarting_tor menu-bridges
fi
read_config
fi
;;
# Activate/deactivate TorBox's automatic counteractions
14)
if [ "$LOGCHECK" = "Deactivate" ]; then
echo -e "${RED}[+] Deactivating TorBox's automatic counteractions feature...${NOCOLOR}"
sudo pkill -f "log_check.py"
echo -e "${RED}[+] ...configuration removed...${NOCOLOR}"
(sudo rm $TORBOX_PATH/log_check_config.py) &>/dev/null
echo -e "${RED}[+] ...log removed!${NOCOLOR}"
(sudo find /var/log/tor/ | grep "automat" | xargs -d"\n" sudo rm) &>/dev/null
(sudo sed -i "s/^LOGCHECK=.*/LOGCHECK=0/" $RUNFILE) &>/dev/null
sleep 1
clear
echo -e "${RED}[+] TorBox's automatic counteractions feature is deactivated!${NOCOLOR}"
sleep 5
fi
if [ "$LOGCHECK" = "Activate" ]; then
###### DISPLAY THE AVAILABLE OPTIONS ######
CHOICE2=$(whiptail --nocancel --title "TorBox v.0.5.4 - AUTOMATIC COUNTERACTIONS" --checklist --separate-output "Choose with SPACE and then press ENTER (ESC -> go back)" 12 $MENU_WIDTH 6 \
"1" "Protection against out of sync time" ON \
"2" "Protection against entry guard failing and overloaded tor network" ON \
"3" "Protection against interrupted WiFi connection with the Internet" ON \
"4" "Protection against excessive number of failing tor circuits" ON \
"5" "Protection against excessive connection failing with tor circuits" ON \
"6" "Protection against tor bootstrapping problems" ON \
3>&1 1>&2 2>&3)
if [ ! -z "$CHOICE2" ]; then
mapfile -t CHOICE2 <<< "$CHOICE2"
clear
for ARGUMENT in "${CHOICE2[@]}"; do
[ -z "$ARGUMENT" ] && exit 0
echo -e "${RED}[+] Activating TorBox's automatic countermeasure - protection number $ARGUMENT${NOCOLOR}"
sleep 1
LOOP_NUMBER=$((LOOP_NUMBER+1))
[ $LOOP_NUMBER = 1 ] && (cp $TORBOX_PATH/install/log_check_config/header $TORBOX_PATH/log_check_config.py) &>/dev/null
[[ "$ARGUMENT" =~ [1-6] ]] && (cat $TORBOX_PATH/install/log_check_config/00"${ARGUMENT}" >> $TORBOX_PATH/log_check_config.py) &>/dev/null
done
if [ ! -z "$LOOP_NUMBER" ]; then
(cat $TORBOX_PATH/install/log_check_config/footer >> $TORBOX_PATH/log_check_config.py) &>/dev/null
(sudo sed -i "s/^LOGCHECK=.*/LOGCHECK=1/" $RUNFILE) &>/dev/null
sudo ./log_check.py &
clear
echo -e "${RED}[+] TorBox's automatic countermeasure feature is activated!${NOCOLOR}"
sleep 5
fi
read_config
fi
fi
;;
# Change or randomize TorBox's hostname
15)
INPUT=$(cat $TXT_DIR/randomize_hostname-text)
HOSTNAME=$(hostname)
INPUT=$(sed "s/HOSTNAMEANKER/$HOSTNAME/g" <<< "$INPUT")
if (whiptail --title "TorBox Installation on Raspberry Pi OS" --defaultno --yes-button "CHANGE!" --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
exitstatus=$?
# exitstatus == 255 means that the ESC key was pressed
if [ "$exitstatus" != "255" ]; then
if (whiptail --title "TorBox Installation on Raspberry Pi OS" --no-button "SET HOSTNAME" --yes-button "RANDOMIZE HOSTNAME" --yesno "You can set a specific hostname or use a randomized one. Please choose..." $MENU_HEIGHT_10 $MENU_WIDTH); then
# shellcheck disable=SC2002
HOSTNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
else
exitstatus=$?
# exitstatus == 255 means that the ESC key was pressed
if [ "$exitstatus" != "255" ]; then
HOSTNAME=$(whiptail --title "TorBox Installation on Raspberry Pi OS" --inputbox "\nEnter the hostname:" $MENU_HEIGHT_10 $MENU_WIDTH_REDUX 3>&1 1>&2 2>&3)
if [[ $HOSTNAME != *[0123456789ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxzy-]* ]]; then
HOSTNAME=$(tr -dc 'a-zA-Z0-9' <<<$HOSTNAME)
fi
if ${#HOSTNAME} -gt 64 ; then
HOSTNAME=$(head -c 64 <<<$HOSTNAME)
fi
fi
fi
fi
# exitstatus == 255 means that the ESC key was pressed
if [ "$exitstatus" != "255" ] && [ "$HOSTNAME" != "" ]; then
clear
echo -e "${RED}[+] Setting up the hostname...${NOCOLOR}"
sleep 1
(sudo hostnamectl set-hostname "$HOSTNAME") 2>/dev/null
clear
sudo systemctl restart systemd-hostnamed
if grep "127.0.1.1.*" /etc/hosts ; then
(sudo sed -i "s/127.0.1.1.*/127.0.1.1\t$HOSTNAME/g" /etc/hosts) 2>/dev/null
clear
else
(sudo sed -i "s/^::1/127.0.1.1\t$HOSTNAME\n::1/g" /etc/hosts) 2>/dev/null
clear
fi
whiptail --title "TorBox - INFO" --msgbox "TorBox's hostname is now changed to $HOSTNAME\n\nYou have to log out and again log into your console to see the change." $MENU_HEIGHT_10 $MENU_WIDTH_REDUX
fi
fi
;;
# Countermeasure against a tightly configured firewall
16)
if [ "$FIREWALL" = "OFF" ] || [ -z "$FIREWALL" ]; then
if [ "$TOGGLE07b" = "ON" ]; then
INPUT="\n\nTo activate the countermeasure against tightly configured firewalls, you have first to DEACTIVATE OBFS4 Bridge Relay Mode in the OBFS4 Bridge Relay sub-menu. You can not run both settings simultaneously!"
whiptail --title "TorBox - INFO" --msgbox "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH
trap "bash menu-bridges; exit 0" EXIT
exit 1
fi
INPUT=$(cat $TXT_DIR/firewall-text-on)
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
sudo sed -i "s/^#ReachableAddresses /ReachableAddresses /g" ${TORRC}
INPUT=$(cat $TXT_DIR/restart-tor-text)
if (whiptail --title "TorBox - INFO" --no-button "NO - DON'T (RE)START" --yes-button "YES - (RE)START" --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
clear
restarting_tor menu-bridges
clear
echo -e "${RED}[+] Countermeasure against a tightly configured firewall activated!${NOCOLOR}"
sleep 2
else
clear
echo -e "${RED}[+] Countermeasure against a tightly configured firewall set but not yet activated!${NOCOLOR}"
sleep 2
fi
fi
fi
if [ "$FIREWALL" = "ON" ]; then
if (whiptail --title "TorBox - INFO" --defaultno --yesno "Do you want to deactivate against a tightly configured firewall?" $MENU_HEIGHT_10 $MENU_WIDTH_REDUX); then
sudo sed -i "s/^ReachableAddresses /#ReachableAddresses /g" ${TORRC}
INPUT=$(cat $TXT_DIR/restart-tor-text)
if (whiptail --title "TorBox - INFO" --no-button "NO - DON'T (RE)START" --yes-button "YES - (RE)START" --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
clear
restarting_tor menu-bridges
clear
echo -e "${RED}[+] Countermeasure against a tightly configured firewall deactivated!${NOCOLOR}"
sleep 2
else
clear
echo -e "${RED}[+] Countermeasure against a tightly configured firewall unset but not yet deactivated!${NOCOLOR}"
sleep 2
fi
fi
fi
;;
# Countermeasure against a disconnection when idle feature
17)
if [ "$PING" = "OFF" ] || [ -z "$PING" ]; then
INPUT=$(cat $TXT_DIR/ping-text-on)
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
ping -q "$PING_SERVER" >/dev/null &
#Alternative Möglichkeit: screen -dm ping google.com
echo -e "${RED}[+] Countermeasure against a disconnect when idle feature activated!${NOCOLOR}"
sleep 2
fi
fi
if [ "$PING" = "ON" ]; then
if (whiptail --title "TorBox - INFO" --defaultno --yesno "Do you want to deactivate the countermeasure against a disconnect when idle feature?" $MENU_HEIGHT_15 $MENU_WIDTH_REDUX); then
sudo killall ping
echo -e "${RED}[+] Countermeasure against a disconnect when idle feature deactivated!${NOCOLOR}"
sleep 2
fi
fi
;;
# Connect/Disconnect TorBox to/from VPN
18)
if [ -z "$tun0up" ] ; then
INPUT=$(cat $TXT_DIR/connecting-VPN-text)
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
connecting_to_VPN
sudo systemctl restart tor &
tun0up=$(ip link | grep tun0)
fi
else
INPUT=$(cat $TXT_DIR/disconnecting-VPN-text)
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
clear
echo -e "${RED}[+] Disonnecting OpenVPN server...${NOCOLOR}"
sudo killall openvpn
echo -e "${RED}[+] Please wait, we need 15 second to configure the interface...${NOCOLOR}"
sleep 15
sudo systemctl restart tor &
echo ""
echo -e "${RED}[+] It may take some time for Tor to reconnect.${NOCOLOR}"
echo -e "${RED}[+] In case of problems, use main menu entry 5-10.${NOCOLOR}"
sleep 5
tun0up=$(ip link | grep tun0)
fi
fi
;;
*)
clear
exit 0
esac
bash menu-bridges