How to use adblock.sh

Support forum for routers of all shapes and sizes. As long as it's router based and doesn't fall into the other categories, this is the place to ask your questions.
User avatar
thechief
RouterTech Team
RouterTech Team
Posts: 12067
Joined: Wed Feb 01, 2006 10:22 pm
Location: England, the Centre of Africa
Contact:

Re: How to use adblock.sh

Post by thechief » Thu Jun 03, 2010 7:34 am

scgf wrote:Is this a riddle?
No.
scgf wrote:Why a secret?
There is no secret.
scgf wrote:All I need to know is what to do to keep the adblock.conf file over a reboot.
And this is very very well explained in the docs, which you should have read.
scgf wrote:I am a teacher and am exasperated with the way hackers and Linux gurus hide their knowledge behind riddles and 'read this' and 'read that'. I have run a Linux box for some years and have learned a lot but sometimes it is just too difficult. When my students at school ask for help I give the help which is suitable for that individual - I don't respond with a riddle.
You keep repeating to your students the very things you have told them to read in their textbook, which they have obviously refused to read?
scgf wrote:Why is it so difficult to just tell me what to do?
Because we did not invent the term RTFM. We have taken the time to write the docs so that we don't have to keep repeating the same thing over and over again in the forum. This adds nothing but noise to the forum. If we have taken the time to write the docs, the least that anyone could do is to take the time to read them BEFORE posting to ask a question. No apologies from this side.

To bring some perspective to your exasperation, this is from the docs;
features.html wrote: 10. Auto execution of shell scripts at bootup. This requires entries in the bootloader environment. If there is any entry in the bootloader environment that points to a shell script (i.e., ending with the extension ".sh") that shell script will be executed everytime the router boots up. There is a default "autoexec.sh" provided, which just runs any commands passed to it (there are also autoexec1.sh to autoexec7.sh, which do the same thing).

37. Facility for executing commands on bootup - by "RT_cmd_x" entries in the environment ("x") stands for a number or some other distinguishing letter/number: e.g.,
setenv RT_cmd_1 "rshaperctl 192.168.1.6 32768" (will execute "rshaperctl 192.168.1.6 32768" during bootup - at the tail end of the boot process)

38. Facility for executing commands at the earliest stages of bootup - by "RT_init_x" entries in the environment ("x") stands for a number or some other distinguishing letter/number: e.g.,
setenv RT_init_1 "mount -t minix /dev/mtdblock/5 /nvram" (will execute "mount -t minix /dev/mtdblock/5 /nvram" very early in the boot process - and long before the commands loaded via RT_cmd_x)

54. Ad blocking, through adblock.sh and adblock_multi.sh. For this purpose, adblock.sh downloads and converts one of a number of common internet resources ("small", "medium", "large", or "xlarge") of ad servers to be blocked. The largest of these uses a lot of cpu cycles on the router (about 20%) - but since the router's cpu is largely idle most of the time, this is not a major issue. The smallest consumes only about 5% cpu cycles. Run adblock.sh with no parameters to see the syntax. adblock_multi.sh is a shell to adblock.sh, allowing it to download more than one of the internet lists at once (e.g., "adblock_multi.sh exit small large"). Note that, for routers with low memory (i.e., 8mb RAM), you should never use "large" or "xlarge". In fact, "small" is the only one that such routers will be able to cope with. If you try to download more lists than your free memory can cope with, your router WILL crash!

NOTE: you MUST always run "adblock.sh exit" to remove the adblock features from memory, before any attempt to upgrade the firmware.
history.html wrote: 15. New shell scripts: adblock.sh and adblock_multi.sh - to assist in blocking popup adverts by means of "dns poisoning". It is basically obsolete if you can use Firefox and adblock plus - but otherwise (e.g., if using IE) it is very useful. Advantages [a] it only needs to be implemented once - on the router - and all clients would benefit from the ad blocking, etc it works with all browsers such such as IE which don't have adblock [c] some of the hosts in the hosts block lists do some of what tinyproxy could have achieved, re: parental control. For this purpose, adblock.sh downloads and converts one of a number of common internet resources ("small", "medium", "large", or "xlarge") of ad servers to be blocked. The largest of these uses a lot of cpu cycles on the router (about 20%) - but since the router's cpu is largely idle most of the time, this is not a major issue. The smallest consumes only about 5% cpu cycles. Run adblock.sh with no parameters to see the syntax. adblock_multi.sh is a shell to adblock.sh, allowing it to download more than one of the internet lists at once (e.g., "adblock_multi.sh exit small large"). Note that, for routers with low memory (i.e., 8mb RAM), you should never use "large" or "xlarge". In fact, "small" might be the only one that such routers will be able to cope with. If you try to download more lists than your free memory can cope with, your router WILL crash!
NOTE: you MUST always run "adblock.sh exit" to remove the adblock features from memory, before any attempt to upgrade the firmware.

16. New environment variable: adblock - use this to schedule adblock_multi.sh to run when a WAN connection is made. The values should be the parameters that you wish to pass to adblock_multi.sh (e.g., setenv adblock "exit medium xlarge"). On routers with 8mb RAM, you should only supply "small" - do NOT try to use the medium/large/xlarge lists on such routers.
faq.html wrote: Q. I have some specific needs and want some things to happen on the router everytime it is booted. How do I do this?
A. Use the "autoexec.sh" feature (remember to reboot the router afterwards):
e.g.,
setenv autoexec.sh "wget http://fpp.com/bar.sh -P /var && chmod a+x /var/bar.sh && /var/bar.sh"
This will set up the router to fetch a script (bar.sh) from a website, set its executable flag, and then run it, everytime the router boots up.
OR
Use the "RT_cmd_n" feature (remember to reboot the router afterwards):
e.g.,
setenv RT_cmd_1 "mount -t minix /dev/mtdblock/5 /nvram"
This will set up the router to mount an mtd5 that you have created and converted to a minix filesystem at the mountpoint /nvram
OR
Use the "RT_init_n" feature (remember to reboot the router afterwards):
e.g.,
setenv RT_init_1 "mount -t minix /dev/mtdblock/5 /nvram"
This will set up the router to mount an mtd5 that you have created and converted to a minix filesystem at the mountpoint /nvram
OR
If you are a Windows user, then you can write script to be stored on your PC and then use a Windows telnet scripter to run the script each time you restart the router.
The "RT_init_n" commands are executed very early in the boot process. The "RT_cmd_n" commands are executed after most things have been loaded (towards the end of initialisation) and the "autoexec.sh" commands are executed at the tail end - normally after a WAN connection has been achieved, or the firmware has timed out from waiting for a WAN connection.

Bottom line: if you had bothered to read the docs, you would not have been exasperated at all - and neither would any of those who ask questions without first reading the docs. Presumably, we should resort to doing all this copying and pasting everytime someone prefers to not read the docs?
The Chief: :afro: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
scgf
Regular
Regular
Posts: 52
Joined: Wed Oct 28, 2009 7:40 pm

Re: How to use adblock.sh

Post by scgf » Thu Jun 03, 2010 3:59 pm

Thanks for your help, guys. I managed to get adblock working after a reboot.

thechief: I have to disagree with your stance. The ICT department in my school has all the help imaginable online for all of our curriculum material. Students know how to access it, but the vast majority just do not for whatever reason. For some it is a case of not being able to see the wood for the trees, for others it is sheer laziness. If you have looked me up on the Internet you will see that it is not laziness on my part. Of course I had perused the docs, but just could not put things together. If only life were that easy!

I used to be a member of Team OS/2 and gave a great deal of help to users online. I was an evangelist and wanted to see OS/2 adopted by more and more people. Just telling them to read the docs would not have helped realise that aim so I willingly gave useful, practical advice that got people back on track, no matter whether is had been documented elsewhere. I still miss OS/2 greatly :-(

Linux gurus are a different breed - they seem to adopt T S Elliot's stance regarding his poetry - let it not be easily accessible to the common people - make it difficult so they keep away and the poetry remains elitist. Linux will never become mainstream with that attitude - those with an interest will just go elsewhere. The success of Apple is down to the way it has made its OS more accessible to ordinary people who really don't want to read technical manuals. That is the way forward.

For anyone else wanting to do what I needed to do, the answer is simple once you have pored over the docs ;-). Just telnet into the router, then enter these two lines:

setenv adblock small

setenv RT_cmd_1 "echo "address=/whatever.com/xx.xxx.xx.xxx" >> /var/tmp/dns.d/bad1.conf"

Where whatever.com is the url you wish to block and xx.xxx.xx.xxx is the numerical IP address of the website you wish to appear in its place.
User avatar
mysticalos
Experienced
Experienced
Posts: 237
Joined: Sun Feb 25, 2007 11:46 pm
Location: Georgia, USA
Contact:

Re: How to use adblock.sh

Post by mysticalos » Sat Mar 08, 2014 7:49 am

A very old thread but what I need is far more than just adding one or two urls. I have about 50 domains I need to inject into the adblock temp file on router boot. Because I have a PS4 and because sony's coding is such utter bad and they decided a system with 8 gigs of ram should allocate so little memory to browser, that pretty much have to strip the hell out of images and ads far more strict than adblock alone can muster to make some of pages I go to for streaming video to work. Basically, what I need to do is produce a custom adblock list of my own, upload it to my own domain and then have adblock.sh support adding MY list to the startup. is this at all doable or adable where i can have it download a completely customized adblock list?

This is basically what I need to block (pulled from hosts files I have on all my desktop computers, unfortunately I can't just drop a hosts file on the PS4. I wish. But I need router level blocking for that, so I need to inject all of these into the adblock function somehow, and the means here don't exactly do it for me, not this many of them.

Code: Select all

#More Servers added by MysticalOS
127.0.0.1 au.a1.yimg.com
127.0.0.1 richmedia.yimg.com
127.0.0.1 ts.richmedia.yahoo.com
127.0.0.1 us.adserver.yahoo.com
127.0.0.1 au.adserver.yahoo.com
127.0.0.1 ca.adserver.yahoo.com
127.0.0.1 cn.adserver.yahoo.com
127.0.0.1 mi.adinterax.com
127.0.0.1 adserver.teracent.net
127.0.0.1 adserver2.teracent.net
127.0.0.1 adserver3.teracent.net
127.0.0.1 a.as-us.talkag.net
127.0.0.1 a.as-eu.falkag.net
127.0.0.1 a.as-us.falkag.net
127.0.0.1 www.assoc-amazon.com
127.0.0.1 promos.fling.com
127.0.0.1 ads.blizzard.com
127.0.0.1 www.pheedo.com
127.0.0.1 promo.macupdate.com
127.0.0.1 cdn5.tribalfusion.com
127.0.0.1 a.tribalfusion.com
127.0.0.1 counter.hitslink.com
127.0.0.1 altfarm.mediaplex.com
127.0.0.1 secure.img-cdn.mediaplex.com
127.0.0.1 bs.serving-sys.com
127.0.0.1 ad.ad-flow.com
127.0.0.1 banners.cams.com
127.0.0.1 ads.alt.com
127.0.0.1 ads.millionairemate.com
127.0.0.1 ads.adbrite.com
127.0.0.1 b1.adbrite.com
127.0.0.1 files.adbrite.com
127.0.0.1 4.adbrite.com
127.0.0.1 promos.xpeeps.com
127.0.0.1 banners.pennyweb.com
127.0.0.1 a.ads1.msn.com
127.0.0.1 ads1.msn.com
127.0.0.1 a.rad.live.com
127.0.0.1 ads.ak.facebook.com
127.0.0.1 cubics.com
127.0.0.1 m.uk.2mdn.net
127.0.0.1 ad.uk.doubleclick.net
127.0.0.1 ad.doubleclick.net
127.0.0.1 twx.doubleclick.net
127.0.0.1 n4403ad.doubleclick.net
127.0.0.1 cdn.fastclick.net
127.0.0.1 media.fastclick.net
127.0.0.1 servedby.advertising.com
127.0.0.1 as.casalemedia.com
127.0.0.1 m1.2mdn.net
127.0.0.1 ad.yieldmanager.com
127.0.0.1 content.yieldmanager.com
127.0.0.1 adserving.cpxinteractive.com
127.0.0.1 t2.trafficmp.com
127.0.0.1 aps.media.adrevolver.com
127.0.0.1 media.adrevolver.com
127.0.0.1 ads.revsci.net
127.0.0.1 switch.atdmt.com
127.0.0.1 cdn2.atdmt.com
127.0.0.1 rmd.atdmt.com
127.0.0.1 spe.atdmt.com
127.0.0.1 view.atdmt.com
127.0.0.1 geo.precisionclick.com
127.0.0.1 cdn2.precisionclick.com
127.0.0.1 adimg.tv.com
127.0.0.1 pixel.quantserve.com
127.0.0.1 edge.quantserve.com
127.0.0.1 uac.advertising.com
127.0.0.1 afe.specificclick.net
127.0.0.1 adopt.specificclick.net
127.0.0.1 ads.pointroll.com
127.0.0.1 speed.pointroll.com
127.0.0.1 dd.connextra.com
127.0.0.1 us.bcast1.yimg.com
127.0.0.1 srv.etology.com
127.0.0.1 ad.afy11.net
127.0.0.1 servedbyadbutler.com
127.0.0.1 limelight.smartadserver.com
127.0.0.1 ww38.smartadserver.com
127.0.0.1 media2.adshuffle.com
127.0.0.1 adcontent.videoegg.com
127.0.0.1 www.game-advertising-online.com
127.0.0.1 adservM02.pornotube.com
127.0.0.1 cgm-images.adbureau.net
127.0.0.1 cgm.adbureau.net
127.0.0.1 adservM02.pornotube.com
127.0.0.1 cgm-images.adbureau.net
127.0.0.1 cgm.adbureau.net
127.0.0.1 graphics.medleyads.com
127.0.0.1 ads.adsonar.com
127.0.0.1 js.adsonar.com
127.0.0.1 adservM02.pornotube.com
127.0.0.1 cgm-images.adbureau.net
127.0.0.1 cgm.adbureau.net
127.0.0.1 graphics.medleyads.com
127.0.0.1 media.mlgpro.com
127.0.0.1 goblins.guildlaunch.net
127.0.0.1 lcd2.wgsrv.de
127.0.0.1 pr.gulli.com
127.0.0.1 img.gulli.com
127.0.0.1 akamai.smartadserver.com
127.0.0.1 ads.pubmatic.com
127.0.0.1 showads.pubmatic.com
127.0.0.1 ads.ero-advertising.com
127.0.0.1 ads.sitescout.com
127.0.0.1 banners.ero-advertising.com
127.0.0.1 adspaces.ero-advertising.com
127.0.0.1 data.ero-advertising.com
127.0.0.1 data2.ero-advertising.com
127.0.0.1 adserver.adtechus.com
127.0.0.1 ads.shanoogle.com
127.0.0.1 ads.amateurmatch.com
127.0.0.1 ads.clicksor.com
127.0.0.1 ads.adonion.com
127.0.0.1 pubads.g.doubleclick.net
127.0.0.1 flash.qauntserve.com
127.0.0.1 ad.xtendmedia.com
127.0.0.1 ads01.9hz.com
127.0.0.1 s01.usercash.com
127.0.0.1 ads.ad3game.com
127.0.0.1 adsyndication.msn.com
127.0.0.1 ac3.msn.com
127.0.0.1 cdn.ad4game.com
127.0.0.1 cdn.gigya.com
127.0.0.1 ev.yieldbuild.com
127.0.0.1 max.gunggo.com
127.0.0.1 payload.yieldbuild.com
127.0.0.1 public.pinballpublishernetwork.com
127.0.0.1 tag.contextweb.com
127.0.0.1 media.contextweb.com
127.0.0.1 hook.yieldbuild.com
127.0.0.1 public.securewebsiteaccess.com
127.0.0.1 static.zangocash.com
127.0.0.1 ads.ad4game.com
127.0.0.1 ping.chartbeat.net
127.0.0.1 www.saple.net
127.0.0.1 www.medleyads.com
127.0.0.1 cds020.dc1.hwcdn.net
127.0.0.1 jw.re.il.arti-mediagroup.com
127.0.0.1 www.ltassrv.com
127.0.0.1 xmlconfig.ltassrv.com
127.0.0.1 sp.ltassrv.com
127.0.0.1 plugins.longtailvideo.com
127.0.0.1 ox.tossoffads.com
127.0.0.1 ads.reelhd.com
127.0.0.1 cdn.content.ads.chaturbate.com
127.0.0.1 matomy.adk2.co
127.0.0.1 s7.addthis.com
127.0.0.1 o.addthis.com
127.0.0.1 www.free-hd-divx.com
127.0.0.1 www.free-hd-movies.com
127.0.0.1 nht-3.extreme-dm.com
127.0.0.1 megu.xcea.net
127.0.0.1 peerfly.com
127.0.0.1 nofacesbook.com
127.0.0.1 www.nofacesbook.com
127.0.0.1 thefreecamsecret.com
127.0.0.1 a2pub.com
127.0.0.1 live.sekindo.com
127.0.0.1 ad.derectrev.com
127.0.0.1 a2pub.com
127.0.0.1 www.pharmdaily.com
127.0.0.1 mackeeperapp2.zeobit.com
127.0.0.1 myonlinearcade.com
127.0.0.1 vube.com
127.0.0.1 gameninja.com
127.0.0.1 watch32.com
127.0.0.1 l.adtrace.org
127.0.0.1 kaizentraffic.com

#3rd party sites solicited on web, blocked based on my own preference. Comment these out if you use these sites.
127.0.0.1 graphics.cams.com
127.0.0.1 cams.com
127.0.0.1 www.cams.com
127.0.0.1 photos.cams.com
127.0.0.1 graphics.alt.com
127.0.0.1 www.alt.com
127.0.0.1 alt.com
127.0.0.1 www.streamray.com
127.0.0.1 won.images.streamray.com
127.0.0.1 affiliates.streamray.com
127.0.0.1 livesexfreecams.streamray.com
127.0.0.1 video.streamray.com
127.0.0.1 freelivesexchat.streamray.com
127.0.0.1 freexxx.streamray.com
127.0.0.1 trampitas.streamray.com
127.0.0.1 sexcamportal.streamray.com
127.0.0.1 boysandgirls.streamray.com
127.0.0.1 cybersexx.streamray.com
127.0.0.1 topsexsites.streamray.com
127.0.0.1 freewebcams.streamray.com
127.0.0.1 camgirlmovies.streamray.com
127.0.0.1 callgirls.streamray.com
127.0.0.1 campimp.streamray.com
127.0.0.1 webcamgirls.streamray.com
127.0.0.1 camsstream.streamray.com
127.0.0.1 www.iamfreetonight.com
127.0.0.1 cdn.amateurmatch.com

#3rd Block Tumblr bullshit, because bandwidth memory hungry gif files are bane of all things.
127.0.0.1 media.tumblr.com
127.0.0.1 1.media.tumblr.com
127.0.0.1 2.media.tumblr.com
127.0.0.1 3.media.tumblr.com
127.0.0.1 4.media.tumblr.com
127.0.0.1 5.media.tumblr.com
127.0.0.1 6.media.tumblr.com
127.0.0.1 7.media.tumblr.com
127.0.0.1 8.media.tumblr.com
127.0.0.1 9.media.tumblr.com
127.0.0.1 10.media.tumblr.com
127.0.0.1 11.media.tumblr.com
127.0.0.1 12.media.tumblr.com
127.0.0.1 13.media.tumblr.com
127.0.0.1 14.media.tumblr.com
127.0.0.1 15.media.tumblr.com
127.0.0.1 16.media.tumblr.com
127.0.0.1 17.media.tumblr.com
127.0.0.1 18.media.tumblr.com
127.0.0.1 19.media.tumblr.com
127.0.0.1 20.media.tumblr.com
127.0.0.1 21.media.tumblr.com
127.0.0.1 22.media.tumblr.com
127.0.0.1 23.media.tumblr.com
127.0.0.1 24.media.tumblr.com
127.0.0.1 25.media.tumblr.com
127.0.0.1 26.media.tumblr.com
127.0.0.1 27.media.tumblr.com
127.0.0.1 28.media.tumblr.com
127.0.0.1 29.media.tumblr.com
127.0.0.1 30.media.tumblr.com
127.0.0.1 31.media.tumblr.com
127.0.0.1 32.media.tumblr.com
127.0.0.1 33.media.tumblr.com
127.0.0.1 34.media.tumblr.com
127.0.0.1 35.media.tumblr.com
127.0.0.1 36.media.tumblr.com
127.0.0.1 37.media.tumblr.com
127.0.0.1 38.media.tumblr.com
127.0.0.1 40.media.tumblr.com
127.0.0.1 41.media.tumblr.com
127.0.0.1 42.media.tumblr.com
127.0.0.1 43.media.tumblr.com
127.0.0.1 44.media.tumblr.com
127.0.0.1 45.media.tumblr.com
User avatar
thechief
RouterTech Team
RouterTech Team
Posts: 12067
Joined: Wed Feb 01, 2006 10:22 pm
Location: England, the Centre of Africa
Contact:

Re: How to use adblock.sh

Post by thechief » Sat Mar 08, 2014 9:40 am

Create your own custom block file in the required format (see the files in the /var/tmp/dns.d/ directory for the format), call it something like "adblock_myst1.conf", store it on your minix partition, and copy it to /var/tmp/dns.d/ during each bootup. Depending on how early or late in the boot process you do the copying, you might need to run "killall dproxy" after copying, for your custom block file to come into effect.
The Chief: :afro: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
Post Reply