-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathenergized
2133 lines (2052 loc) · 82.5 KB
/
energized
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
#!/system/bin/sh
# ======================================================================
# Module: Energized Protection
# License: CC BY-NC-SA 4.0; https://energized.pro/license
# Copyright (C) 2018-2020 Energized Protection.
# ======================================================================
# Script Begins -
# ========================================
# ----------------------------------------
# Load setup files and strings
modPath="/sbin/.magisk/modules/energizedprotection/system/bin"
. $modPath/setupFiles.sh
. $modPath/mainMenu.sh
. $modPath/strings.sh
alias wget="$busybox wget"
alias awk="$busybox awk"
# ----------------------------------------
# Define Energized Protection directory
# ----------------------------------------
directory="/sdcard/EnergizedProtection"
# Create directory
if [ ! -d $directory ]; then
mkdir -p $directory;
fi
# ----------------------------------------
# Config
# ----------------------------------------
config="$directory/ep.conf"
getValue() { sed -n "s|^$1=||p" "$config"; }
getFileSize() { ls -lah "$1" | awk '{print $5}'; }
# ----------------------------------------
# ----------------------------------------
# Colors
# ----------------------------------------
BL='\e[01;90m' > /dev/null 2>&1; # Black
R='\e[01;91m' > /dev/null 2>&1; # Red
LR='\033[1;31m' > /dev/null 2>&1; # printf Red
G='\e[01;92m' > /dev/null 2>&1; # Green
LG='\033[1;32m' > /dev/null 2>&1; # printf Green
Y='\e[01;93m' > /dev/null 2>&1; # Yellow
LY='\033[1;33m' > /dev/null 2>&1; # printf Yellow
B='\e[01;94m' > /dev/null 2>&1; # Blue
P='\e[01;95m' > /dev/null 2>&1; # Purple
C='\e[01;96m' > /dev/null 2>&1; # Cyan
LC='\033[1;36m' > /dev/null 2>&1; # printf Cyan
W='\e[01;97m' > /dev/null 2>&1; # White
LW='\033[1;37m' > /dev/null 2>&1; # printf White
N='\e[0m' > /dev/null 2>&1; # No color
NC='\033[0m' > /dev/null 2>&1; # printf No color
# ----------------------------------------
hitWeb() { curl -sf http://go.energized.pro/web > /dev/null 2>&1; }
# ----------------------------------------
# Mount and unmount system
# ----------------------------------------
mountSystem(){
mount -o remount,rw '/system' 2>> "${Output[0]}" 1>> "${Output[0]}"
}
unmountSystem(){
mount -o remount,ro '/system' 2>> "${Output[0]}" 1>> "${Output[0]}"
}
# ----------------------------------------
# ----------------------------------------
# Variables
# ----------------------------------------
userAgent='Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0'
hostsGZ=$directory/hosts.gz
versionInfo=$directory/cache/version.md
versionBackup=$directory/cache/version.md.bck
configBackup=$directory/cache/ep.conf.bck
filter=$directory/cache/filter
filterBackup=$directory/cache/filter.bck
whitelist=$directory/whitelist
blacklist=$directory/blacklist
REDIRECTLIST=$directory/redirectlist
temp=$directory/cache/temp
atemp=$directory/cache/temp.a
btemp=$directory/cache/temp.b
ctemp=$directory/cache/temp.c
dtemp=$directory/cache/temp.d
etemp=$directory/cache/temp.e
ltemp=$directory/cache/ltemp
ptemp=$directory/cache/ptemp
stemp=$directory/cache/stemp
hostsBackup=$directory/hosts-backup.gz
lastUpdated=$(grep "Version Code" $filter 2>/dev/null | sed "s/! Version Code: //")
currentIP=$(grep -o -m 1 '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} watchdog.energized.pro' "$hosts" | sed 's/watchdog.energized.pro//')
# ----------------------------------------
# ----------------------------------------
# Versioning & Date
# ----------------------------------------
version=$Y'1.3.2'$N > /dev/null 2>&1
releaseDate=$G'May 25, 2020'$N > /dev/null 2>&1
date=$(date "+%d.%m.%Y %H:%M:%S")
# ----------------------------------------
# ----------------------------------------
# Check Directory
# ----------------------------------------
checkDirectory() {
# Create directory
if [ ! -d $directory ]; then
mkdir -p $directory;
fi
# Create cache folder
if [ ! -d $directory/cache ]; then
mkdir -p $directory/cache;
fi
# Check Blacklist
if [ ! -f $directory/blacklist ]; then
touch $directory/blacklist
fi
# Check Whitelist
if [ ! -f $directory/whitelist ]; then
touch $directory/whitelist
fi
# Check Redirectlist
if [ ! -f $directory/redirectlist ]; then
touch $directory/redirectlist
fi
# Check Temp
if [ ! -f $directory/cache/temp ]; then
touch $directory/cache/temp
fi
# Check P Temp
if [ ! -f $directory/cache/ptemp ]; then
touch $directory/cache/ptemp
fi
# Check S Temp
if [ ! -f $directory/cache/stemp ]; then
touch $directory/cache/stemp
fi
# Check Files
if [ ! -f $directory/whitelist ] && [ ! -f $directory/redirectlist ] && [ ! -f $directory/blacklist ] && [ ! -f $directory/cache/temp ] && [ ! -f $directory/cache/ptemp ] && [ ! -f $directory/cache/stemp ]; then
return 0
else
return 1
fi
}
# ----------------------------------------
# ----------------------------------------
# Get file size from URL
# ----------------------------------------
urlFileSize() {
curl -sI "$1" | grep -i Content-Length | awk '{print $2/1024/1024}'
}
# ----------------------------------------
# ----------------------------------------
# Spin till pid dies
# ----------------------------------------
spinPID() {
# Spin var
spin[0]="-"
spin[1]="\\"
spin[2]="|"
spin[3]="/"
# Check for process
while kill -0 "$pid" 2> /dev/null; do
for i in "${spin[@]}"; do
echo -ne "$W""\r[";
echo -ne "$Y""$i";
echo -ne "$W""]" "$W""$1"; sleep 0.1;
done
done
}
# ----------------------------------------
# ----------------------------------------
# Cleanup
# ----------------------------------------
cleanup () {
# Filter
rm -f $directory/filter
}
# Cleanup temp files
cleanupTemp () {
rm -f $versionInfo $temp $atemp $btemp $ctemp $dtemp $etemp $ltemp $stemp $ptemp
}
# ----------------------------------------
# ----------------------------------------
# Check for config file
# ----------------------------------------
checkConfig() {
if [ ! -f $config ]; then
wget --no-check-certificate -q -O $config "https://block.energized.pro/magisk/ep.conf"
checkConfig=$G"✓"$N
else
checkConfig=$R"×"$N
fi
}
# ----------------------------------------
# ----------------------------------------
# Check root permission
# ----------------------------------------
checkRoot() {
id="$(id)"; id="${id#*=}"; id="${id%%\(*}"; id="${id%% *}"
if [ "$id" != "0" ] && [ "$id" != "root" ]; then
root=$R"[×]"$N
return 0
else
root=$G"[✓]"$N
return 1
fi
}
# ----------------------------------------
# ----------------------------------------
# Check Other Adblocker
# ----------------------------------------
checkAdblockerApp() {
if [ -d /data/data/org.adaway/ ] || [ -d /system/app/org.adaway/ ] || [ -d /system/priv-app/org.adaway/ ]; then
adblockAppName=AdAway
return 1
elif [ -d /data/data/ru.dixl0f0s.unifiedhostsmanager/ ] || [ -d /system/app/ru.dixl0f0s.unifiedhostsmanager/ ] || [ -d /system/priv-app/ru.dixl0f0s.unifiedhostsmanager/ ]; then
adblockAppName=UHM
return 1
else
adblockAppName=''
return 0
fi
}
# ----------------------------------------
# ----------------------------------------
# Check internet
# ----------------------------------------
checkInternetConnection(){
wget --no-check-certificate -q --spider -T '2' https://block.energized.pro 2>/dev/null
if [ $? -eq 0 ]; then
return 1
else
return 0
fi
}
# ----------------------------------------
# ----------------------------------------
# Check hosts update
# ----------------------------------------
checkUpdate() {
checkShell;
checkEP;
#checkInternetConnection
#### Read Config 'checkHostsUpdate=true'
if [ "$(getValue checkHostsUpdate)" == "true" ]; then
#if [ "$checkInternet" == "online" ]; then
### Check Energized Protection pack
if [ "$autoPack" != "null" ]; then
## Download Version Info
wget --no-check-certificate -T "3" -q -O $versionInfo https://block.energized.pro/VERSION.md
#grep -q "Version Code" $versionInfo
cp $versionInfo $versionBackup
# Check Filter Info
if [ -f $filter ]; then 2>/dev/null
CURRENT=$(grep "Version Code" $versionInfo)
LAST_UPDATED=$(sed '1q;d' $filter)
if [ "$LAST_UPDATED" != "$CURRENT" ]; then
if [ "$(grep "watchdog.energized.pro" "$hosts")" ]; then
eupdate=$G'[ϟ] UPDATE AVAILABLE!'$N
checkUpdatePrint=$G"\r[ϟ] Update: Available.\n"$N
fi
else
eupdate=$W'[✓] UP-TO-DATE!'$N
checkUpdatePrint=$G"\r[✓] Update: Already latest.\n"$N
fi
else
touch $filter
for x in "EP0R9-P" "EXR3G1094L-P" "EX7R3M3-P" "EXP0R9-P" "EX50C14L-P"; do
if grep -q $x "$hosts"
then
eupdate=$B'[*] Extension Applied'$N
checkUpdatePrint=$B"\r[+] Update: Extension applied.\n"$N
break
else
eupdate="[+] APPLY PACK FIRST!"
checkUpdatePrint=$Y"\r[+] Update: Apply pack first.\n"$N
fi
done
fi
else
eupdate="[+] APPLY PACK FIRST!"
checkUpdatePrint=$Y"\r[+] Update: Apply pack first.\n"$N
fi
else
eupdate=""
checkUpdatePrint=$B"\r[*] Update: Disabled in config.\n"$N
fi
}
# ----------------------------------------
# ----------------------------------------
# Check Energized Protection pack
# ----------------------------------------
checkEPPack() {
if [ -f "$hosts" ]; then
if grep -q "E84S1C-P" "$hosts"; then
epPack="Basic Protection"
autoPack="basic"
elif grep -q "E5P4RK-P" "$hosts"; then
epPack="Spark Protection"
autoPack="spark"
elif grep -q "E8LU-P" "$hosts"; then
epPack="Blu Protection"
autoPack="blu"
elif grep -q "E8LUG0-P" "$hosts"; then
epPack="BluGo Protection"
autoPack="bluGo"
elif grep -q "EP0R9-P" "$hosts"; then
epPack="Porn Protection"
autoPack="porn"
elif grep -q "EUL71M473-P" "$hosts"; then
epPack="Ultimate Protection"
autoPack="ultimate"
elif grep -q "EU91F13D-P" "$hosts"; then
epPack="Unified Protection"
autoPack="unified"
else
if grep -q "/extensions/" "$hosts"; then
epPack="Extension"
else
epPack="-"
autoPack="null"
fi
fi
fi
}
# ----------------------------------------
# ----------------------------------------
# Check Energized Protection extension
# ----------------------------------------
checkEPExtensionPack() {
if [ -f "$hosts" ]; then
if grep -q "EP0R9-P" "$hosts"; then
ePCheck="✓"
epEPack="Porn"
autoExtension="porn"
else
ePCheck=""
fi
if grep -q "EXR3G1094L-P" "$hosts"; then
eRCheck="✓"
epEPack="Regional"
autoExtension="regional"
else
eRCheck=""
fi
if grep -q "EX7R3M3-P" "$hosts"; then
eXCheck="✓"
epEPack="Xtreme"
autoExtension="xtreme"
else
eXCheck=""
fi
if grep -q "EXP0R9-P" "$hosts"; then
ePLCheck="✓"
epEPack="Porn-lite"
autoExtension="porn-lite"
else
ePLCheck=""
fi
if grep -q "EX50C14L-P" "$hosts"; then
eSCheck="✓"
epEPack="Social"
autoExtension="social"
else
eSCheck=""
fi
fi
}
# ----------------------------------------
# ----------------------------------------
# Check Energized Protection service
# ----------------------------------------
checkEP() {
# Check Magisk hosts
if [ -f "$hosts" ]; then
# Check Energized Protection domain
if grep -q watchdog.energized.pro "$hosts"; then
eonoff=$G"[✓]"$N
energizedCheck=$G"✓ "$N$W"Energized Protection activated."$N
else
# Check extension(s)
if grep -q "/extensions/" "$hosts"; then
eonoff=$B"[*]"$N
energizedCheck=$B"* "$N$W"Energized Protection partially activated."$N
else
eonoff=$R"[×]"$N
energizedCheck=$R"× "$N$W"Energized Protection not activated."$N
fi
#
fi
#
fi
# Check Energized Protection packs
checkEPPack;
# Check Energized Protection extension packs
checkEPExtensionPack;
}
# ----------------------------------------
# ----------------------------------------
# Setup filter
# ----------------------------------------
setFilter() {
wget --no-check-certificate -q -O $versionInfo "https://block.energized.pro/VERSION.md"
cp $versionInfo $versionBackup
grep "Version Code" $versionInfo > $filter 2>/dev/null
}
# ----------------------------------------
# ----------------------------------------
# Setup minimum required stuffs
# ----------------------------------------
setupFilesMin() {
# Cleanup cache filter
cleanup;
# Setup directory
checkDirectory;
# Check Magisk setup
checkMagisk;
# Check systemless hosts
checkSystemlessHosts;
# Check busybox setup
checkBusybox;
# Check Energized Protection
checkEP;
}
# ----------------------------------------
setupFilesMin;
# ----------------------------------------
# Setup required stuffs for menu
# ----------------------------------------
setupFiles() {
# Cleanup cache filter
cleanup;
# Setup directory
checkDirectory;
# Check systemless hosts
checkSystemlessHosts;
# Check config file
checkConfig;
# Check Magisk setup
checkMagisk;
# Check busybox setup
checkBusybox;
# Check Config
checkConfig;
# Check root
checkRoot;
# Check shell
checkShell;
# Check systemless hosts
checkSystemlessHosts;
# Check other adblocker App(s)
checkAdblockerApp;
# Check Energized Protection service
checkEP;
# Check hosts update
checkUpdate 2>/dev/null;
}
# ----------------------------------------
# Divider
# ----------------------------------------
divider="-------------------------------------------------"
divider2="================================================="
divider3="_________________________________________________"
# ----------------------------------------
# Confirmation
# ----------------------------------------
areYouSure() { echo -n -e "$W"'\n[+] Sure? Type "y" or "n" to cancel: '"$N"; read -r 'userAnswer'; }
# ----------------------------------------
# ----------------------------------------
# Check Again?
# ----------------------------------------
checkAgain() { echo -n -e "$W"'[+] Check again? Type "y" or "n" to cancel: '"$N"; read -r 'userAnswer'; }
# ----------------------------------------
# ----------------------------------------
# Visit Telegram
# ----------------------------------------
visitTelegram() {
am start -a android.intent.action.VIEW -d "http://go.energized.pro/telegram" 2>/dev/null;
clear
}
# ----------------------------------------
# ----------------------------------------
# Change redirection IP
# ----------------------------------------
changeRedirectionIP() { sed -ie 's/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/'"$1"'/g' "$hosts"; }
# ----------------------------------------
# ----------------------------------------
# Ectract domain from URL
# ----------------------------------------
getDomain() {
domainOnly=$(echo "$1" | cut -d'/' -f3 | cut -d':' -f1 | cut -d'\@' -f2)
case $domainOnly in
(*[a-zA-Z]*)
for i in $domainOnly ; do
if [[ $i == *.* ]] ; then
echo "$i"
else
echo "0"
fi
done
;;
(*)
echo "null"
;;
esac
}
# ----------------------------------------
# ----------------------------------------
# Porn extension download
# ----------------------------------------
pornEDownload() {
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'[+] P O R N E X T E N S I O N'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Adds Porn Blocking Pack to current hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "https://block.energized.pro/porn/formats/hosts.gz" & pid=$!
spinPID "Extension: Downloading";
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
checkEP;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Extension: ""$N""$Y""Porn Extension\n""$N"
rm -f $temp $stemp $hostsGZ
}
# ----------------------------------------
# ----------------------------------------
# Porn-lite extension download
# ----------------------------------------
pornliteEDownload() {
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'[+] P O R N - L I T E E X T E N S I O N'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Adds Porn Lite Blocking Pack to current hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -O $hostsGZ "https://block.energized.pro/extensions/porn-lite/formats/hosts.gz" & pid=$!
spinPID "Extension: Downloading";
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
checkEP;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Extension: ""$N""$Y""Porn-lite Extension\n""$N"
rm -f $temp $stemp $hostsGZ
}
# ----------------------------------------
# ----------------------------------------
# Regional extension download
# ----------------------------------------
regionalEDownload() {
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'[+] R E G I O N A L E X T E N S I O N'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Adds Regional Blocking Pack to current hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "https://block.energized.pro/extensions/regional/formats/hosts.gz" & pid=$!
spinPID "Extension: Downloading";
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
checkEP;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Extension: ""$N""$Y""Regional Extension\n""$N"
rm -f $temp $stemp $hostsGZ
}
# ----------------------------------------
# ----------------------------------------
# Social extension download
# ----------------------------------------
socialEDownload() {
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'[+] S O C I A L E X T E N S I O N'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Adds Social Blocking Pack to current hosts.""$N"; sleep 0.05;
echo -e "$Y"' > Blocks all social apps. (ex. Snapchat)'"$N"; sleep 0.05;
echo -e "$Y"' > Blocks all social sites. (ex. facebook.com)'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "https://block.energized.pro/extensions/social/formats/hosts.gz" & pid=$!
spinPID "Extension: Downloading";
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
checkEP;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Extension: ""$N""$Y""Social Extension\n""$N"
rm -f $temp $stemp $hostsGZ
}
# ----------------------------------------
# ----------------------------------------
# Xtreme extension download
# ----------------------------------------
xtremeEDownload() {
printWarning;
areYouSure;
if [[ "$userAnswer" == "Y" || "$userAnswer" == "y" ]]; then
clear
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'[+] X T R E M E E X T E N S I O N'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Adds Xtreme Blocking Pack to current hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -O $hostsGZ "https://block.energized.pro/extensions/xtreme/formats/hosts.gz" & pid=$!
spinPID "Extension: Downloading";
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
checkEP;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Extension: ""$N""$Y""Xtreme Extension\n""$N"
rm -f $temp $stemp $hostsGZ
else
clear
fi
}
# ----------------------------------------
# ----------------------------------------
# Aut update extenstion
# ----------------------------------------
autoUpdateExtension() {
cleanupTemp;
if [ "$1" == "porn" ]; then
hostsURL=https://block.energized.pro/porn/formats/hosts.gz
else
hostsURL=https://block.energized.pro/extensions/$1/formats/hosts.gz
fi
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "$hostsURL"
gzip -d -c $hostsGZ > $stemp
mv "$hosts" $temp
truncate -s 0 "$hosts"
cat $temp $stemp > "$hosts"
rm -f $temp $stemp $hostsGZ
}
# ----------------------------------------
# ----------------------------------------
# Auto update hosts, whitelist, blacklist and extension(s)
# ----------------------------------------
updateHWBE() {
checkEP;
currentIP=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} watchdog.energized.pro' "$hosts" | sed 's/ watchdog.energized.pro//')
if [ -z "$currentIP" ]; then
currentIP=$(grep ' watchdog.energized.pro' "$hosts" | sed 's/ watchdog.energized.pro//')
fi
if [ "$autoPack" == "null" ]; then
echo -e "$R""$divider""$N"; sleep 0.05;
echo -e "$R""[-] No pack applied yet!""$N"; sleep 0.05;
echo -e "$R""$divider""$N"; sleep 0.05;
sleep 3
else
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""[+] Applying $epPack""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "https://block.energized.pro/$autoPack/formats/hosts.gz" & pid=$!
spinPID "Pack: Downloading";
gzip -d -c $hostsGZ > "$hosts"
rm -f $hostsGZ
checkEPPack;
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Pack: ""$N""$Y""$epPack\n""$N"
# Update cache filter
setFilter;
# Updating extension
if [ ! -z "$ePCheck" ]; then
autoUpdateExtension "porn" & pid=$!
spinPID "Porn Extension: Downloading"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Porn Extension: ""$N""$Y""Applied successfully.\n""$N"; sleep 0.1;
else
echo -e "$Y"'[~] No porn extension'"$N"; sleep 0.1;
fi
if [ ! -z "$ePLCheck" ]; then
autoUpdateExtension "porn-lite" & pid=$!
spinPID "Porn-Lite Extension: Downloading"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Porn-lite Extension: ""$N""$Y""Applied successfully.\n""$N"; sleep 0.1;
else
echo -e "$Y"'[~] No porn-lite extension'"$N"; sleep 0.1;
fi
if [ ! -z "$eRCheck" ]; then
autoUpdateExtension "regional" & pid=$!
spinPID "Regional Extension: Downloading"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Regional Extension: ""$N""$Y""Applied successfully.\n""$N"; sleep 0.1;
else
echo -e "$Y"'[~] No regional extension'"$N"; sleep 0.1;
fi
if [ ! -z "$eSCheck" ]; then
autoUpdateExtension "social" & pid=$!
spinPID "Social Extension: Downloading"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Social Extension: ""$N""$Y""Applied successfully.\n""$N"; sleep 0.1;
else
echo -e "$Y"'[~] No social extension'"$N"; sleep 0.1;
fi
if [ ! -z "$eXCheck" ]; then
autoUpdateExtension "xtreme" & pid=$!
spinPID "Xtreme Extension: Downloading"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Xtreme Extension: ""$N""$Y""Applied successfully.\n""$N"; sleep 0.1;
else
echo -e "$Y"'[~] No xtreme extension'"$N"; sleep 0.1;
fi
# Change redirection IP
if [ "$currentIP" != "0.0.0.0" ]; then
changeRedirectionIP "$currentIP" & pid=$!
spinPID "Redirection IP: Changing to $currentIP"
echo -en "$W""\r[""$N""$Y""✓""$N""$W""] Redirection IP: ""$N""$Y""Updated to $currentIP\n""$N"; sleep 0.1;
fi
# Blacklisting
doBlacklist;
# Whitelisting
doWhitelist;
printDonate;
fi
}
# ----------------------------------------
# ----------------------------------------
# Open config file
# ----------------------------------------
openConfig() {
case "$2" in
show) clear
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'ϟ O P E N C O N F I G F I L E'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo "Open the config file."; sleep 0.05;
echo -e "$Y""$divider""$N"
echo ''; sleep 0.05;
head -n 30 $config
echo ''; sleep 0.05;
echo -n -e "$W"'[+] Open config file?'"$N" "$Y"'[y/n]:'"$N"
read answer
if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
am start -a android.intent.action.VIEW -d file://$config -t text/plain > /dev/null 2>&1;
fi
clear
;;
edit) clear
am start -a android.intent.action.VIEW -d file://$config -t text/plain > /dev/null 2>&1;
;;
esac
}
# ----------------------------------------
# ----------------------------------------
# Warning
# ----------------------------------------
printWarning() {
echo -e "$R""$divider""$N"; sleep 0.05;
echo -e "$R""W A R N I N G""$N"; sleep 0.05;
echo -e "$R""$divider""$N"; sleep 0.05;
echo -e "$R""This may break your internet usage experience.""$N"; sleep 0.05;
echo -e "$R""Because of its size or blocking pattern.""$N"; sleep 0.05;
echo -e "$R""For more info, https://block.energized.pro""$N"; sleep 0.05;
echo -e "$R""\nYou may proceed if you know what you are doing!""$N"; sleep 0.05;
echo -e "$R""$divider""$N"; sleep 0.05;
}
# ----------------------------------------
# ----------------------------------------
# Return
# ----------------------------------------
printReturn() {
echo -en "$W""[←] Returning ""$N"
echo -en "$Y""•""$N"; sleep 0.2;
echo -en "$Y""•""$N"; sleep 0.3;
echo -en "$Y""•""$N"; sleep 1;
}
# ----------------------------------------
# ----------------------------------------
# Donate
# ----------------------------------------
printDonate() {
sleep 0.1
echo -e "$Y""$divider""$N"; sleep 0.1
echo -e "$Y"'[+] If you loved our work, consider donating.'"$N"; sleep 0.1
echo -e "$B"' > PayPal: paypal.me/shadmansaleh'"$N"
echo -e "$Y"' > Support: energized.pro/support'"$N"
echo -e "$Y""$divider""$N"; sleep 0.1
sleep 0.1
}
# ----------------------------------------
# ----------------------------------------
# Backup Hosts
# ----------------------------------------
backupHosts() {
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'ϟ B A C K U P'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Make a backup of current hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
if [ -f "$hosts" ]; then
gzip -9 -c "$hosts" > $hostsBackup & pid=$!
spinPID "Storing Hosts"
cp $filter $filterBackup
echo -en $W"\r["$N$Y"✓"$N$W"] Storing Hosts: "$N$Y"Completed."$N; sleep 0.1;
echo -e -n $W"\n[+] Backup Config file?"$N $Y"[Y/N]"$N "$answer"
read answer
if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
spinPID "Storing Config"
cp $config $configBackup
echo -en $W"\r["$N$Y"✓"$N$W"] Storing Config: "$N$Y"Completed.\n\n"$N; sleep 0.1;
else
echo -e $W"[×] Not backing up config.\n"$N; sleep 0.1;
fi
printDonate;
else
echo -e "$R""$divider""$N"; sleep 0.05;
echo -e "$R""[×] No hosts found.""$N"; sleep 0.05;
echo -e "$R""$divider\n\n""$N"; sleep 0.05;
fi
}
# ----------------------------------------
# ----------------------------------------
# Clear Hosts
# ----------------------------------------
clearHosts() {
checkBusybox;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'ϟ C L E A N H O S T S'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Revert back to stock hosts.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo ""; sleep 0.05;
echo -n -e "$W""[+] Cleaning ""$N"; sleep 0.05;
echo -n -e "$G""•""$N"; sleep 0.05;
truncate -s 0 "$hosts"
echo -n -e "$Y""•""$N"; sleep 0.05;
rm -f $filter
echo -n -e "$C""•""$N"; sleep 0.05;
touch $filter
echo -n -e "$B""•""$N"; sleep 0.05;
echo -e "# Energized Protection - https://energized.pro\n# Let's make an annoyance free better open internet, altogether!\n\n127.0.0.1 localhost\n::1" >> "$hosts"
echo -n -e "$R""•\n""$N"; sleep 0.05;
echo -e "$W""[+] Done.\n""$N"; sleep 0.05;
checkEP;
checkUpdate;
printCountedDomains;
printDonate;
}
# ----------------------------------------
# ----------------------------------------
# Restore Hosts
# ----------------------------------------
restoreHosts() {
checkBusybox;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'ϟ R E S T O R E'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y""Restore the hosts backup.""$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
if [ -s $hostsBackup ]; then
gzip -d -c $hostsBackup > "$hosts" & pid=$!
spinPID "Restoring Hosts"
cp $filterBackup $filter
echo -en $W"\r["$N$Y"✓"$N$W"] Restoring Hosts: "$N$Y"Completed.\n"$N; sleep 0.1;
if [ -s $configBackup ]; then
echo -e -n $W"[+] Restore Config file?"$N $Y"[Y/N]"$N "$answer"
read answer
if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
spinPID "Restoring Config"
cp $configBackup $config
echo -en $W"\r["$N$Y"✓"$N$W"] Restoring Config: "$N$Y"Completed.\n\n"$N; sleep 0.1;
echo ''
else
echo -e $W"[×] Not restoring config.\n"$N; sleep 0.1;
fi
fi
printDonate;
else
echo -e $R"$divider"$N; sleep 0.05;
echo -e "$R""[×] No backup found.""$N"; sleep 0.05;
echo -e "$R""$divider\n\n""$N"; sleep 0.05;
fi
}
# ----------------------------------------
# ----------------------------------------
# Open Hosts File
# ----------------------------------------
openHosts() {
clear
checkBusybox
echo -e $Y"$divider"$N; sleep 0.05;
echo -e "$Y"'ϟ O P E N H O S T S F I L E'"$N"; sleep 0.05;
echo -e $Y"$divider"$N; sleep 0.05;
echo "Open the hosts file."; sleep 0.05;
echo -e "$Y""$divider""$N"
echo ''; sleep 0.05;
head -n 30 "$hosts"
echo ''; sleep 0.05;
echo -n -e "$W"'[+] Open Hosts File?'"$N" "$Y"'[Y/N]:'"$N"
read answer
if [[ "$answer" == "Y" || "$answer" == "y" ]]; then
am start -a android.intent.action.VIEW -d file://"$hosts" -t text/plain > /dev/null 2>&1;
fi
clear
}
# ----------------------------------------
# ----------------------------------------
# Aut update hosts
# ----------------------------------------
autoUpdateHosts() {
cleanupTemp;
hostsURL="https://block.energized.pro/$DIR"
wget --no-check-certificate -q -U "$userAgent" -O $hostsGZ "$hostsURL"
gzip -d -c $hostsGZ > $hosts
}
# ----------------------------------------
# ----------------------------------------
# Download pack
# ----------------------------------------
downloadPack() {
echo ''
case "$2" in
spark|Spark|SPARK|blugo|Blugo|bluGo|BLUGO|blu|Blu|BLU|basic|Basic|BASIC|porn|Porn|PORN|ultimate|Ultimate|ULTIMATE|unified|Unified|UNIFIED|porn-lite|pornlite|Porn-lite|PORN-LITE|xtreme|Xtreme|XTREME|regional|Regional|REGIONAL|social|Social|SOCIAL)
if [[ "$2" == "spark" || "$2" == "Spark" || "$2" == "SPARK" ]]; then
pack="spark"
epPack="Spark Protection"
DIR="/spark/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "blu" || "$2" == "Blu" || "$2" == "BLU" ]]; then
pack="blu"
epPack="Blu Protection"
DIR="/blu/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "blugo" || "$2" == "bluGo" || "$2" == "Blugo" || "$2" == "BluGo" || "$2" == "BLUGO" ]]; then
pack="bluGo"
epPack="BluGo Protection"
DIR="/bluGo/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "basic" || "$2" == "Basic" || "$2" == "BASIC" ]]; then
pack="basic"
epPack="Basic Protection"
DIR="/basic/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "porn" || "$2" == "Porn" || "$2" == "PORN" ]]; then
pack="porn"
epPack="Porn Protection"
DIR="/porn/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "ultimate" || "$2" == "Ultimate" || "$2" == "ULTIMATE" ]]; then
pack="ultimate"
epPack="Ultimate Protection"
DIR="/ultimate/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "unified" || "$2" == "Unified" || "$2" == "UNIFIED" ]]; then
pack="unified"
epPack="Unified Protection"
DIR="/unified/formats/hosts.gz"
autoUpdateHosts "$DIR" & pid=$!
spinPID "Pack: Downloading";
echo -en $W"\r["$N$Y"✓"$N$W"] Pack: "$N$Y"$epPack\n"$N
elif [[ "$2" == "xtreme" || "$2" == "Xtreme" || "$2" == "XTREME" ]]; then
pack="extensions/xtreme"