lixuewei / rt-n56u

Automatically exported from code.google.com/p/rt-n56u
0 stars 0 forks source link

Addblock script for custom firmware #1364

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please add this to the Wiki:

##########################
# ADBLOCK
##########################
# Sources of this list can be found here: 
https://github.com/dschuermann/ad-away/wiki/HostsSources
# This script comes with zero warranty, use at own risk
# Portions of this script are based on the original DD-WRT adblock scripts
# Tested only on Asus RT-N56U router
# Firmware: 3.4.3.8-085
# I have added it to my "Run after WAN Up/Down Events:" Customization - Scripts 
field.
##########################
#!/bin/sh
logger WAN up script executing
if test -s /tmp/hosts0
then
        rm /tmp/hosts0
fi

logger Downloading http://winhelp2002.mvps.org/hosts.txt
wget -O - http://winhelp2002.mvps.org/hosts.txt | grep 0.0.0.0 |
    sed '2,$s/127.0.0.1/0.0.0.0/g; s/[[:space:]]*#.*$//g;' |
    grep -v localhost | tr ' ' '\t' |
    tr -s '\t' | tr -d '\015' | sort -u >/tmp/hosts0
wget -O - http://someonewhocares.org/hosts/zero | grep '0.0.0.0' >>/tmp/hosts0 
wget -O - http://adaway.org/hosts.txt | grep '127.0.0.1' |  sed 
'2,$s/127.0.0.1/0.0.0.0/g; s/[[:space:]]*#.*$//g;' >>/tmp/hosts0 
wget -O - http://hosts-file.net/.wget -O - 
"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimet
ype=plaintext" | grep '127.0.0.1' | sed '2,$s/127.0.0.1/0.0.0.0/g; 
s/[[:space:]]*#.*$//g;' >>/tmp/hosts0
wget -O - http://www.malwaredomainlist.com/hostslist/hosts.txt | grep 
'127.0.0.1' | sed '2,$s/127.0.0.1/0.0.0.0/g; s/[[:space: ]]*#.*$//g;' 
>>/tmp/hosts0
grep addn-hosts /etc/storage/dnsmasq/dnsmasq.conf ||
    echo "addn-hosts=/tmp/hosts0" >>/etc/storage/dnsmasq/dnsmasq.conf
logger Restarting dnsmasq
killall dnsmasq
dnsmasq --conf-file=/etc/storage/dnsmasq/dnsmasq.conf

Original issue reported on code.google.com by yuri.ver...@gmail.com on 14 Nov 2014 at 8:49

GoogleCodeExporter commented 9 years ago
Works fine for and hour or so but breaks my dnsmasq so I'm unable to obtain IP 
on wifi.

Original comment by kitch2400 on 23 Nov 2014 at 3:53

GoogleCodeExporter commented 9 years ago
I experience same problem. Couldn't connect to my WiFi after a while :-( 

Really want this to work globally

Original comment by ji...@warting.se on 23 Nov 2014 at 4:37

GoogleCodeExporter commented 9 years ago
I noticed this happening to me as well, however I was thinking it was a 
configuration error only I would experience. 

The fix for me was to go to the DHCP settings and ensure

Gateway: Make sure this is not blank
DNS: Make sure the only entry is that of the router you run this script on.

For me, both the gateway and the DNS were blank. When wifi clients connected 
they would try then fail. After the changes (and applying them) wifi clients 
connected without any issue. Reply back if this works. 

Original comment by yuri.ver...@gmail.com on 24 Nov 2014 at 12:20

GoogleCodeExporter commented 9 years ago
I'll look into this tonight and post laster for verification.

Original comment by kitch2400 on 25 Nov 2014 at 2:04

GoogleCodeExporter commented 9 years ago
FYI i should clarify for those that don't have a strong understanding of TCP/IP 
addressing.

The Gateway IP is that which the clients will use when exiting your network 
(usually to the internet). It is almost always that of your ASUS router. So if 
you access your ASUS router at http://192.168.1.1, then the gateway you will be 
specifying for DHCP client settings will be 192.168.1.1

Similarly the DNS server will be that of your router - 192.168.1.1, the router 
will be accepting your DNS requests (converting something.com into an IP 
address) and if it cannot fulfil them, it will forward those onto your ISP DNS 
(or whatever you have defined as your WAN DNS server, if unsure use 8.8.8.8 and 
8.8.4.4 as your WAN connection DNS - NOT YOUR DHCP DNS)

All this script is doing is effectively returning a bad ip address for DNS 
requests for Advertisements and malware. This causes the request for the image 
or file to fail, and you are left with a wonderful ad-free experience. 

Original comment by yuri.ver...@gmail.com on 25 Nov 2014 at 4:20

GoogleCodeExporter commented 9 years ago
Confirmed. All is good after manually reverting default gateway and DNS server 
to previous values.

Original comment by kitch2400 on 27 Nov 2014 at 12:00

GoogleCodeExporter commented 9 years ago
Sorry, can't post it as I (or someone from this project) haven't test it.
But I've looked at your code and fixed it a little...
https://dl.dropboxusercontent.com/u/44733876/tmp/adblock.sh
(https://dl.dropboxusercontent.com/u/44733876/tmp/resourses.txt)
Usage: ./adblock.sh /path/to/file/with/links.txt -r

So it reads links from given text file. http and https protocols are supported. 
(openssl binary is required for https).

For example:
./adblock.sh resourses.txt -r

Pls, let me know if it works or any fixes needed...

Original comment by d...@soulblader.com on 28 Nov 2014 at 9:39

GoogleCodeExporter commented 9 years ago
Issue 1419 has been merged into this issue.

Original comment by d...@soulblader.com on 7 Feb 2015 at 9:52

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
My take on adblocking might be a bit heavy compared to the other ones
https://www.dropbox.com/sh/vwyjbsbey84q2hs/AAA9vP7lVJ94-ZdupW-FxaHha?dl=0

Original comment by toast.ro...@gmail.com on 25 Mar 2015 at 9:59