-
Notifications
You must be signed in to change notification settings - Fork 27
/
menu
executable file
·885 lines (852 loc) · 44.3 KB
/
menu
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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
#!/bin/bash
# This file is a part of TorBox, an easy to use anonymizing router based on Raspberry Pi.
# Copyright (C) 2024 Patrick Truffer
# Contact: [email protected]
# Website: https://www.torbox.ch
# Github: https://github.com/radio24/TorBox
#
# 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 main menu and executes all relevant scripts.
#
# SYNTAX
# ./menu [<INTERNETSELECTION>]
#
# <INTERNETSELECTION> will execute one of the routines, which configures
# TorBox to route the data from an internal to an external interface.
#
###### SET VARIABLES ######
#
# SIZE OF THE MENU
#
# How many items do you have in the main menu?
NO_ITEMS=15
#
# How many lines are only for decoration and spaces?
NO_SPACER=3
#
#Set the the variables for the menu
MENU_WIDTH=80
MENU_WIDTH_REDUX=60
MENU_HEIGHT_25=25
MENU_HEIGHT_15=15
# MENU_HEIGHT should not exceed 26
MENU_HEIGHT=$((8+NO_ITEMS+NO_SPACER))
MENU_LIST_HEIGHT=$((NO_ITEMS+NO_SPACER))
#Colors
RED='\033[1;31m'
WHITE='\033[1;37m'
NOCOLOR='\033[0m'
# Identify the Operation System
CHECK_OS="$(lsb_release -si)"
CHECK_OS="$(echo "$CHECK_OS" | tail -n1)"
#Other variables
TORSTATS="sudo -u debian-tor nyx"
TORRC="/etc/tor/torrc"
RUNFILE="/home/torbox/torbox/run/torbox.run"
EXITID="EXITID=0"
MMENUSTRING=""
INTERNETSELECTION=$1
#Check freshinstalled
FRESHINSTALLED=$(grep "^FRESH_INSTALLED=.*" ${RUNFILE} | sed "s/.*=//g") 2>/dev/null
##############################
######## FUNCTIONS ###########
#include lib
. /home/torbox/torbox/lib/torbox.lib
# TIS FUNCTION HAS TO BE INTEGRATED INTO THE LIB
# This function imports the configuration and makes some preparations
# TOGGLE07 / TOGGLE08 represents the status of the Bridge Relay mode
read_config()
{
MODE_BR=$(grep "^BridgeRelay" ${TORRC})
if [ "$MODE_BR" = "BridgeRelay 1" ]; then
TOGGLE07="IS RUNNING"
else
TOGGLE07="IS NOT RUNNING"
fi
MODE_OS=$(grep "^HiddenServiceDir" ${TORRC})
if [ ! -z "$MODE_OS" ]; then
TOGGLE16="IS RUNNING"
else
TOGGLE16="IS NOT RUNNING"
fi
}
# This function opens the ports, after a restart if bridge relay is on
check_bridge_relay()
{
if grep "^BridgeRelay 1" ${TORRC} ; then
ORPORT=$(grep "^ORPort" ${TORRC} | cut -d " " -f2)
OBFS4PORT=$(grep "^ServerTransportListenAddr" ${TORRC} | cut -d ":" -f2)
(sudo iptables -C INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null
RULE_CHECK=$?
if [ $RULE_CHECK = 1 ]; then
(sudo iptables -A INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null
(sudo iptables -A INPUT -p tcp --dport $OBFS4PORT -j ACCEPT) 2>/dev/null
fi
else
if iptables-save | grep -e "-A INPUT -p tcp --dport $ORPORT -j ACCEPT" ; then (sudo /sbin/iptables -D INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null ; fi
if iptables-save | grep -e "-A INPUT -p tcp --dport $OBFS4PORT -j ACCEPT" ; then (sudo /sbin/iptables -D INPUT -p tcp --dport $OBFS4PORT -j ACCEPT) 2>/dev/null ; fi
fi
}
# This function tests if TorBox's automatic counteractions are activated and still running
check_log_check()
{
clear
if pgrep -f "log_check.py"; then
clear
else
clear
if grep "LOGCHECK=1" /home/torbox/torbox/run/torbox.run ; then
clear
(nohup sudo /usr/bin/python3 /home/torbox/torbox/log_check.py &) 2>/dev/null
clear
sleep 1
fi
fi
}
# This function asks if a Captive Portal is used and which method should be taken to pass through it
ask_captive()
{
clear
INPUT=$(cat text/captive_or_not-text)
if (whiptail --title "TorBox - INFO" --defaultno --no-button "OPEN ACCESS" --yes-button "CAPTIVE PORTAL" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
INPUT=$(cat text/captive_portal-text)
if (whiptail --title "TorBox - INFO" --no-button "TUNNELLING" --yes-button "SPOOFING" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
CAPTIVE=2
else
CAPTIVE=1
fi
else
CAPTIVE=0
fi
sleep 2
}
######## PREPARATIONS ########
# 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}
clear
if [ -z "$INTERNETSELECTION" ]; then
if [ $FRESHINSTALLED -gt 0 ]; then bin/first_use; fi
fi
read_config
do_we_use_bridges
check_bridge_relay
check_interface_with_internet
check_log_check
check_tor
TOR_OVER_VPN=$(sudo iptables -t nat -vnL | grep tun0)
if [ ! -z "$TOR_STATUS" ] && [ ! -z "$VPN_STATUS" ] && [ ! -z "$TOR_OVER_VPN" ]; then TOR_STATUS=" TOR over VPN working"
elif [ ! -z "$TOR_STATUS" ] && [ ! -z "$VPN_STATUS" ] && [ -z "$TOR_OVER_VPN" ]; then TOR_STATUS="VPN is up & TOR working"
elif [ ! -z "$TOR_STATUS" ] && [ -z "$VPN_STATUS" ] && [ -z "$TOR_OVER_VPN" ]; then TOR_STATUS=" TOR is working"
elif [ -z "$TOR_STATUS" ] && [ ! -z "$VPN_STATUS" ] && [ -z "$TOR_OVER_VPN" ]; then TOR_STATUS=" VPN is up"
else TOR_STATUS=""
fi
if grep ^FORWARDING_ONLY=1 ${RUNFILE}; then TOR_STATUS=" FORWARDING - NO TOR!"; fi
if grep "^TOR_CONTROL_PORT_ACCESS=1" ${RUNFILE}; then
CONTROLPORT_WLAN="s/^#ControlPort 192.168.42.1:9051/ControlPort 192.168.42.1:9051/"
CONTROLPORT_ETH="s/^#ControlPort 192.168.43.1:9051/ControlPort 192.168.43.1:9051/"
else
CONTROLPORT_WLAN="s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/"
CONTROLPORT_ETH="s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/"
fi
CHOICE=""
#If first_use is at play, only the configuration where the Internet is coming from will be made without displaying the Main Menu
if [[ $INTERNETSELECTION -gt 4 && $INTERNETSELECTION -lt 11 ]]; then
CHOICE=$INTERNETSELECTION
else
#Probabaly only under Ubuntu shell output line separator fails to get reset: https://superuser.com/questions/1650758/how-does-the-shell-output-line-separator-fail-to-get-reset
if [ "$CHECK_OS" == "Ubuntu" ]; then stty sane; fi
###### DISPLAY THE MAIN MENU ######
CHOICE=$(whiptail --nocancel --title "TorBox v.0.5.3 - MAIN MENU" --menu "Choose an option (ESC -> command prompt) $TOR_STATUS" $MENU_HEIGHT $MENU_WIDTH $MENU_LIST_HEIGHT \
" 1" "Tor statistics (press m for menu / q to quit)" \
" 2" "Enforce a new exit node with a new IP" \
" 3" "Restart Tor - check if it is working (press q to quit)" \
" 4" "Display the Tor log file - quick and dirty (press q to quit)" \
"===" "===================================[Where is the Internet?]===" \
" 5" "Ethernet cable (eth0) "$FLASH_ETH0 \
" 6" "Wireless network (through an USB adapter; wlan1) "$FLASH_WLAN1 \
" 7" "Wireless network (through the onboard chip; wlan0) "$FLASH_WLAN0 \
" 8" "Cellular, USB dongle or Tethering (Android) (ppp0; usb0) "$FLASH_USB0 \
" 9" "USB ethernet adapter or Tethering (iOS) (eth1) "$FLASH_ETH1 \
"10" "Over a VPN connection (tun0) "$FLASH_TUN0 \
"===" "================================================[Sub-Menus]===" \
"11" "Go to the Countermeasure sub-menu... ${MMENUSTRING}" \
"12" "Go to the Configuration sub-menu..." \
"13" "Go to run an OBFS4 Bridge Relay... ${TOGGLE07}" \
"14" "Go to run an Onion Service... ${TOGGLE16}" \
"15" "Go to the Danger Zone..." \
"16" "Go to the Update and Maintenance sub-menu..." \
"==" "============================================[Informational]===" \
"17" "HOW CAN I SUPPORT THE TOR PROJECT!" \
"18" "HOW CAN I HELP WITH TORBOX?" \
"===" "========================================[Reboot & Shutdown]===" \
"19" "Reboot / Shutdown TorBox" \
3>&1 1>&2 2>&3)
exitstatus=$?
# exitstatus == 255 means that the ESC key was pressed
[ "$exitstatus" == "255" ] && exit 0
fi
CHOICE=$(echo "$CHOICE" | tr -d ' ')
case "$CHOICE" in
# This starts nyx (Tor statistics)
1)
clear
$TORSTATS
;;
# This enforces a new exit node
2)
clear
echo -e "${RED}[+] Requesting new identity...${WHITE}"
echo ""
sleep 2
sudo -u debian-tor tor-prompt --run 'SIGNAL NEWNYM'
echo -e "${RED}[+] Done!${NOCOLOR}"
sleep 4
;;
# Restart Tor and check the progress
3)
INPUT=$(cat text/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
exit 0
fi
;;
# This displays the tor log file (quick and dirty)
4)
clear
trap "bash menu; exit 0" SIGINT
echo -e "${RED}[+] See below the tor log file (press q to quit):${NOCOLOR}"
stty intr q
sudo tail -f -n 30 /var/log/tor/notices.log | sed -u 's#.*Bootstrapped 100% (done): Done#\x1b[97m&\x1b[0m#' | grep -v -e "You configured a non-loopback address" -e "opening log file" -e "Application request when we haven't" -e "Giving up. (waiting for circuit)" -e "New control connection opened from" -e "While fetching directory info, no running dirservers known"
stty intr ^c
;;
# Ethernet cable internet eth0 --> wlan0 / eth1
5)
INPUT=$(cat text/cable-text)
if (whiptail --title "TorBox - INFO" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan0 eth1) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan0 eth1) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth1 | grep "state UP" ; then
ETH1_IP=$(ip addr show eth1 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH1_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth1/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH1_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth1/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 eth0 wlan0 eth1 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 eth0 wlan0 eth1 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
fi
;;
# Wireless network (through an USB adapter; wlan1 --> wlan0 / eth0)
6)
INPUT=$(cat text/wlan1-text)
if (whiptail --title "TorBox - INFO" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
if ip link | grep wlan1; then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 wlan1 wlan0 eth0 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 wlan1 wlan0 eth0 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
else
whiptail --title "TorBox - INFO" --textbox text/no_wlan1-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
fi
;;
# Wireless network (through the onboard chip; wlan0 --> wlan1 / eth0)
# This menu entry temporary restores the wlan1 / eth0 configuration, which does not survive a reboot!
# A failsave routine in rc.local takes care of it!
7)
INPUT=$(cat text/wlan0-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan1 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan1 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
if ip link | grep wlan1 | grep "state UP" ; then
WLAN1_IP=$(ip addr show wlan1 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN1_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan1 eth0/" ${RUNFILE}
elif [ -z "$WLAN1_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=wlan0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan1/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 wlan0 wlan1 eth0 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 wlan0 wlan1 eth0 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
# iptables cannot be saved !!
fi
;;
# Cellular or other connections (ppp0; usb0 --> wlan0 / eth0)
8)
INPUT=$(cat text/ppp0-text)
if (whiptail --title "TorBox - INFO" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
if ip link | grep usb0 ; then
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=usb0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=usb0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=usb0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 usb0 wlan0 eth0 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 usb0 wlan0 eth0 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
else
if pgrep -f "pppd"; then
if (whiptail --title "TorBox - INFO" --no-button "CONTINUE" --yes-button "RESET" --yesno "\nThe PPP connection is already up!\n\nDo you want to reset the PPP connection or continue with the already existing one?" $MENU_HEIGHT_15 $MENU_WIDTH); then
clear
echo -e "${RED}[+] Reset PPP connection (you may check the output for errors)${NOCOLOR}"
echo -e "${RED}[+] If stuck, please press q${NOCOLOR}"
echo ""
trap "bash menu; exit 0" SIGINT
stty intr q
sudo bin/poff
sleep 5
sudo pon
echo ""
sleep 2
read -n 1 -s -r -p "Press any key to continue"
stty intr ^c
trap
fi
else
echo -e "${RED}[+] Activating PPP connection (you may check the output for errors)${NOCOLOR}"
echo -e "${RED}[+] If stuck, please press q${NOCOLOR}"
echo ""
trap "bash menu; exit 0" SIGINT
stty intr q
if pgrep -f "pppd"; then
sudo bin/poff
sleep 5
fi
sudo pon
echo ""
sleep 2
read -n 1 -s -r -p "Press any key to continue"
stty intr ^c
trap
fi
if ip link | grep ppp0 > /dev/null; then
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=ppp0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=ppp0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=ppp0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 ppp0 wlan0 eth0 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 ppp0 wlan0 eth0 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
else
whiptail --title "TorBox - INFO" --textbox text/no_ppp0-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
fi
fi
;;
# Tethering or USB ethernet adapter (eth1 --> wlan0 / eth0)
9)
INPUT=$(cat text/tethering-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
if ip link | grep eth1 ; then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth1/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 eth1 wlan0 eth0 $CAPTIVE 1
else
sudo bash bin/set_interfaces_2 eth1 wlan0 eth0 $CAPTIVE 0
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
else
whiptail --title "TorBox - INFO" --textbox text/no_eth1-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
fi
;;
# Over a VPN connection (tun0)
10)
INPUT=$(cat text/tun0-text)
if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
tun0up=$(ip link | grep tun0)
if [ -z "$tun0up" ] ; then
clear
online_check default 0 0
if [ $OCHECK == 0 ]; then
INPUT=$(cat text/tun0-not_connected-text)
if (whiptail --title "TorBox - INFO" --yesno --no-button "CONTINUE" --yes-button "CONNECT WLAN" --yesno "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH); then
display_net_reconfiguration_info
(nohup bin/hostapd_fallback_komplex_part_1 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 1 of 2 done${NOCOLOR}"
(nohup bin/hostapd_fallback_komplex_part_2 wlan0 eth0) 2>/dev/null
echo -e "${WHITE}[+] Step 2 of 2 done${NOCOLOR}"
sleep 2
ask_captive
# set_interfaces_2 will do the captive portal handling, if necessary and start TWM, but it will not restart tor
sudo bash bin/set_interfaces_2 wlan1 wlan0 eth0 $CAPTIVE 0 0
fi
fi
connecting_to_VPN
sleep 3
fi
tun0up=$(ip link | grep tun0)
if [ ! -z "$tun0up" ] ; then
if ip link | grep wlan0 | grep "state UP" ; then
WLAN0_IP=$(ip addr show wlan0 | grep -w 192.168.42.1)
clear
fi
if ip link | grep eth0 | grep "state UP" ; then
ETH0_IP=$(ip addr show eth0 | grep -w 192.168.43.1)
clear
fi
if [ -n "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=tun0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth0/" ${RUNFILE}
elif [ -z "$WLAN0_IP" ] && [ -n "$ETH0_IP" ] ; then
sudo sed -i "s/^TransPort 192.168.42.1:9040/#TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.42.1:9053/#DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9050/#SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.42.1:9052/#SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.42.1:9051/#ControlPort 192.168.42.1:9051/" ${TORRC}
sudo sed -i "s/^#TransPort 192.168.43.1:9040/TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.43.1:9053/DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9050/SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.43.1:9052/SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_ETH" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=tun0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=eth0/" ${RUNFILE}
else
sudo sed -i "s/^#TransPort 192.168.42.1:9040/TransPort 192.168.42.1:9040/" ${TORRC}
sudo sed -i "s/^#DNSPort 192.168.42.1:9053/DNSPort 192.168.42.1:9053/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9050/SocksPort 192.168.42.1:9050/" ${TORRC}
sudo sed -i "s/^#SocksPort 192.168.42.1:9052/SocksPort 192.168.42.1:9052/" ${TORRC}
sudo sed -i "$CONTROLPORT_WLAN" ${TORRC}
sudo sed -i "s/^TransPort 192.168.43.1:9040/#TransPort 192.168.43.1:9040/" ${TORRC}
sudo sed -i "s/^DNSPort 192.168.43.1:9053/#DNSPort 192.168.43.1:9053/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9050/#SocksPort 192.168.43.1:9050/" ${TORRC}
sudo sed -i "s/^SocksPort 192.168.43.1:9052/#SocksPort 192.168.43.1:9052/" ${TORRC}
sudo sed -i "s/^ControlPort 192.168.43.1:9051/#ControlPort 192.168.43.1:9051/" ${TORRC}
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=tun0/" ${RUNFILE}
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0/" ${RUNFILE}
fi
# The following line should minimize those cases where a restart is required.
sudo systemctl restart isc-dhcp-server
if [ -z "$INTERNETSELECTION" ]; then
sudo bash bin/set_interfaces_2 tun0 wlan0 eth0 0 1 1
else
sudo bash bin/set_interfaces_2 tun0 wlan0 eth0 0 0 1
fi
if [ -z "$INTERNETSELECTION" ]; then finish; else exit; fi
(sudo sh -c "iptables-save > /etc/iptables.ipv4.nat") 2>/dev/null
else
whiptail --title "TorBox - INFO" --textbox text/no_tun0-text $MENU_HEIGHT_15 $MENU_WIDTH_REDUX
fi
fi
;;
# Sub-menues
11) bash menu-bridges;;
12) bash menu-config;;
13) bash menu-server;;
14) bash menu-onion;;
15)
INPUT=$(cat text/menu_danger-text)
whiptail --title "TorBox - INFO" --msgbox "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH
bash menu-danger
;;
16)
screen bash menu-update
clear
# shellcheck disable=SC2164
cd
# shellcheck disable=SC2164
cd torbox
;;
# How to support Tor
17)
INPUT=$(cat text/support-tor-text)
whiptail --title "TorBox - INFO" --msgbox "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH
;;
# How to support TorBox
18)
INPUT=$(cat text/support-torbox-text)
whiptail --title "TorBox - INFO" --msgbox "$INPUT" $MENU_HEIGHT_25 $MENU_WIDTH
;;
# Reboot or Shotdown TorBox
19)
CHOICE_EXIT=$(whiptail --nocancel --title "TorBox v.0.5.3 - EXIT MENU" --menu "Reboot or Shutdown (ESC to quit)" 10 $MENU_WIDTH_REDUX 2 \
" 1" "REBOOT TorBox" \
" 2" "SHUTDOWN TorBox" \
3>&1 1>&2 2>&3)
if [ "$CHOICE_EXIT" != " " ]; then
if [ $CHOICE_EXIT = 1 ]; then
clear
echo -e "${RED}[+] Rebooting TorBox...${NOCOLOR}"
echo -e "${WHITE}[!] If you have activated Bridges or Bridge Relay, these services will be reactivated automatically after the restart.${NOCOLOR}"
echo ""
sleep 2
sudo reboot
exit 0
elif [ $CHOICE_EXIT = 2 ]; then
clear
echo -e "${RED}[+] Shutting down TorBox...${NOCOLOR}"
echo -e "${WHITE}[!] If you have activated Bridges or Bridge Relay, these services will be reactivated automatically after the restart.${NOCOLOR}"
echo -e "${WHITE}[!] You can disconnect TorBox from the power source in about 30 second...${NOCOLOR}"
echo ""
sleep 2
sudo shutdown -h now
exit 0
fi
fi
;;
*)
clear
#Probabaly only under Ubuntu shell output line separator fails to get reset: https://superuser.com/questions/1650758/how-does-the-shell-output-line-separator-fail-to-get-reset
if [ "$CHECK_OS" == "Ubuntu" ]; then stty sane; fi
PROMPTTEXT=$(cat text/prompt-text)
echo -e "$PROMPTTEXT"
echo " "
exit 0
esac
bash menu