mirror of
https://github.com/trailofbits/algo.git
synced 2025-06-07 07:33:52 +02:00
random tmp names #64
This commit is contained in:
parent
3864f8104d
commit
53f60e33d8
1 changed files with 13 additions and 11 deletions
|
@ -1,40 +1,42 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#Block ads, malware, etc.
|
# Block ads, malware, etc..
|
||||||
|
|
||||||
# Redirect endpoint
|
# Redirect endpoint
|
||||||
ENDPOINT_IP4="0.0.0.0"
|
ENDPOINT_IP4="0.0.0.0"
|
||||||
ENDPOINT_IP6="::"
|
ENDPOINT_IP6="::"
|
||||||
IPV6="Y"
|
IPV6="Y"
|
||||||
|
TEMP=`mktemp`
|
||||||
|
TEMP_SORTED=`mktemp`
|
||||||
|
|
||||||
#Delete the old block.hosts to make room for the updates
|
#Delete the old block.hosts to make room for the updates
|
||||||
rm -f /var/lib/dnsmasq/block.hosts
|
rm -f /var/lib/dnsmasq/block.hosts
|
||||||
|
|
||||||
echo 'Downloading hosts lists...'
|
echo 'Downloading hosts lists...'
|
||||||
#Download and process the files needed to make the lists (enable/add more, if you want)
|
#Download and process the files needed to make the lists (enable/add more, if you want)
|
||||||
wget -qO- http://www.mvps.org/winhelp2002/hosts.txt| awk -v r="$ENDPOINT_IP4" '{sub(/^0.0.0.0/, r)} $0 ~ "^"r' > /tmp/block.build.list
|
wget -qO- http://www.mvps.org/winhelp2002/hosts.txt| awk -v r="$ENDPOINT_IP4" '{sub(/^0.0.0.0/, r)} $0 ~ "^"r' > "$TEMP"
|
||||||
wget -qO- "http://adaway.org/hosts.txt"|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> /tmp/block.build.list
|
wget -qO- "http://adaway.org/hosts.txt"|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> "$TEMP"
|
||||||
wget -qO- http://www.malwaredomainlist.com/hostslist/hosts.txt|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> /tmp/block.build.list
|
wget -qO- http://www.malwaredomainlist.com/hostslist/hosts.txt|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> "$TEMP"
|
||||||
wget -qO- "http://hosts-file.net/.\ad_servers.txt"|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> /tmp/block.build.list
|
wget -qO- "http://hosts-file.net/.\ad_servers.txt"|awk -v r="$ENDPOINT_IP4" '{sub(/^127.0.0.1/, r)} $0 ~ "^"r' >> "$TEMP"
|
||||||
|
|
||||||
#Add black list, if non-empty
|
#Add black list, if non-empty
|
||||||
if [ -s "/etc/black.list" ]
|
if [ -s "/var/lib/dnsmasq/black.list" ]
|
||||||
then
|
then
|
||||||
echo 'Adding blacklist...'
|
echo 'Adding blacklist...'
|
||||||
awk -v r="$ENDPOINT_IP4" '/^[^#]/ { print r,$1 }' /etc/black.list >> /tmp/block.build.list
|
awk -v r="$ENDPOINT_IP4" '/^[^#]/ { print r,$1 }' /var/lib/dnsmasq/black.list >> "$TEMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Sort the download/black lists
|
#Sort the download/black lists
|
||||||
awk '{sub(/\r$/,"");print $1,$2}' /tmp/block.build.list|sort -u > /tmp/block.build.before
|
awk '{sub(/\r$/,"");print $1,$2}' "$TEMP"|sort -u > "$TEMP_SORTED"
|
||||||
|
|
||||||
#Filter (if applicable)
|
#Filter (if applicable)
|
||||||
if [ -s "/etc/white.list" ]
|
if [ -s "/var/lib/dnsmasq/white.list" ]
|
||||||
then
|
then
|
||||||
#Filter the blacklist, supressing whitelist matches
|
#Filter the blacklist, supressing whitelist matches
|
||||||
# This is relatively slow =-(
|
# This is relatively slow =-(
|
||||||
echo 'Filtering white list...'
|
echo 'Filtering white list...'
|
||||||
egrep -v "^[[:space:]]*$" /etc/white.list | awk '/^[^#]/ {sub(/\r$/,"");print $1}' | grep -vf - /tmp/block.build.before > /var/lib/dnsmasq/block.hosts
|
egrep -v "^[[:space:]]*$" /var/lib/dnsmasq/white.list | awk '/^[^#]/ {sub(/\r$/,"");print $1}' | grep -vf - "$TEMP_SORTED" > /var/lib/dnsmasq/block.hosts
|
||||||
else
|
else
|
||||||
cat /tmp/block.build.before > /var/lib/dnsmasq/block.hosts
|
cat "$TEMP_SORTED" > /var/lib/dnsmasq/block.hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$IPV6" = "Y" ]
|
if [ "$IPV6" = "Y" ]
|
||||||
|
|
Loading…
Add table
Reference in a new issue