ad-blocking with DD-WRT revisited (simple)

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3, 4 ... 12, 13, 14  Next
Author Message
mac913
DD-WRT Guru


Joined: 02 May 2008
Posts: 1230
Location: Canada

PostPosted: Thu Feb 26, 2009 16:54    Post subject: Reply with quote
frater wrote:
I have moved "sleep 60" to the beginning of the loop. This will put less stress on router during startup and give it more time to get its WAN running properly (a powercut could have put the modem offline).

Code:
while sleep 60
do
  ....
  ....
done

instead of
Code:
while true
do
  ....
  ....
  sleep 60
done


So how would you add the code above to refect to the orignal code below...

_rogue=0.0.0.0
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\n" >/tmp/write_dlhosts
echo -e "\t[ \`grep -il doubleclick /tmp/dlhosts\` ] && break\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\ndone\nkillall -HUP dnsmasq" >>/tmp/write_dlhosts
chmod +x /tmp/write_dlhosts
/tmp/write_dlhosts &

Also I have some other Stratup code, should it be before or after this code?

Thanks...

_________________
Home Network on Telus PureFibre - Wired GigaBit Backbone
| SSH | DDNS | DNSCrypt-Proxy | DHCP/Static IPs | Ad-Blocking |
| USB Storage - Scripts Only | VLANs/BRs | WiFi - APs/VAPs |
| OpenVPN-Client | YAMon3 | Telus-IPv6 | ebtables | ip6tables |

Multi 2x R7000 Setup - KONGAC 35550M Release 2018-03-28 (k4.4.124#548SMP)

______________________
YAMon 3.0 | Ad-Blocking for DD-WRT
DDWRT 60-day Timeline/changelogs

Kong Builds | DD-WRT Beta Builds
Sponsor
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Feb 26, 2009 17:55    Post subject: Reply with quote
The code which you posted already has the sleep 60 at start.

Best to put it at the end, but it doesn't really matter as it only writes the script which takes a millisecond. Then it waits a minute before it starts working.

In the mean time the rest of your startup code will continue.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
Exvitermini
DD-WRT User


Joined: 13 Feb 2008
Posts: 228

PostPosted: Thu Feb 26, 2009 22:30    Post subject: Reply with quote
does using this script block certain images or content that shouldnt be blocked? cuz I had this script runnin on my WRT54GL before I upgraded its firmware a few days ago and It was blocking the "Coming Soon" image from my GoDaddy webserver. If i try the same link at a friends house it showed the image.
Any ideas wuts happening there? I mean it cant be only that image this script is blocking, who knows wut else im missing lol

_________________
> Linksys WRT610N v2 /w DD-WRT v24-sp2 (12/20/11) big (SVN revision 18024)
> Linksys WRT54GL v1.1 /w DD-WRT v24-sp2 (08/23/09) std (SVN revision 12714M VINT Eko) [Retired]
> Linksys WRT54G v6 /w DD-WRT v24-sp2 (07/22/09) micro (SVN revision 12548M NEWD Eko) [Retired]
MKruer
DD-WRT Novice


Joined: 15 Feb 2009
Posts: 18

PostPosted: Thu Feb 26, 2009 23:00    Post subject: Reply with quote
Exvitermini wrote:
does using this script block certain images or content that shouldnt be blocked? cuz I had this script runnin on my WRT54GL before I upgraded its firmware a few days ago and It was blocking the "Coming Soon" image from my GoDaddy webserver. If i try the same link at a friends house it showed the image.
Any ideas wuts happening there? I mean it cant be only that image this script is blocking, who knows wut else im missing lol


The dlhosts and for that matter the hosts files in general block everything coming from a site, pictures, pages, scripts, everything. That is why you are getting those missing pages.

excample
0.0.0.0 ads.godaddy.com < blocks everything from the ads subdomain of godaddy
0.0.0.0 godaddy.com < blocks everything from godaddy domain
0.0.0.0 com < blocks all com domains, i.e gooogle.com
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Feb 26, 2009 23:04    Post subject: Reply with quote
Exvitermini wrote:
I mean it cant be only that image this script is blocking, who knows wut else im missing lol


Yes, it can block only that image.
A lot of sites (including this forum) has ads on them which are on special adservers. If the domains of these adservers can't be resolved it can't download that image.

In the case of this forum it also means Brainslayer is getting less money Sad

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
gaganwalia
DD-WRT User


Joined: 24 Dec 2007
Posts: 449

PostPosted: Fri Feb 27, 2009 7:00    Post subject: Reply with quote
thats right. and i am not blocking the ads on this site. because i would like BS to make as much as he can for the work he has done and the great stuff he has given us.
MKruer
DD-WRT Novice


Joined: 15 Feb 2009
Posts: 18

PostPosted: Fri Feb 27, 2009 20:14    Post subject: Re: ad-blocking with DD-WRT revisited (simple) Reply with quote
frater wrote:
I will later make another thread where I'll be using the onboard webserver to answer the webcalls.


Frater, I was just wondering if you have started this. If so, i would like to lend my services for testing and/or comments if you are accepting them.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Feb 27, 2009 20:33    Post subject: Reply with quote
Now we will use the DD-WRT as webserver. Because DD-WRT is already running de management interface on port 80, we need to move it.

This can be done by simply changing its port.
Code:
nvram set http_lanport=88
nvram commit

The code is about the same. It just starts the webserver.
Code:
httpd -h /usr/tmp/www
_rogue=`nvram get lan_ipaddr`
echo -e "#!/bin/sh\nn=1\nwhile sleep 60\ndo\n\twget -q -O - http://www.mvps.org/winhelp2002/hosts.txt | grep \"^127.0.0.1\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\n" >/tmp/write_dlhosts
echo -e "\t[ \`grep -il doubleclick /tmp/dlhosts\` ] && break\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\ndone\nkillall -HUP dnsmasq" >>/tmp/write_dlhosts
chmod +x /tmp/write_dlhosts
/tmp/write_dlhosts &


BEWARE!
Your router will run on port 88 afterwards.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
MKruer
DD-WRT Novice


Joined: 15 Feb 2009
Posts: 18

PostPosted: Fri Feb 27, 2009 21:05    Post subject: Reply with quote
Question:

I ran into this setting up the host and pushing it to another system. If the URL to the ad is something like http:/ /SomeURL.com / ad.php?crapad=101, When it was redirected to the local server I set up it still came up page not found. The reason why is because the ad url changed to another system, but the path remained. If the URL to the add is something like http:/ /localURL.com / ad.php?crapad=101. The web server is missing the page ad.php?crapad=101. A good test a amazon, it has three ads off the front page that are blocked, but the blocked ads show up as page not found. I cant try this right now, but I dont think this solves that type of issue, which makes me wonder why have the web server redirect in the first place.
mac913
DD-WRT Guru


Joined: 02 May 2008
Posts: 1230
Location: Canada

PostPosted: Sat Feb 28, 2009 2:49    Post subject: Reply with quote
frater the Ad-Blocking script is working great. What is the purpose of the webserver and answering webcalls. Isn't it more secure to no servers running for hackers to hack?
_________________
Home Network on Telus PureFibre - Wired GigaBit Backbone
| SSH | DDNS | DNSCrypt-Proxy | DHCP/Static IPs | Ad-Blocking |
| USB Storage - Scripts Only | VLANs/BRs | WiFi - APs/VAPs |
| OpenVPN-Client | YAMon3 | Telus-IPv6 | ebtables | ip6tables |

Multi 2x R7000 Setup - KONGAC 35550M Release 2018-03-28 (k4.4.124#548SMP)

______________________
YAMon 3.0 | Ad-Blocking for DD-WRT
DDWRT 60-day Timeline/changelogs

Kong Builds | DD-WRT Beta Builds
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sat Feb 28, 2009 8:37    Post subject: Reply with quote
mac913 wrote:
frater the Ad-Blocking script is working great. What is the purpose of the webserver and answering webcalls. Isn't it more secure to no servers running for hackers to hack?


Although the thread is called "ad blocking" it's not "blocking" at all. It's more about giving your web browser false info, so it can not find the ads.

The ads are just links to special webservers. You have downloaded a big list containing all those webservers. Normally your DNS-server (dnsmasq on your router) has to find out on which IP they are. dnsmasq now doesn't return the real IP address, but a fake one, the IP of the DD-WRT router.

Your webbrowser will then connect to that IP.

All this is done on your local LAN, so there are no security issues.

MKruer wrote:
The web server is missing the page ad.php?crapad=101. A good test a amazon, it has three ads off the front page that are blocked, but the blocked ads show up as page not found. I cant try this right now, but I dont think this solves that type of issue, which makes me wonder why have the web server redirect in the first place.

It's true that running the 2nd http-server isn't nearly as good as pixelserv. You will still get "page not found" because the server doesn't have the pages that are being asked by your webbrowser.

pixelserv is a very simple perl script which acts as a dumb http-server and returns a pixel whatever page is asked. Although pixelserv is simple itself it is dependent of perl. perl is a very powerful language and although it can be installed on DD-WRT it's a bit too heavy for it.

I have a Linux server on which I installed pixelserv on a 2nd IP.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
gene
DD-WRT Guru


Joined: 28 Dec 2007
Posts: 619

PostPosted: Sat Feb 28, 2009 20:22    Post subject: Reply with quote
gaganwalia wrote:
hos is it possible to join 2 files into one file without duplicates. is there any command in linux that can be used on the router.

i have 2 diff. hos files and would like to combine them, but there are lots of duplicates in there too.

@gaganwalia
While I'm NOT taking the time to understand YOUR problem, I am taking the time to point out that Frater explicitly created THIS thread for those of us that DON'T need a special set-up. YOU have a special need, YOU need to use the other thread. Please stop trying to make a SIMPLE AD-BLOCKING thread complicated. I'm not flaming you, I'm strongly suggesting you use your own thread for special needs so you can have your own custom script that covers special considerations. and give it a name like "special ad-blocking" so its distinct from "SIMPLE ad-blocking".

I do understand you want to do something different so that you can preserve your existing hosts file, you need to go to a different thread and get your suggestions posted THERE.

Please RE-READ Fraters origional post for this thread: It clearly states its for simple ad-blocking. Please understand, I don't have the same need as you do to preserve and existing hosts file like you do. YOU have the special need. This thread is for those who do NOT have a special need. We want it simple, we do not need special considerations, Frater is dead on target with this thread, and I am sure that you will see others with your need for special need are still using the other thread with special considerations.

_________________
1 WRT160N v3 - remote AP WPA2 Personal Aes dd-wrt-mini-trailed CPU OC400,
2 wrt54G v3(BCM4712 chip rev 1, corerev=7)- AP WPA2 Personal Aes dd-wrt-mini-generic CPU OC228,
1 wrt54gs v6 - remote AP WPA2 Personal Aes dd-wrt-micro CPU OC228 ,
3 WAP54g v3 - repeater, client Bridge, repeater bridge dd-wrt-micro CPU OC225,
1 NetGear WNR2000 v3 AP Atheros AR7241 ver 1 rev 1.1 (0x0101) Trailed build CPU OC360
DD-WRT usually the most current BS builds and less frequently lately EKO builds(because of new BS rules that eliminated EKO builds I used).
uncle bob
DD-WRT User


Joined: 31 Aug 2008
Posts: 148

PostPosted: Sun Mar 01, 2009 17:11    Post subject: Reply with quote
so this is basically same old thread on ad blocking ?
what about pixelserv thing ?
I changed rougue to router ip instead 0.0.0.0 and I still have a lot "page not found" "cannot connect" empty recatngles
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sun Mar 01, 2009 18:40    Post subject: Reply with quote
You can only get rid of those "page not found" when you run pixelserv or something like it.
You can run pixelserv on a system that's capable of running perl.

It's not the same as the other thread. Although that thread also contains "my code" it also has a lot of scripts which are faulty.
I made a seperate thread, so we can all discuss this one script.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
barryware
DD-WRT Guru


Joined: 26 Jan 2008
Posts: 13018
Location: Behind The Reset Button

PostPosted: Sun Mar 01, 2009 23:28    Post subject: Reply with quote
Why are you guys blocking the adds? Has anyone seen the swimsuit adds on this forum? That's good stuff Very Happy
_________________
[Moderator Deleted] Shocked
Goto page Previous  1, 2, 3, 4 ... 12, 13, 14  Next Display posts from previous:    Page 3 of 14
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum