Skip to content

Commit f5b49c8

Browse files
committed
cleanup
1 parent d1c4e58 commit f5b49c8

File tree

1 file changed

+99
-70
lines changed

1 file changed

+99
-70
lines changed

Install/openWRT23_install.sh

Lines changed: 99 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ INET_GW_org=$INET_GW
108108
RESET='0'
109109

110110
echo
111-
read -p 'Would you Reset the Configuration: [y/N] ' -s -n 1 RESET_ANSWER
111+
read -p 'Would you Reset the Configuration: [y/N] ' -s -n 1 qRESET_ANSWER
112112
echo
113-
if [ "$RESET_ANSWER" = "y" ]
113+
if [ "$qRESET_ANSWER" = "y" ]
114114
then
115115
RESET='1'
116116
wget https://github.com/CyberAndi/CyberSecurity-Box/raw/CyberSecurity-Box/Firmware/backup-OpenWrt-2024-08-29.tar.gz
117117
sysupgrade -r backup-OpenWrt-2024-08-29.tar.gz
118118
uci set unbound.ub_main.dhcp_link='dnsmasq'
119-
uci set unbound.ub_main.listen_port='5353'
119+
uci set unbound.ub_main.listen_port=$DNS_UNBOUND_port
120120
set_unbound_reset
121121
processes=$(uci commit && reload_config)
122122
wait $processes
@@ -130,11 +130,13 @@ if [ "$RESET_ANSWER" = "y" ]
130130
fi
131131

132132
echo
133-
read -p 'Please give me the WAN-IP (Gateway/Router): ['$INET_GW'] ' INET_GW
133+
read -p 'Please give me the WAN-IP (Gateway/Router): ['$INET_GW'] ' qINET_GW
134134
echo
135-
if [ "$INET_GW" = "" ]
135+
if [ "$qINET_GW" = "" ]
136136
then
137137
INET_GW=$INET_GW_org
138+
else
139+
INET_GW=$qINET_GW
138140
fi
139141

140142
WAN_ip=$(echo $INET_GW | cut -f1 -d '.')
@@ -194,10 +196,12 @@ fi
194196

195197
LAN_org=$LAN
196198

197-
read -p 'Type the LAN-IP (Internal Network): ['$( echo $LAN )'] ' LAN
198-
if [ "$LAN" = "" ]
199+
read -p 'Type the LAN-IP (Internal Network): ['$( echo $LAN )'] ' qLAN
200+
if [ "$qLAN" = "" ]
199201
then
200202
LAN=$LAN_org
203+
else
204+
LAN=$qLAN
201205
fi
202206

203207
if [ ! -z "$3" ]
@@ -208,10 +212,12 @@ if [ ! -z "$3" ]
208212
fi
209213

210214
echo
211-
read -p 'Your local Domain of your LAN? [CyberSecBox.local] ' LOCAL_DOMAIN
212-
if [ "$LOCAL_DOMAIN" = "" ]
215+
read -p 'Your local Domain of your LAN? [CyberSecBox.local] ' qLOCAL_DOMAIN
216+
if [ "$qLOCAL_DOMAIN" = "" ]
213217
then
214218
LOCAL_DOMAIN=$LOCAL_DOMAIN_org
219+
else
220+
LOCAL_DOMAIN=$qLOCAL_DOMAIN
215221
fi
216222

217223
if [ ! -z "$4" ]
@@ -225,10 +231,12 @@ WIFI_SSID_org=$WIFI_SSID
225231

226232
echo
227233

228-
read -p 'The Main-WiFi-SSID? ['$(echo $WIFI_SSID)'] ' WIFI_SSID
229-
if [ "$WIFI_SSID" = "" ]
234+
read -p 'The Main-WiFi-SSID? ['$(echo $WIFI_SSID)'] ' qWIFI_SSID
235+
if [ "$qWIFI_SSID" = "" ]
230236
then
231237
WIFI_SSID=$WIFI_SSID_org
238+
else
239+
WIFI_SSID=$qWIFI_SSID
232240
fi
233241

234242
if [ ! -z "$5" ]
@@ -242,18 +250,20 @@ WIFI_PASS_org=$WIFI_PASS
242250

243251
echo
244252

245-
read -p 'And the WiFi-Key? [Cyber,Sec9ox] ' WIFI_PASS
246-
if [ "$WIFI_PASS" = "" ]
253+
read -p 'And the WiFi-Key? [Cyber,Sec9ox] ' qWIFI_PASS
254+
if [ "$qWIFI_PASS" = "" ]
247255
then
248256
WIFI_PASS=$WIFI_PASS_org
257+
else
258+
WIFI_PASS=$qWIFI_PASS
249259
fi
250260

251-
USERNAME='root'
261+
qUSERNAME='root'
252262
echo
253-
read -p 'Enter the user for the login: [root] ' -s USERNAME
263+
read -p 'Enter the user for the login: [root] ' -s qUSERNAME
254264
echo
255265
echo
256-
passwd $USERNAME
266+
passwd $qUSERNAME
257267

258268
if [ ! -z "$6" ]
259269
then
@@ -286,12 +296,12 @@ fi
286296

287297
AD_GUARD='0'
288298
echo
289-
read -p 'Install AdGuard-Blocker? Need external USB-Device [y/N] ' -s -n 1 ADGUARD_ACTIVE
299+
read -p 'Install AdGuard-Blocker? Need external USB-Device [y/N] ' -s -n 1 qADGUARD_ACTIVE
290300

291-
if [ "$ADGUARD_ACTIVE" = "" ]
301+
if [ "$qADGUARD_ACTIVE" = "" ]
292302
then
293303
AD_GUARD='0'
294-
elif [ "$ADGUARD_ACTIVE" = "y" ]
304+
elif [ "$qADGUARD_ACTIVE" = "y" ]
295305
then
296306
AD_GUARD='1'
297307
else
@@ -301,11 +311,11 @@ fi
301311
echo
302312
TOR_ONION='0'
303313
echo
304-
read -p 'Use TOR(Onion)-Network? [Y/n] ' -s -n 1 TOR_ACTIVE
305-
if [ "$TOR_ACTIVE" = "" ]
314+
read -p 'Use TOR(Onion)-Network? [Y/n] ' -s -n 1 qTOR_ACTIVE
315+
if [ "$qTOR_ACTIVE" = "" ]
306316
then
307317
TOR_ONION='1'
308-
elif [ "$TOR_ACTIVE" = "y" ]
318+
elif [ "$qTOR_ACTIVE" = "y" ]
309319
then
310320
TOR_ONION='1'
311321
else
@@ -314,80 +324,81 @@ fi
314324

315325
echo
316326

317-
SDNS_PORT='y'
327+
qSDNS_PORT='y'
318328
DNSMASQ_Relay_port='53'
319329
echo
320330

321331
STUBBY='1'
322332
DNS_IP='127.0.0.1'
323-
read -p 'DNS-Relay to STUBBY [Y/n] ' -s -n 1 SDNS_PORT
333+
read -p 'DNS-Relay to STUBBY [Y/n] ' -s -n 1 qSDNS_PORT
324334

325335

326-
if [ "$SDNS_PORT" = "" ]
336+
if [ "$qSDNS_PORT" = "" ]
327337
then
328338
STUBBY='1'
329339
elif [ "$SNDS_PORT" = "y" ]
330340
then
331341
STUBBY='1'
332342
else
333343
STUBBY='0'
334-
DNSMASQ_relay_port='53'
344+
DNSMASQ_relay_port=$DNS_port
345+
DNS_PORT=$qDNS_PORT
335346
DNS_IP=$INET_GW
336347
fi
337348
echo $DNS_IP
338349
echo
339-
DNS_PORT='y'
340-
read -p 'DNS-Relay to UNBOUND-DNS? [Y/n] ' -s -n 1 DNS_PORT
350+
qDNS_PORT='y'
351+
read -p 'DNS-Relay to UNBOUND-DNS? [Y/n] ' -s -n 1 qDNS_PORT
341352
UNBOUND='1'
342-
if [ "$DNS_PORT" = "" ]
353+
if [ "$qDNS_PORT" = "" ]
343354
then
344355
UNBOUND='1'
345-
DNSMASQ_Relay_port='5353'
356+
DNSMASQ_Relay_port=$DNSMASQ_port
346357
if [ "$TOR_ONION" = "1" ]
347358
then
348-
UNBOUND_Relay_port='9053'
359+
UNBOUND_Relay_port=$DNS_TOR_port
349360
elif [ "$STUBBY" = "0" ]
350361
then
351-
UNBOUND_Relay_port='53'
362+
UNBOUND_Relay_port=$DNS_port
352363
else
353-
UNBOUND_Relay_port='5453'
364+
UNBOUND_Relay_port=$DNS_STUBBY_port
354365
fi
355-
elif [ "$DNS_PORT" = "y" ]
366+
elif [ "$qDNS_PORT" = "y" ]
356367
then
357368
UNBOUND='1'
358-
DNSMASQ_Relay_port='5353'
369+
DNSMASQ_Relay_port=$DNSMASQ_port
359370
if [ "$TOR_ONION" = "1" ]
360371
then
361-
UNBOUND_Relay_port='9053'
372+
UNBOUND_Relay_port=$DNS_TOR_port
362373
elif [ "$STUBBY" = "0" ]
363374
then
364-
UNBOUND_Relay_port='53'
375+
UNBOUND_Relay_port=$DNS_port
365376
else
366-
UNBOUND_Relay_port='5453'
377+
UNBOUND_Relay_port=$DNS_STUBBY_port
367378
fi
368379
elif [ "$TOR_ONION" = "1" ]
369380
then
370-
DNSMASQ_Relay_port='9053'
371-
UNBOUND_Relay_port='9053'
381+
DNSMASQ_Relay_port=$DNS_TOR_port
382+
UNBOUND_Relay_port=$DNS_TOR_port
372383
UNBOUND='0'
373384
elif [ "$STUBBY" = "0" ]
374385
then
375-
DNSMASQ_Relay_port='53'
376-
UNBOUND_Relay_port='53'
386+
DNSMASQ_Relay_port=$DNS_port
387+
UNBOUND_Relay_port=$DNS_port
377388
UNBOUND='0'
378389
else
379-
DNSMASQ_Relay_port='5453'
380-
UNBOUND_Relay_port='5453'
390+
DNSMASQ_Relay_port=$DNS_STUBBY_port
391+
UNBOUND_Relay_port=$DNS_STUBBY_port
381392
UNBOUND='0'
382393
fi
383394
VLAN_ENABLE='0'
384395
echo
385396
echo
386-
read -p 'Would you like separate Networks for each Device-Category? [Y/n] ' -s -n 1 VLAN_ACTIVE
387-
if [ "$VLAN_ACTIVE" = "" ]
397+
read -p 'Would you like separate Networks for each Device-Category? [Y/n] ' -s -n 1 qVLAN_ACTIVE
398+
if [ "$qVLAN_ACTIVE" = "" ]
388399
then
389400
VLAN_ENABLE='1'
390-
elif [ "$VLAN_ACTIVE" = "y" ]
401+
elif [ "$qVLAN_ACTIVE" = "y" ]
391402
then
392403
VLAN_ENABLE='1'
393404
else
@@ -399,19 +410,19 @@ echo
399410

400411
if [ ! -z "$7" ]
401412
then
402-
SECURE_RULESW=$7
413+
qSECURE_RULES=$7
403414
else
404-
SECURE_RULES='y'
415+
qSECURE_RULES='y'
405416
fi
406417

407418
echo
408-
read -p 'Activate HighSecure-Firewall? [Y/n] ' -s -n 1 SECURE_RULES
419+
read -p 'Activate HighSecure-Firewall? [Y/n] ' -s -n 1 qSECURE_RULES
409420

410-
if [ "$SECURE_RULES" = "" ]
421+
if [ "$qSECURE_RULES" = "" ]
411422
then
412423
FW_HSactive='1'
413424
# set_HS_Firewall
414-
elif [ "$SECURE_RULES" = "y" ]
425+
elif [ "$qSECURE_RULES" = "y" ]
415426
then
416427
FW_HSactive='1'
417428
#set_HS_Firewall
@@ -753,6 +764,8 @@ all_other_CONTROLER_port="1-8042 8044-65535"
753764
mDNS_port="5353"
754765
all_other_mDNS_port="1-5352 5354-65535"
755766

767+
768+
756769
#Link Local Multicast Name Resolution (LLMNR)
757770
#5357
758771
LLMNR_port="5357"
@@ -947,6 +960,8 @@ ACCESS_HTTPS_port="8443"
947960
#TOR Onion Services
948961
TOR_SOCKS_port="9050"
949962
TOR_SOCKS2_port="9150"
963+
TOR_SOCKS3_port="9100"
964+
TOR_SOCKS4_port="9200"
950965
TOR_TRANS_port="9040"
951966
TOR_DIR_port="9030"
952967
TOR_OR_port="9049"
@@ -1256,6 +1271,8 @@ iptab_ACCESS_HTTPS_port="8443"
12561271
#TOR Onion Services
12571272
iptab_TOR_SOCKS_port="9050"
12581273
iptab_TOR_SOCKS2_port="9150"
1274+
iptab_TOR_SOCKS3_port="9100"
1275+
iptab_TOR_SOCKS4_port="9200"
12591276
iptab_TOR_TRANS_port="9040"
12601277
iptab_TOR_DIR_port="9030"
12611278
iptab_TOR_OR_port="9049"
@@ -3082,23 +3099,23 @@ VirtualAddrNetworkIPv6 fc00::/7
30823099

30833100
ControlPort 9051
30843101
CookieAuthentication 1
3085-
DNSPort 127.0.0.1:9053
3086-
DNSPort 127.0.0.1:9153
3087-
DNSPort 0.0.0.0:9053
3088-
DNSPort [::]:9053
3102+
DNSPort 127.0.0.1:$(echo $DNS_TOR_port)
3103+
DNSPort [0::1]:$(echo $DNS_TOR_port)
3104+
DNSPort 0.0.0.0:$(echo $DNS_TOR_port)
3105+
DNSPort [::]:$(echo $DNS_TOR_port)
30893106

3090-
TransPort 0.0.0.0:9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3091-
TransPort [::]:9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3092-
#TransPort 9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3093-
SocksPort 9050 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3094-
SocksPort 9150 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3095-
SocksPort 9100 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3096-
SocksPort 9200 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3107+
TransPort 0.0.0.0:$(echo $TOR_TRANS_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3108+
TransPort [::]:$(echo $TOR_TRANS_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3109+
#TransPort $(echo $TOR_TRANS_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3110+
SocksPort $(echo $TOR_SOCKS_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3111+
SocksPort $(echo $TOR_SOCKS2_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3112+
SocksPort $(echo $TOR_SOCKS3_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3113+
SocksPort $(echo $TOR_SOCKS4_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
30973114

3098-
#ORPort 127.0.0.1:9049
3099-
#DirPort 9030
3115+
#ORPort 127.0.0.1:$(echo $TOR_OR_port) NoListen
3116+
#DirPort $(echo $TOR_DIR_port) NoListen
31003117

3101-
HTTPTunnelPort 9060 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
3118+
HTTPTunnelPort $(echo $TOR_THTTP_port) IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
31023119

31033120
DisableDebuggerAttachment 1
31043121
DisableAllSwap 1
@@ -3415,9 +3432,10 @@ uci set unbound.ub_main.verbosity='1'
34153432

34163433
uci add_list unbound.ub_main.outgoing_port_permit=$SDNS_port
34173434
uci add_list unbound.ub_main.outgoing_port_permit=$TOR_SOCKS_port
3418-
uci add_list unbound.ub_main.outgoing_port_permit='9150'
3435+
uci add_list unbound.ub_main.outgoing_port_permit=$TOR_SOCKS2_port
34193436
uci add_list unbound.ub_main.outgoing_port_permit=$DNS_TOR_port
3420-
uci add_list unbound.ub_main.outgoing_port_permit='9153'
3437+
uci add_list unbound.ub_main.outgoing_port_permit=$TOR_SOCKS3_port
3438+
uci add_list unbound.ub_main.outgoing_port_permit=$TOR_SOCKS4_port
34213439
uci add_list unbound.ub_main.outgoing_port_avoid='1-9029'
34223440
uci add_list unbound.ub_main.outgoing_port_avoid='9061-65335'
34233441

@@ -32165,8 +32183,6 @@ echo 'set Tor intercept' >> /root/install.log
3216532183
uci set firewall.ssh_int.enabled='1'
3216632184
uci set firewall.http_int.enabled='1'
3216732185
uci set firewall.https_int.enabled='1'
32168-
uci set firewall.tcp_tor1_int.enabled='1'
32169-
uci set firewall.tcp_tor2_int.enabled='1'
3217032186
processes=$(uci commit && reload_config)
3217132187
wait $processes >> /root/install.log
3217232188

@@ -32306,6 +32322,19 @@ uci set firewall.homematic1.extra='--syn'
3230632322
uci set firewall.homematic1.enabled='0'
3230732323
}
3230832324

32325+
test_tor_dns_intercept() {
32326+
uci -q del firewall.dns_int
32327+
uci set firewall.dns_int="redirect"
32328+
uci set firewall.dns_int.name="Intercept-DNS"
32329+
uci set firewall.dns_int.family="any"
32330+
uci set firewall.dns_int.proto="tcp udp"
32331+
uci set firewall.dns_int.src="lan"
32332+
uci set firewall.dns_int.src_dport=$DNSPort
32333+
uci set firewall.dns_int.target="DNAT"
32334+
uci commit firewall
32335+
service firewall restart
32336+
}
32337+
3230932338
setup_tor_routing() {
3231032339
iptables -t nat -A PREROUTING -i inet -p tcp --syn -j REDIRECT --to-ports $TOR_TRANS_port
3231132340
iptables -A FORWARD -i inet -o wan -j ACCEPT

0 commit comments

Comments
 (0)