-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadblocker
126 lines (114 loc) · 5.18 KB
/
adblocker
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
#!/system/bin/sh
# Copyright (C) 2016 Paget96
#
#=======================================================================#
# 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 will be 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/>.
#=======================================================================#
while true; do
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
if [ ! -d "/sqlite_stmt_journals" ]; then
busybox mkdir -p /sqlite_stmt_journals;
fi
busybox clear
if [ -f /system/etc/hosts ]; then
if busybox grep -q adblocker /system/etc/hosts; then
adblocker="\e[1;32m`busybox date -r /system/etc/hosts`\e[0m"
else
adblocker="\e[1;31mOff\e[0m"
fi
fi
busybox echo -e -n " AdBlocker
Current: $adblocker
info: Internet connection is required
1. Enable/Update
2. Disable
0. Go back
Please select an option: "
read -r option
if [ "$option" -eq 1 ]; then
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
busybox rm -rf /system/etc/hosts
busybox wget -O /system/etc/host4 "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext"
busybox wget -O /system/etc/host3 "http://adaway.org/hosts.txt"
busybox cat /system/etc/host4 >> /system/etc/host3; busybox rm -rf /system/etc/host4
busybox wget -O /system/etc/host2 "http://hosts-file.net/ad_servers.txt"
busybox cat /system/etc/host3 >> /system/etc/host2; busybox rm -rf /system/etc/host3
busybox wget -O /system/etc/host1 "http://winhelp2002.mvps.org/hosts.txt"
busybox cat /system/etc/host2 >> /system/etc/host1; busybox rm -rf /system/etc/host2
busybox sed '/^#/ d' /system/etc/host1 > /system/etc/host;
busybox rm -rf /system/etc/host1
busybox sort /system/etc/host | busybox uniq -u > /system/etc/hosts; busybox rm -rf /system/etc/host
busybox sed '/localhost/d' /system/etc/hosts > /system/etc/host; busybox rm -rf /system/etc/hosts
busybox sed -i -e 's/0.0.0.0/127.0.0.1/g' /system/etc/host; busybox sed -i '1i #adblocker' /system/etc/host
busybox sed -i '2i 127.0.0.1 localhost' /system/etc/host; busybox sed -i '3i ::1 localhost' /system/etc/host
busybox awk '{$1=$1}1' OFS=" " /system/etc/host > /system/etc/hosts
busybox sed -i -e '$a\' /system/etc/hosts
busybox rm -rf /system/etc/host
busybox chmod 644 /system/etc/hosts
busybox chown 0:0 /system/etc/hosts
mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null
elif [ "$option" -eq 2 ]; then
mount -o remount,rw / 2>/dev/null
mount -o remount,rw / / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
mount -o remount,rw /system /system 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw / / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system /system 2>/dev/null
busybox rm -rf /system/etc/hosts
busybox cat >> /system/etc/hosts <<EOF
127.0.0.1 localhost
EOF
busybox chmod 644 /system/etc/hosts
busybox chown 0:0 /system/etc/hosts
mount -o remount,ro / 2>/dev/null
mount -o remount,ro / / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
mount -o remount,ro /system /system 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro / / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system /system 2>/dev/null
elif [ "$option" -eq 0 ]; then
break
fi
done