My Ad/Malware block script

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6435
Location: UK, London, just across the river..

PostPosted: Thu Nov 07, 2019 6:39    Post subject: Reply with quote
does this line keeps pinging even when WAN is on....??

until ping -c 1 -w 10 &> /dev/null cloudflare.com; do sleep 110; done

instead I usually extend adblocker sleep time in startup script as it's placed in the custom section, so it loads independently and its the last thing to load at the end when WAN is available anyway ..

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55779 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Sponsor
pikasso
DD-WRT Novice


Joined: 06 Nov 2019
Posts: 2

PostPosted: Thu Nov 07, 2019 10:12    Post subject: Reply with quote
SurprisedItWorks wrote:
Thank you, Pierrick! Unusual that people bother with that. It is appreciated.


Being around xda and other communities, I know that so well.. I have been having my router since one year but now, I need also more parental control and ads management that I switched recently to ddwrt.. I begin to have fun with it Very Happy

SurprisedItWorks wrote:

until ping -c 1 -w 10 &> /dev/null cloudflare.com; do sleep 110; done


Updated successfully.

For the records.. I had previously a host file on my windows machine.. but now, all my devices are under the same configuration, and with white listing, it saves also some time in case of future forced *inclusion*.

Thanks
ctclark1
DD-WRT Novice


Joined: 08 Feb 2012
Posts: 1

PostPosted: Wed Nov 27, 2019 3:31    Post subject: Reply with quote
This is awesome, thank you! I was getting fed up with Privoxy not really blocking much of anything ad-wise except for whole sites, and stumbled across the "other" thread with your trials, found my way here, and managed to somehow get it working! Laughing I will say it took me a few tries, for some reason the first few times I tried curl I wouldn't get any responses in the logs at all, then wget was always failing even with the extra "-", but then mysteriously curl worked when I went back to trying it, so I wanted to say thank you!

As a comment on it - I ended up dropping the ping wait at the beginning from 110 seconds to 30, hopefully that doesn't cause a problem. Fingers crossed.

I should also add, for some who might encounter it, that graph.facebook.com being blacklisted not only broke my Messenger (on mobile only, not desktop) but also kept the facebook settings on mobile from working at all, so I unfortunately had to whitelist those, but oh well.
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Wed Nov 27, 2019 17:09    Post subject: Reply with quote
ctclark1 wrote:
This is awesome, thank you! I was getting fed up with Privoxy not really blocking much of anything ad-wise except for whole sites, and stumbled across the "other" thread with your trials, found my way here, and managed to somehow get it working! Laughing I will say it took me a few tries, for some reason the first few times I tried curl I wouldn't get any responses in the logs at all, then wget was always failing even with the extra "-", but then mysteriously curl worked when I went back to trying it, so I wanted to say thank you!

As a comment on it - I ended up dropping the ping wait at the beginning from 110 seconds to 30, hopefully that doesn't cause a problem. Fingers crossed.

Thanks for the support! Also, there's absolutely no harm in using a smaller delay (as you did) in that "until..." loop. It just means you'll attempt to ping cloudflare more often while looking for the network to come up.
Quote:
I should also add, for some who might encounter it, that graph.facebook.com being blacklisted not only broke my Messenger (on mobile only, not desktop) but also kept the facebook settings on mobile from working at all, so I unfortunately had to whitelist those, but oh well.

For graph.facebook.com, it should be enough to not blacklist it, since (at least at present) it's not showing up in badhosts anyway. I don't blacklist it here anymore either. I'm currently blacklisting only ads.facebook.com and connect.facebook.net, but the inadequate evidence here so far suggests the latter may disable facebook messenger. I don't use any facebook tools/spyware myself anyway and refuse to install it or even browse to it on my own devices, so to discover problems I have to wait for the rest of the family to swawk.
Twisted Evil

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Mon Dec 09, 2019 16:27    Post subject: Reply with quote
It turns out that sometimes Startup code is run more than once by dd-wrt. I believe Apply on some GUI pages will rerun it, for example. So as presented above, the adblocker may get rerun. That's pretty harmless unless two runs of it overlap in time in just the wrong way, but to be super safe, you can replace the whole <Adblocker Code> with this:
Code:
( STARTED=/tmp/root/StartedAdBlocker
  [[ -f $STARTED ]] && exit || touch $STARTED
  <Adblocker Code> )

Of course you can name the file whatever you like. It will be an empty file that exists only so that the second and later runs of the Startup code will "realize" not to execute your code. The variable STARTED is local to the enclosing subshell (the parentheses), so you can re-use the name elsewhere if inclined, just not in the <Adblocker>.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6435
Location: UK, London, just across the river..

PostPosted: Mon Dec 09, 2019 18:13    Post subject: Reply with quote
got lost here what is all about Razz

just either revise it on the top or post the all revised adblocker as you believe it should be....
here at the end... this article gets interesting as
there are many suggestions all working and useful..

by the way ive never seen it executed twice...as i also keep it in custom script instead...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55779 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Mon Dec 09, 2019 18:41    Post subject: Reply with quote
Alozaros wrote:
got lost here what is all about Razz

just either revise it on the top

Good point. I've gone back and revised the latest full version with the more recent updates.
Quote:
or post the all revised adblocker as you believe it should be....
here at the end... this article gets interesting as
there are many suggestions all working and useful..

by the way ive never seen it executed twice...as i also keep it in custom script instead...

I have seen other startup code executed twice. Yesterday the second execution, due to a bug in my (other) code, crashed my router so completely that I needed a reset/restore. It got my attention! And this morning I finally noticed that the scripting section in the wiki warns us to plan for startup to run more than once. Of course if you call your custom script from startup, you may need something like
Code:
( STARTED=/tmp/root/StartedCustom
  [[ -f $STARTED ]] && exit || touch $STARTED
  sh /tmp/custom.sh & )

If you don't call the adblocker from startup, I can't see any reason you'd need to care about double running, so you can pretty much ignore today's posts. Or if you are looking back to the last posted full version of the code (https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=321121&start=42), strip off the new two first (noncomment) lines AND the new final parenthesis on the last line. Gotta keep those parens in pairs!

BTW all, yesterday this adblocker saved my wife's computer from tags.bluekai.com, supposedly a nasty site that infects browsers with a popup creation engine that fills one's life with ads. There's lots of stuff online about it and how to remove it. Just for grins, I checked and discovered that Quad9 DNS does not block it but that Adguard DNS does.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
EnigmaSol
DD-WRT Novice


Joined: 07 Jan 2020
Posts: 5

PostPosted: Tue Jan 07, 2020 16:47    Post subject: Adchoices Ads Reply with quote
Hi all,

I have copied and saved the script as startup (Thank you all who created/contributed to the script), DNSmasq is enabled but Local DNS is disabled.

The Adchoices ads and google ads are still able to slip through (yahoo.com). Am I doing something wrong (noob)? It seems all the sites I frequent are served by Adchoices/Google ads and there is no solution? even Ad Block plus extension works only sometimes.

Thanks again!
tinkeruntilitworks
Guest





PostPosted: Tue Jan 07, 2020 22:12    Post subject: Reply with quote
can't speak for this script but i run something somewhat similar. hosts blocking has become harder. https sites can inject ads
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6435
Location: UK, London, just across the river..

PostPosted: Wed Jan 08, 2020 8:35    Post subject: Re: Adchoices Ads Reply with quote
EnigmaSol wrote:
Hi all,

I have copied and saved the script as startup (Thank you all who created/contributed to the script), DNSmasq is enabled but Local DNS is disabled.

The Adchoices ads and google ads are still able to slip through (yahoo.com). Am I doing something wrong (noob)? It seems all the sites I frequent are served by Adchoices/Google ads and there is no solution? even Ad Block plus extension works only sometimes.

Thanks again!


Local DNS must be enabled (turned on)
as this script is using a, local host based scanning list....

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55779 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Wed Jan 08, 2020 15:51    Post subject: Re: Adchoices Ads Reply with quote
EnigmaSol wrote:
Hi all,

I have copied and saved the script as startup (Thank you all who created/contributed to the script), DNSmasq is enabled but Local DNS is disabled.

The Adchoices ads and google ads are still able to slip through (yahoo.com). Am I doing something wrong (noob)? It seems all the sites I frequent are served by Adchoices/Google ads and there is no solution? even Ad Block plus extension works only sometimes.

Thanks again!

There is no 100% solution, as many ads are embedded now in the material you are trying to view and don't involve separate DNS lookups. All we can do is try to reduce the numbers of ads as best we can!

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Wed Jan 08, 2020 16:08    Post subject: Re: Adchoices Ads Reply with quote
Alozaros wrote:
Local DNS must be enabled (turned on)
as this script is using a, local host based scanning list....

Have you actually tested this both ways, with and without Local DNS enabled? I have not, but I don't believe Local DNS should be required. The addn-hosts=... dnsmasq feature that this all hinges on simply extends the usual unix use of an /etc/hosts file, which is not related to a local-DNS capability in particular.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
EnigmaSol
DD-WRT Novice


Joined: 07 Jan 2020
Posts: 5

PostPosted: Fri Jan 10, 2020 14:41    Post subject: Re: Adchoices Ads Reply with quote
SurprisedItWorks wrote:
EnigmaSol wrote:
Hi all,

I have copied and saved the script as startup (Thank you all who created/contributed to the script), DNSmasq is enabled but Local DNS is disabled.

The Adchoices ads and google ads are still able to slip through (yahoo.com). Am I doing something wrong (noob)? It seems all the sites I frequent are served by Adchoices/Google ads and there is no solution? even Ad Block plus extension works only sometimes.

Thanks again!

There is no 100% solution, as many ads are embedded now in the material you are trying to view and don't involve separate DNS lookups. All we can do is try to reduce the numbers of ads as best we can!


I can definitely try it with Local DNS enabled, however, would you folks confirm, if you go to yahoo.com or slickdeals.com, you are not seeing the ads to the right side of the page?
croweater
DD-WRT User


Joined: 28 Dec 2019
Posts: 59

PostPosted: Fri Jan 10, 2020 14:49    Post subject: Reply with quote
I'm using BusyBox v1.31.1

I guess curl is no good based on the badhosts.log
/tmp/.rc_startup: line 17: curl: not found

How do I resolve this?

edit: I see there is a wget command I can use.


Last edited by croweater on Fri Jan 10, 2020 17:45; edited 1 time in total
croweater
DD-WRT User


Joined: 28 Dec 2019
Posts: 59

PostPosted: Fri Jan 10, 2020 17:33    Post subject: Reply with quote
Is there a way to run this only on certain SSIDs? I ask because I prefer to NOT run this on my Guest wireless network.

Last edited by croweater on Fri Jan 10, 2020 19:03; edited 1 time in total
Goto page Previous  1, 2, 3, 4, 5, 6  Next Display posts from previous:    Page 4 of 6
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking 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 cannot attach files in this forum
You cannot download files in this forum