-
Notifications
You must be signed in to change notification settings - Fork 0
/
killmon-1.1.2.sh
1360 lines (1195 loc) · 56.7 KB
/
killmon-1.1.2.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
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
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# KILLMON v1.1.2 - Asus-Merlin IP4/IP6 Kill Switch Monitor & Configurator by Viktor Jaep, 2022
#
# KILLMON is a shell script that provides additional capabilities outside of the VPN kill switch functionality that is
# currently integrated into the Asus-Merlin Firmware. KILLMON builds on the excellent kill switch script originally
# provided by @Eibgrad, and provides a user interface to help monitor, enable, or disable kill switch operations, as well
# as allowing you to choose how to implement the kill switch for both IP4 and IP6 traffic. Currently, KILLMON provides
# traffic kill modes for 3 different scenarios...
#
# (1) Paranoid mode - All LAN traffic is forbidden from using the current WAN interface
# (2) IP Range mode - All LAN traffic within specified IP Range is forbidden from using the current WAN interface
# (3) Single IP mode - All LAN traffic on specified IP is forbidden from using the current WAN interface
#
# In each instance,a valid VPN tunnel must be up and running for traffic to make it out to the internet, preventing any
# possible traffic leaks while a VPN tunnel is down, thus the necessity for a kill switch.
#
# IMPORTANT NOTE: Many kill switches do not consider IP6, or recommend just completely disabling IP6 on the router itself.
# KILLMON may very well be one of the first kill switches that both embraces and kills the sh*t out of unwanted IP6 traffic
# when your VPN connection goes down. Please note that if IPv6 is enabled on your router and are using a kill switch of any
# kind that does not specifically block IP6, any and all traffic that utilizes IPv6 addressing will be leaking traffic
# around your IP4 VPN tunnel over your WAN when it goes down.
#Preferred standard router binaries path
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH"
# -------------------------------------------------------------------------------------------------------------------------
# System Variables (Do not change beyond this point or this may change the programs ability to function correctly)
# -------------------------------------------------------------------------------------------------------------------------
Version="1.1.2"
Beta=0
APPPATH="/jffs/scripts/killmon.sh"
CFGPATH="/jffs/addons/killmon.d/killmon.cfg"
LOGFILE="/jffs/addons/killmon.d/killmon.log"
DLVERPATH="/jffs/addons/killmon.d/version.txt"
FW_CHAIN="KILLMON"
FW6_CHAIN="KILLMON6"
killswitchstatus="DISABLED" # ENABLED OR DISABLED
killswitch6status="DISABLED" # ENABLED OR DISABLED
killswitchautostart="DISABLED" # ENABLED OR DISABLED
killswitchmode="INACTIVE" # PARANOID, IP RANGE, SINGLEIP, OR INACTIVE
killswitch6mode="INACTIVE" # PARANOID, IP RANGE, SINGLEIP, OR INACTIVE
iprangenotation=1 # 0=CIDR, 1=Range
ip6rangenotation=1 # 0=CIDR, 1=Range
iprangecidr="192.168.1.0/24"
ip6rangecidr="2601:04c1:417f:e91c:0000:0000:0000:0000/64" # Local IPv6 Subnet /64
iprangefrom="192.168.1.50"
ip6rangefrom="2601:04c1:417f:e91c:0000:0000:0000:0000" # Local IPv6 Subnet Start
iprangeto="192.168.1.60"
ip6rangeto="2601:04c1:417f:e91c:0000:0000:0000:000f" # Local IPv6 Subnet End with 16 sample usable addresses
ipsingle="192.168.1.150"
ip6single="fe80::92ca:faff:fe22:97bf"
WANIFUSED=0 # 0=WAN0, 1=WAN1, OR 2=WAN0/1
WAN0IFNAME="eth0"
WAN1IFNAME="None"
hideoptions=1
# Color variables
CBlack="\e[1;30m"
InvBlack="\e[1;40m"
CRed="\e[1;31m"
InvRed="\e[1;41m"
CGreen="\e[1;32m"
InvGreen="\e[1;42m"
CDkGray="\e[1;90m"
InvDkGray="\e[1;100m"
InvLtGray="\e[1;47m"
CYellow="\e[1;33m"
InvYellow="\e[1;43m"
CBlue="\e[1;34m"
InvBlue="\e[1;44m"
CMagenta="\e[1;35m"
CCyan="\e[1;36m"
InvCyan="\e[1;46m"
CWhite="\e[1;37m"
InvWhite="\e[1;107m"
CClear="\e[0m"
# -------------------------------------------------------------------------------------------------------------------------
# Functions
# -------------------------------------------------------------------------------------------------------------------------
# LogoNM is a function that displays the RTRMON script name in a cool ASCII font without menu options
logoNM () {
echo -e "${CYellow} __ __ ______ __ __ _______ _ __"
echo -e " / //_// _/ / / / / |/ / __ \/ | / / ${CGreen}v$Version${CYellow}"
echo -e " / ,< / // / / / / /|_/ / / / / |/ /"
echo -e " / /| |_/ // /___/ /___/ / / / /_/ / /| /"
echo -e " /_/ |_/___/_____/_____/_/ /_/\____/_/ |_/${CClear}"
}
# LogoNM is a function that displays the RTRMON script name in a cool ASCII font without menu options
logo () {
echo -e "${CYellow} __ __ ______ __ __ _______ _ __"
echo -e " / //_// _/ / / / / |/ / __ \/ | / / ${CGreen}v$Version${CYellow}"
echo -e " / ,< / // / / / / /|_/ / / / / |/ / ${CRed}(S)${CGreen}etup${CYellow}"
echo -e " / /| |_/ // /___/ /___/ / / / /_/ / /| / ${CRed}(I)${CGreen}structions${CYellow}"
echo -e " /_/ |_/___/_____/_____/_/ /_/\____/_/ |_/ ${CRed}(E)${CGreen}xit${CClear}"
}
# -------------------------------------------------------------------------------------------------------------------------
# promptyn takes input for Y/N questions
promptyn () { # No defaults, just y or n
while true; do
read -p "[y/n]? " -n 1 -r yn
case "${yn}" in
[Yy]* ) return 0 ;;
[Nn]* ) return 1 ;;
* ) echo -e "\nPlease answer y or n.";;
esac
done
}
# -------------------------------------------------------------------------------------------------------------------------
# Separated these out to get the ifname for a dual-wan/failover situation where both WAN connections are on
get_wan_setting0() {
local varname varval
varname="${1}"
prefixes="wan0_"
if [ "$($timeoutcmd$timeoutsec nvram get wans_mode)" = "lb" ] ; then
for prefix in $prefixes; do
state="$($timeoutcmd$timeoutsec nvram get "${prefix}"state_t)"
sbstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"sbstate_t)"
auxstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"auxstate_t)"
# is_wan_connect()
[ "${state}" = "2" ] || continue
[ "${sbstate}" = "0" ] || continue
[ "${auxstate}" = "0" ] || [ "${auxstate}" = "2" ] || continue
# get_wan_ifname()
proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)"
if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")"
else
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")"
fi
done
else
for prefix in $prefixes; do
primary="$($timeoutcmd$timeoutsec nvram get "${prefix}"primary)"
[ "${primary}" = "1" ] && break
done
proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)"
if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")"
else
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")"
fi
fi
printf "%s" "${varval}"
} # get_wan_setting
# Separated these out to get the ifname for a dual-wan/failover situation where both WAN connections are on
get_wan_setting1() {
local varname varval
varname="${1}"
prefixes="wan1_"
if [ "$($timeoutcmd$timeoutsec nvram get wans_mode)" = "lb" ] ; then
for prefix in $prefixes; do
state="$($timeoutcmd$timeoutsec nvram get "${prefix}"state_t)"
sbstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"sbstate_t)"
auxstate="$($timeoutcmd$timeoutsec nvram get "${prefix}"auxstate_t)"
# is_wan_connect()
[ "${state}" = "2" ] || continue
[ "${sbstate}" = "0" ] || continue
[ "${auxstate}" = "0" ] || [ "${auxstate}" = "2" ] || continue
# get_wan_ifname()
proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)"
if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")"
else
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")"
fi
done
else
for prefix in $prefixes; do
primary="$($timeoutcmd$timeoutsec nvram get "${prefix}"primary)"
[ "${primary}" = "1" ] && break
done
proto="$($timeoutcmd$timeoutsec nvram get "${prefix}"proto)"
if [ "${proto}" = "pppoe" ] || [ "${proto}" = "pptp" ] || [ "${proto}" = "l2tp" ] ; then
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}"pppoe_"${varname}")"
else
varval="$($timeoutcmd$timeoutsec nvram get "${prefix}""${varname}")"
fi
fi
printf "%s" "${varval}"
} # get_wan_setting
# -------------------------------------------------------------------------------------------------------------------------
# iptables commands for the various modes
paranoidmode () {
iptables -N $FW_CHAIN
if [ $WANIFUSED -eq 0 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -i br+ -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -i br+ -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -i br+ -o $WAN0IFNAME -j REJECT
iptables -A $FW_CHAIN -i br+ -o $WAN1IFNAME -j REJECT
fi
}
paranoidmode6 () {
ip6tables -N $FW6_CHAIN
if [ $WANIFUSED -eq 0 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -i br+ -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -i br+ -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -i br+ -o $WAN0IFNAME -j REJECT
ip6tables -A $FW6_CHAIN -i br+ -o $WAN1IFNAME -j REJECT
fi
}
iprangemode () {
iptables -N $FW_CHAIN
if [ $iprangenotation -eq 0 ]; then
if [ $WANIFUSED -eq 0 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $iprangecidr -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $iprangecidr -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $iprangecidr -o $WAN0IFNAME -j REJECT
iptables -A $FW_CHAIN -s $iprangecidr -o $WAN1IFNAME -j REJECT
fi
elif [ $iprangenotation -eq 1 ]; then
if [ $WANIFUSED -eq 0 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -m iprange --src-range $iprangefrom"-"$iprangeto -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -m iprange --src-range $iprangefrom"-"$iprangeto -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -m iprange --src-range $iprangefrom"-"$iprangeto -j REJECT
fi
fi
}
iprangemode6 () {
ip6tables -N $FW6_CHAIN
if [ $ip6rangenotation -eq 0 ]; then
if [ $WANIFUSED -eq 0 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6rangecidr -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6rangecidr -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6rangecidr -o $WAN0IFNAME -j REJECT
ip6tables -A $FW6_CHAIN -s $ip6rangecidr -o $WAN1IFNAME -j REJECT
fi
elif [ $ip6rangenotation -eq 1 ]; then
if [ $WANIFUSED -eq 0 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -m iprange --src-range $ip6rangefrom"-"$ip6rangeto -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -m iprange --src-range $ip6rangefrom"-"$ip6rangeto -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -m iprange --src-range $ip6rangefrom"-"$ip6rangeto -j REJECT
fi
fi
}
singleipmode () {
iptables -N $FW_CHAIN
if [ $WANIFUSED -eq 0 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $ipsingle -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $ipsingle -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
iptables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN
iptables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN
iptables -A $FW_CHAIN -s $ipsingle -o $WAN0IFNAME -j REJECT
iptables -A $FW_CHAIN -s $ipsingle -o $WAN1IFNAME -j REJECT
fi
}
singleipmode6 () {
ip6tables -N $FW6_CHAIN
if [ $WANIFUSED -eq 0 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6single -o $WAN0IFNAME -j REJECT
elif [ $WANIFUSED -eq 1 ]; then
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6single -o $WAN1IFNAME -j REJECT
elif [ $WANIFUSED -eq 2 ]; then
ip6tables -I FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN
ip6tables -I FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN
ip6tables -A $FW6_CHAIN -s $ip6single -o $WAN0IFNAME -j REJECT
ip6tables -A $FW6_CHAIN -s $ip6single -o $WAN1IFNAME -j REJECT
fi
}
reverserules () {
# Reverse Paranoid Mode iptables rules
iptables -D $FW_CHAIN -i br+ -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
iptables -D $FW_CHAIN -i br+ -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
# Reverse IP Range Mode iptables rules
iptables -D $FW_CHAIN -s $iprangecidr -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
iptables -D $FW_CHAIN -s $iprangecidr -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
iptables -D $FW_CHAIN -m iprange --src-range $iprangefrom"-"$iprangeto -j REJECT >/dev/null 2>/dev/null
# Reverse Single IP Mode iptables rules
iptables -D $FW_CHAIN -s $ipsingle -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
iptables -D $FW_CHAIN -s $ipsingle -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
# Remove custom chain name
iptables -D FORWARD -i br+ -o $WAN0IFNAME -j $FW_CHAIN >/dev/null 2>/dev/null
iptables -D FORWARD -i br+ -o $WAN1IFNAME -j $FW_CHAIN >/dev/null 2>/dev/null
iptables -F $FW_CHAIN >/dev/null 2>/dev/null && iptables -X $FW_CHAIN >/dev/null 2>/dev/null
}
reverserules6 () {
# Reverse Paranoid Mode ip6tables rules
ip6tables -D $FW6_CHAIN -i br+ -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
ip6tables -D $FW6_CHAIN -i br+ -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
# Reverse IP Range Mode iptables rules
ip6tables -D $FW6_CHAIN -s $ip6rangecidr -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
ip6tables -D $FW6_CHAIN -s $ip6rangecidr -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
ip6tables -D $FW6_CHAIN -m iprange --src-range $ip6rangefrom"-"$ip6rangeto -j REJECT >/dev/null 2>/dev/null
# Reverse Single IP Mode iptables rules
ip6tables -D $FW6_CHAIN -s $ip6single -o $WAN0IFNAME -j REJECT >/dev/null 2>/dev/null
ip6tables -D $FW6_CHAIN -s $ip6single -o $WAN1IFNAME -j REJECT >/dev/null 2>/dev/null
# Remove custom chain name
ip6tables -D FORWARD -i br+ -o $WAN0IFNAME -j $FW6_CHAIN >/dev/null 2>/dev/null
ip6tables -D FORWARD -i br+ -o $WAN1IFNAME -j $FW6_CHAIN >/dev/null 2>/dev/null
ip6tables -F $FW6_CHAIN >/dev/null 2>/dev/null && ip6tables -X $FW6_CHAIN >/dev/null 2>/dev/null
}
# -------------------------------------------------------------------------------------------------------------------------
# vsetup is a function that sets up, confiures and allows you to launch RTRMON on your router...
vsetup () {
while true; do
clear
logoNM
echo ""
echo -e "${CYellow}Setup Utility${CClear}" # Provide main setup menu
echo ""
echo -e "${CGreen}----------------------------------------------------------------"
echo -e "${CGreen}Setup Operations"
echo -e "${CGreen}----------------------------------------------------------------"
echo -e "${InvDkGray}${CWhite} mc ${CClear}${CCyan}: Monitor and Configure KILLMON"
echo -e "${InvDkGray}${CWhite} fr ${CClear}${CCyan}: Force Re-install Entware Dependencies"
echo -e "${InvDkGray}${CWhite} up ${CClear}${CCyan}: Check for latest updates"
echo -e "${InvDkGray}${CWhite} vl ${CClear}${CCyan}: View logs"
echo -e "${InvDkGray}${CWhite} un ${CClear}${CCyan}: Uninstall"
echo -e "${InvDkGray}${CWhite} e ${CClear}${CCyan}: Exit"
echo -e "${CGreen}----------------------------------------------------------------"
echo ""
printf "Selection: "
read -r InstallSelection
# Execute chosen selections
case "$InstallSelection" in
mc) # Check for existence of entware, and if so proceed and install the timeout package
clear
if [ -f "/opt/bin/timeout" ]; then
sh $APPPATH -monitor
else
logoNM
echo ""
echo -e "${CYellow}Installing KILLMON Dependencies...${CClear}"
echo ""
echo -e "${CCyan}KILLMON will require the installation of CoreUtils-Timeout utility.${CClear}"
echo -e "${CCyan}These utilities require you to have Entware already installed using${CClear}"
echo -e "${CCyan}the AMTM tool. If Entware is present, the Timeout utility will be${CClear}"
echo -e "${CCyan}downloaded and installed during this setup process, and utilized by${CClear}"
echo -e "${CCyan}KILLMON${CClear}"
echo ""
echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}"
echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}"
echo -e "${CCyan}hang scripts running on this router model.${CClear}"
echo ""
[ -z "$($timeoutcmd$timeoutsec nvram get odmpid)" ] && RouterModel="$($timeoutcmd$timeoutsec nvram get productid)" || RouterModel="$($timeoutcmd$timeoutsec nvram get odmpid)" # Thanks @thelonelycoder for this logic
echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel"
echo ""
echo -e "${CCyan}Ready to install?${CClear}"
if promptyn "(y/n): "
then
if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out.
echo ""
echo -e "\n${CGreen}Updating Entware Packages...${CClear}"
echo ""
opkg update
echo ""
echo -e "${CGreen}Installing Entware CoreUtils-Timeout Package...${CClear}"
echo ""
opkg install coreutils-timeout
echo ""
read -rsp $'Press any key to continue...\n' -n1 key
echo ""
echo -e "${CGreen}Executing KILLMON Configuration Utility...${CClear}"
sleep 2
sh $APPPATH -monitor
else
clear
echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}"
echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}"
echo ""
sleep 3
fi
else
echo ""
echo -e "\n${CGreen}Executing KILLMON Configuration Utility...${CClear}"
sleep 2
sh $APPPATH -monitor
fi
fi
;;
fr) # Force re-install the CoreUtils timeout/screen package
clear
logoNM
echo ""
echo -e "${CYellow}Force Re-installing KILLMON Dependencies...${CClear}"
echo ""
echo -e "${CCyan}KILLMON will require the installation of CoreUtils-Timeout utility.${CClear}"
echo -e "${CCyan}These utilities require you to have Entware already installed using${CClear}"
echo -e "${CCyan}the AMTM tool. If Entware is present, the Timeout utility will be${CClear}"
echo -e "${CCyan}downloaded and installed during this setup process, and utilized by${CClear}"
echo -e "${CCyan}KILLMON${CClear}"
echo ""
echo -e "${CGreen}CoreUtils-Timeout${CCyan} is a utility that provides more stability for${CClear}"
echo -e "${CCyan}certain routers (like the RT-AC86U) which has a tendency to randomly${CClear}"
echo -e "${CCyan}hang scripts running on this router model.${CClear}"
echo ""
[ -z "$(nvram get odmpid)" ] && RouterModel="$(nvram get productid)" || RouterModel="$(nvram get odmpid)" # Thanks @thelonelycoder for this logic
echo -e "${CCyan}Your router model is: ${CYellow}$RouterModel"
echo ""
echo -e "${CCyan}Force Re-install?${CClear}"
if promptyn "(y/n): "
then
if [ -d "/opt" ]; then # Does entware exist? If yes proceed, if no error out.
echo ""
echo -e "\n${CGreen}Updating Entware Packages...${CClear}"
echo ""
opkg update
echo ""
echo -e "${CGreen}Force Re-installing Entware CoreUtils-Timeout Package...${CClear}"
echo ""
opkg install --force-reinstall coreutils-timeout
echo ""
echo -e "${CGreen}Re-install completed...${CClear}"
echo ""
read -rsp $'Press any key to continue...\n' -n1 key
else
clear
echo -e "${CGreen}ERROR: Entware was not found on this router...${CClear}"
echo -e "${CGreen}Please install Entware using the AMTM utility before proceeding...${CClear}"
echo ""
sleep 3
fi
fi
;;
up)
echo ""
vupdate
;;
vl)
echo ""
vlogs
;;
un)
echo ""
vuninstall
;;
[Ee])
echo -e "${CClear}"
exit 0
;;
*)
echo ""
echo -e "${CRed}Invalid choice - Please enter a valid option...${CClear}"
echo ""
sleep 2
;;
esac
done
}
# -------------------------------------------------------------------------------------------------------------------------
# updatecheck is a function that downloads the latest update version file, and compares it with what's currently installed
updatecheck () {
# Download the latest version file from the source repository
curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/KILLMON/master/version.txt" -o "/jffs/addons/killmon.d/version.txt"
if [ -f $DLVERPATH ]
then
# Read in its contents for the current version file
DLVersion=$(cat $DLVERPATH)
# Compare the new version with the old version and log it
if [ "$Beta" == "1" ]; then # Check if Dev/Beta Mode is enabled and disable notification message
UpdateNotify=0
elif [ "$DLVersion" != "$Version" ]; then
UpdateNotify="Update available: v$Version -> v$DLVersion"
echo -e "$(date) - KILLMON - A new update (v$DLVersion) is available to download" >> $LOGFILE
else
UpdateNotify=0
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# vupdate is a function that provides a UI to check for script updates and allows you to install the latest version...
vupdate () {
updatecheck # Check for the latest version from source repository
clear
logoNM
echo ""
echo -e "${CYellow}Update Utility${CClear}"
echo ""
echo -e "${CCyan}Current Version: ${CYellow}$Version${CClear}"
echo -e "${CCyan}Updated Version: ${CYellow}$DLVersion${CClear}"
echo ""
if [ "$Version" == "$DLVersion" ]
then
echo -e "${CCyan}You are on the latest version! Would you like to download anyways?${CClear}"
echo -e "${CCyan}This will overwrite your local copy with the current build.${CClear}"
if promptyn "(y/n): "; then
echo ""
echo -e "${CCyan}Downloading KILLMON ${CYellow}v$DLVersion${CClear}"
curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/killmon.sh" -o "/jffs/scripts/killmon.sh" && chmod a+rx "/jffs/scripts/killmon.sh"
echo ""
echo -e "${CCyan}Download successful!${CClear}"
echo -e "$(date) - KILLMON - Successfully downloaded KILLMON v$DLVersion" >> $LOGFILE
echo ""
read -rsp $'Press any key to continue...\n' -n1 key
exec sh /jffs/scripts/killmon.sh -setup
else
echo ""
echo ""
echo -e "${CGreen}Exiting Update Utility...${CClear}"
sleep 1
return
fi
else
echo -e "${CCyan}Score! There is a new version out there! Would you like to update?${CClear}"
if promptyn "(y/n): "; then
echo ""
echo -e "${CCyan}Downloading KILLMON ${CYellow}v$DLVersion${CClear}"
curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/KILLMON/master/killmon.sh" -o "/jffs/scripts/killmon.sh" && chmod a+rx "/jffs/scripts/killmon.sh"
echo ""
echo -e "${CCyan}Download successful!${CClear}"
echo -e "$(date) - KILLMON - Successfully downloaded KILLMON v$DLVersion" >> $LOGFILE
echo ""
read -rsp $'Press any key to continue...\n' -n1 key
exec sh /jffs/scripts/killmon.sh -setup
else
echo ""
echo ""
echo -e "${CGreen}Exiting Update Utility...${CClear}"
sleep 1
return
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# vlogs is a function that calls the nano text editor to view the RTRMON log file
vlogs() {
export TERM=linux
nano +999999 --linenumbers $LOGFILE
}
# -------------------------------------------------------------------------------------------------------------------------
# vuninstall is a function that uninstalls and removes all traces of RTRMON from your router...
vuninstall () {
clear
logoNM
echo ""
echo -e "${CYellow}Uninstall Utility${CClear}"
echo ""
echo -e "${CCyan}You are about to uninstall KILLMON! This action is irreversible."
echo -e "${CCyan}Do you wish to proceed?${CClear}"
if promptyn "(y/n): "; then
echo ""
echo -e "\n${CCyan}Are you sure? Please type 'Y' to validate you want to proceed.${CClear}"
if promptyn "(y/n): "; then
clear
reverserules
reverserules6
if [ -f /jffs/scripts/firewall-start ]; then
sed -i -e '/killmon.sh/d' /jffs/scripts/firewall-start
fi
rm -r /jffs/addons/killmon.d
rm /jffs/scripts/killmon.sh
echo ""
echo -e "\n${CGreen}KILLMON has been uninstalled...${CClear}"
echo ""
exit 0
else
echo ""
echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}"
sleep 1
return
fi
else
echo ""
echo -e "\n${CGreen}Exiting Uninstall Utility...${CClear}"
sleep 1
return
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# Save Config file
saveconfig () {
{ echo 'killswitchstatus="'"$killswitchstatus"'"' # ENABLED OR DISABLED
echo 'killswitchautostart="'"$killswitchautostart"'"' # ENABLED OR DISABLED
echo 'killswitchmode="'"$killswitchmode"'"' # PARANOID, IP RANGE, SINGLE IP OR INACTIVE
echo 'killswitch6status="'"$killswitch6status"'"' # ENABLED OR DISABLED
echo 'killswitch6mode="'"$killswitch6mode"'"' # PARANOID, IP RANGE, SINGLE IP, OR INACTIVE
echo 'iprangenotation='$iprangenotation
echo 'ip6rangenotation='$ip6rangenotation
echo 'iprangecidr="'"$iprangecidr"'"' # Local IPv4 Subnet in CIDR
echo 'ip6rangecidr="'"$ip6rangecidr"'"' # Local IPv6 Subnet in CIDR
echo 'iprangefrom="'"$iprangefrom"'"' # Local IPv4 Subnet Start
echo 'ip6rangefrom="'"$ip6rangefrom"'"' # Local IPv6 Subnet Start
echo 'iprangeto="'"$iprangeto"'"' # Local IPv4 Subnet End
echo 'ip6rangeto="'"$ip6rangeto"'"' # Local IPv6 Subnet End
echo 'ipsingle="'"$ipsingle"'"'
echo 'ip6single="'"$ip6single"'"'
echo 'WANIFUSED='$WANIFUSED # 0=WAN0, 1=WAN1, OR 2=WAN0/1
echo 'WAN0IFNAME="'"$WAN0IFNAME"'"'
echo 'WAN1IFNAME="'"$WAN1IFNAME"'"'
} > $CFGPATH
echo ""
echo -e "${CCyan}Applying config changes to KILLMON..."
#echo -e "$(date) - KILLMON - Successfully wrote a new config file" >> $LOGFILE
sleep 2
}
# -------------------------------------------------------------------------------------------------------------------------
# Begin Main Program
# -------------------------------------------------------------------------------------------------------------------------
#DEBUG=; set -x # uncomment/comment to enable/disable debug mode
#{ # uncomment/comment to enable/disable debug mode
# Create the necessary folder/file structure for RTRMON under /jffs/addons
if [ ! -d "/jffs/addons/killmon.d" ]; then
mkdir -p "/jffs/addons/killmon.d"
fi
# Check and see if any commandline option is being used
if [ $# -eq 0 ]
then
clear
sh /jffs/scripts/killmon.sh -monitor
exit 0
fi
# Check and see if an invalid commandline option is being used
if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "-log" ] || [ "$1" == "-setup" ] || [ "$1" == "-monitor" ] || [ "$1" == "-protect" ]
then
clear
else
clear
echo ""
echo "KILLMON v$Version"
echo ""
echo "Exiting due to invalid commandline options!"
echo "(run 'killmon -h' for help)"
echo ""
echo -e "${CClear}"
exit 0
fi
# Check to see if the help option is being called
if [ "$1" == "-h" ] || [ "$1" == "-help" ]
then
clear
echo ""
echo "KILLMON v$Version Commandline Option Usage:"
echo ""
echo "killmon -h | -help"
echo "killmon -log"
echo "killmon -setup"
echo "killmon -monitor"
echo "killmon -protect"
echo ""
echo " -h | -help (this output)"
echo " -log (displays the event log)"
echo " -setup (displays the setup menu)"
echo " -monitor (displays status and operations page)"
echo " -protect (populates iptables with kill switch rules)"
echo ""
echo -e "${CClear}"
exit 0
fi
# Check to see if the log option is being called, and display through nano
if [ "$1" == "-log" ]
then
vlogs
exit 0
fi
# Check to see if the populate option is being called
if [ "$1" == "-protect" ]
then
# Grab the config and read it in
if [ -f $CFGPATH ]; then
source $CFGPATH
else
clear
echo -e "${CRed}ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first."
echo -e "$(date) - KILLMON ------> ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first." >> $LOGFILE
echo -e "${CClear}"
exit 0
fi
if [ -f "/opt/bin/timeout" ] # If the timeout utility is available then use it and assign variables
then
timeoutcmd="timeout "
timeoutsec="10"
timeoutlng="60"
else
timeoutcmd=""
timeoutsec=""
timeoutlng=""
fi
# Find the current WAN0/1 Interface Names
WAN0IFNAME=$(get_wan_setting0 ifname)
WAN1IFNAME=$(get_wan_setting1 ifname)
# Determine if IPv6 is enabled
if [ "$($timeoutcmd$timeoutsec nvram get ipv6_service)" = "disabled" ] ; then
ipv6service=0
killswitch6status="DISABLED"
else
ipv6service=1
fi
# Delete any possible previous rules
if [ $ipv6service -eq 0 ]; then
reverserules
else
reverserules
reverserules6
fi
# Write the currently configured Kill Switch IP4 Rules to the iptables
if [ "$killswitchstatus" == "ENABLED" ]; then
if [ "$killswitchmode" == "PARANOID" ]; then
paranoidmode
elif [ "$killswitchmode" == "IP RANGE" ]; then
iprangemode
elif [ "$killswitchmode" == "SINGLEIP" ]; then
singleipmode
else
clear
echo -e "${CRed}ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first."
echo -e "$(date) - KILLMON ------> ERROR: KILLMON is not configured. Please run 'killmon.sh -setup'." >> $LOGFILE
sleep 3
fi
echo -e "${CGreen}INFO: KILLMON applied IP4 kill switch rules on firewall-start/router restart."
echo -e "$(date) - KILLMON - INFO: KILLMON applied IP4 kill switch rules on firewall-start/router restart." >> $LOGFILE
else
clear
echo -e "${CRed}ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first."
echo -e "$(date) - KILLMON ------> ERROR: KILLMON is not configured. Please run 'killmon.sh -setup'." >> $LOGFILE
sleep 3
fi
# Write the currently configured Kill Switch IP6 Rules to the iptables
if [ $ipv6service -ne 0 ]; then
if [ "$killswitch6status" == "ENABLED" ]; then
if [ "$killswitch6mode" == "PARANOID" ]; then
paranoidmode6
elif [ "$killswitch6mode" == "IP RANGE" ]; then
iprangemode6
elif [ "$killswitch6mode" == "SINGLEIP" ]; then
singleipmode6
else
clear
echo -e "${CRed}ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first."
echo -e "$(date) - KILLMON ------> ERROR: KILLMON is not configured. Please run 'killmon.sh -setup'." >> $LOGFILE
sleep 3
fi
echo -e "${CGreen} INFO: KILLMON applied IP6 kill switch rules on firewall-start/router restart."
echo -e "$(date) - KILLMON - INFO: KILLMON applied IP6 kill switch rules on firewall-start/router restart." >> $LOGFILE
else
clear
echo -e "${CRed} ERROR: KILLMON is not configured. Please run 'killmon.sh -setup' first."
echo -e "$(date) - KILLMON ------> ERROR: KILLMON is not configured. Please run 'killmon.sh -setup'." >> $LOGFILE
sleep 3
fi
fi
echo -e "${CClear}"
exit 0
fi
# Check to see if the setup option is being called
if [ "$1" == "-setup" ]
then
vsetup
fi
# Check to see if the monitor option is being called
if [ "$1" == "-monitor" ]
then
# Check for and add an alias for RTRMON
if ! grep -F "sh /jffs/scripts/killmon.sh" /jffs/configs/profile.add >/dev/null 2>/dev/null; then
echo "alias killmon=\"sh /jffs/scripts/killmon.sh\" # KILLMON" >> /jffs/configs/profile.add
fi
if [ -f "/opt/bin/timeout" ] # If the timeout utility is available then use it and assign variables
then
timeoutcmd="timeout "
timeoutsec="10"
timeoutlng="60"
else
timeoutcmd=""
timeoutsec=""
timeoutlng=""
fi
# Determine if IPv6 is enabled
if [ "$($timeoutcmd$timeoutsec nvram get ipv6_service)" = "disabled" ]; then
ipv6service=0
killswitch6status="DISABLED"
else
ipv6service=1
fi
sleep 1
fi
while true; do
if [ -f $CFGPATH ]; then
source $CFGPATH
fi
# Check for Updates
updatecheck
WAN0IFNAME=$(get_wan_setting0 ifname)
WAN1IFNAME=$(get_wan_setting1 ifname)
clear
logo
if [ "$UpdateNotify" != "0" ]; then
echo -e "${CRed} $UpdateNotify${CClear}"
echo ""
else
echo ""
fi
echo -e "${InvDkGray}${CWhite} Status ${CClear}"
echo ""
if [ $ipv6service -eq 0 ]; then
if [ "$killswitchstatus" == "DISABLED" ]; then
echo -e "${InvRed} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvRed}${CWhite}DISABLED ${CClear} | ${InvDkGray} ${CClear}${CWhite} IP6 Protocol ${CClear}: ${InvDkGray}${CWhite}DISABLED ${CClear}"
elif [ "$killswitchstatus" == "ENABLED" ]; then
echo -e "${InvGreen} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvGreen}${CWhite}ENABLED ${CClear} | ${InvDkGray} ${CClear}${CWhite} IP6 Protocol ${CClear}: ${InvDkGray}${CWhite}DISABLED ${CClear}"
fi
else
if [ "$killswitchstatus" == "DISABLED" ] && [ "$killswitch6status" == "DISABLED" ]; then
echo -e "${InvRed} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvRed}${CWhite}DISABLED ${CClear} | ${InvRed} ${CClear}${CWhite} IP6 Kill Switch ${CClear}: ${InvRed}${CWhite}DISABLED ${CClear}"
elif [ "$killswitchstatus" == "ENABLED" ] && [ "$killswitch6status" == "DISABLED" ]; then
echo -e "${InvGreen} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvGreen}${CWhite}ENABLED ${CClear} | ${InvRed} ${CClear}${CWhite} IP6 Kill Switch ${CClear}: ${InvRed}${CWhite}DISABLED ${CClear}"
elif [ "$killswitchstatus" == "DISABLED" ] && [ "$killswitch6status" == "ENABLED" ]; then
echo -e "${InvRed} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvRed}${CWhite}DISABLED ${CClear} | ${InvGreen} ${CClear}${CWhite} IP6 Kill Switch ${CClear}: ${InvGreen}${CWhite}ENABLED ${CClear}"
elif [ "$killswitchstatus" == "ENABLED" ] && [ "$killswitch6status" == "ENABLED" ]; then
echo -e "${InvGreen} ${CClear}${CWhite} IP4 Kill Switch ${CClear}: ${InvGreen}${CWhite}ENABLED ${CClear} | ${InvGreen} ${CClear}${CWhite} IP6 Kill Switch ${CClear}: ${InvGreen}${CWhite}ENABLED ${CClear}"
fi
fi
if [ $ipv6service -eq 0 ]; then
KILLMONRULESCHECK=$(iptables -L | grep -c "KILLMON")
if [ $KILLMONRULESCHECK -eq 0 ]; then
echo -e "${InvRed} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvRed}${CWhite}NOT FOUND${CClear} |"
elif [ $KILLMONRULESCHECK -gt 0 ]; then
echo -e "${InvGreen} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvGreen}${CWhite}VERIFIED ${CClear} |"
fi
else
KILLMONRULESCHECK=$(iptables -L | grep -c "KILLMON")
KILLMONRULES6CHECK=$(ip6tables -L | grep -c "KILLMON")
if [ $KILLMONRULESCHECK -eq 0 ] && [ $KILLMONRULES6CHECK -eq 0 ]; then
echo -e "${InvRed} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvRed}${CWhite}NOT FOUND${CClear} | ${InvRed} ${CClear}${CWhite} ip6tables Rules ${CClear}: ${InvRed}${CWhite}NOT FOUND${CClear}"
elif [ $KILLMONRULESCHECK -gt 0 ] && [ $KILLMONRULES6CHECK -eq 0 ]; then
echo -e "${InvGreen} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvGreen}${CWhite}VERIFIED ${CClear} | ${InvRed} ${CClear}${CWhite} ip6tables Rules ${CClear}: ${InvRed}${CWhite}NOT FOUND${CClear}"
elif [ $KILLMONRULESCHECK -eq 0 ] && [ $KILLMONRULES6CHECK -gt 0 ]; then
echo -e "${InvRed} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvRed}${CWhite}NOT FOUND${CClear} | ${InvGreen} ${CClear}${CWhite} ip6tables Rules ${CClear}: ${InvGreen}${CWhite}VERIFIED ${CClear}"
elif [ $KILLMONRULESCHECK -gt 0 ] && [ $KILLMONRULES6CHECK -gt 0 ]; then
echo -e "${InvGreen} ${CClear}${CWhite} iptables Rules ${CClear}: ${InvGreen}${CWhite}VERIFIED ${CClear} | ${InvGreen} ${CClear}${CWhite} ip6tables Rules ${CClear}: ${InvGreen}${CWhite}VERIFIED ${CClear}"
fi
fi
if [ "$killswitchautostart" == "DISABLED" ]; then
echo -en "${InvRed} ${CClear}${CWhite} Reboot Protection ${CClear}: "
printf "${InvRed}${CWhite}DISABLED ${CClear} |"; printf "%s\n"
else
echo -en "${InvGreen} ${CClear}${CWhite} Reboot Protection ${CClear}: "
printf "${InvGreen}${CWhite}ENABLED ${CClear} |"; printf "%s\n"
fi
echo -e "${CWhite} ${CClear}${CCyan}"
if [ $ipv6service -eq 0 ]; then
echo -e "${InvDkGray}${CWhite} ${CClear}${CWhite} IP4 Kill Mode ${CClear}: ${CGreen}$killswitchmode${CClear}"
else
echo -e "${InvDkGray}${CWhite} ${CClear}${CWhite} IP4 Kill Mode ${CClear}: ${CGreen}$killswitchmode${CClear} | ${InvDkGray}${CWhite} ${CClear}${CWhite} IP6 Kill Mode ${CClear}: ${CGreen}$killswitch6mode${CClear}"
fi
echo ""
echo -en "${InvDkGray}${CWhite} ${CClear}${CWhite} IP4(s) affected ${CClear}: ${CGreen}"
if [ $iprangenotation -eq 0 ] && [ "$killswitchmode" == "IP RANGE" ]; then
printf $iprangecidr; printf "%s\n"
elif [ $iprangenotation -eq 1 ] && [ "$killswitchmode" == "IP RANGE" ]; then
printf $iprangefrom"-"$iprangeto; printf "%s\n"
elif [ ! -z "$ipsingle" ] && [ "$killswitchmode" == "SINGLEIP" ]; then
printf $ipsingle; printf "%s\n"
elif [ "$killswitchmode" == "PARANOID" ]; then
printf "ALL"; printf "%s\n"
else
printf "UNDEFINED"; printf "%s\n"
fi
if [ $ipv6service -ne 0 ]; then