Community discussions

MikroTik App
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

modify a 3rd part script

Thu Feb 25, 2021 1:32 pm

HI

I am curious if there is anything that can be done about this script:

it's a 3rd part adblock


https://www.micu.eu/adblock/adblock_script.txt

and what it does it puls the list from https://www.micu.eu/adblock/adblock.php


the problem is I would like to whitelist a few google dns entries but I don't know why

thank you
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Thu Feb 25, 2021 5:37 pm

If it s just to remove an entry from the DNS list, add this to the bottom of the script.
ip dns static remove [find where name="aarki.com"] 
Take care, this script will remove all DNS you have added your self with IP 127.0.0.1
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script  [SOLVED]

Thu Feb 25, 2021 10:31 pm

Cleaned up the original script some (better tabs, removed not needed ;) and added example to remove stuff from the list.
# Script to download adblock list	
# https://www.micu.eu/adblock/adblock.php
#
:log warning "starting adblock update"
:delay 2
:log warning "downloading adblock"
:local hostScriptUrl "https://www.micu.eu/adblock/adblock.php"
:local scriptName "adblock"
do {
	/tool fetch mode=http url=$hostScriptUrl dst-path=("./".$scriptName)
	:delay 20
	:if ([:len [/file find name=$scriptName]] > 0) do={
		:log warning "removing old adblock list"
		/ip dns static remove [find address=127.0.0.1]
		:log warning "importing new adblock list"
		/import file-name=$scriptName
		/file remove $scriptName
		:log warning "adblock list imported"
	} else={
		:log warning "adblock list not downloaded, script stopped"
	}
} on-error={
	:log warning "adblock list download FAILED"
}
#  These I would like to white list
ip dns static remove [find where name="aarki.com"] 
ip dns static remove [find where name="www.google.com"] 

#  To remove list complete, use this command:
# /ip dns static remove [find address=127.0.0.1]
Last edited by Jotne on Sun Aug 08, 2021 6:23 pm, edited 4 times in total.
 
nevolex
Member Candidate
Member Candidate
Topic Author
Posts: 167
Joined: Mon Apr 20, 2020 1:09 pm

Re: modify a 3rd part script

Fri Feb 26, 2021 4:46 am

Cleaned up the original script some (better tabs, removed not needed ;)
# Script to download adblock list	
# https://www.micu.eu/adblock/adblock.php
#
:log warning "starting adblock update"
:delay 2
:log warning "downloading adblock"
:local hostScriptUrl "https://www.micu.eu/adblock/adblock.php"
:local scriptName "adblock"
do {
	/tool fetch mode=http url=$hostScriptUrl dst-path=("./".$scriptName)
	:delay 20
	:if ([:len [/file find name=$scriptName]] > 0) do={
		:log warning "removing old adblock list"
		/ip dns static remove [find address=127.0.0.1]
		:log warning "importing new adblock list"
		/import file-name=$scriptName
		/file remove $scriptName
		:log warning "adblock list imported"
	} else={
		:log warning "adblock list not downloaded, script stopped"
	}
} on-error={
	:log warning "adblock list download FAILED"
}

Thank you very much!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Fri Feb 26, 2021 10:31 am

You are welcome.

PS no need to quote the post above you. Use the Post Reply button under det post

Here is how it looks like after 15 hours of use. 445 blocked access on 124 different sites. (Using Splunk see my signature)
block.jpg
Top blocked site:
site	count
settings-win.data.microsoft.com	44
www.google-analytics.com	22
adservice.google.com	20
googleads.g.doubleclick.net	19
www.googletagmanager.com	19
app-measurement.com	13
sb.scorecardresearch.com	12
acdn.adnxs.com	11
ib.adnxs.com	11
cdn.adnxs.com	10
js-agent.newrelic.com	10
secure.adnxs.com	9
ssl.google-analytics.com	8
telemetry.dropbox.com	8
firebase-settings.crashlytics.com	7
pagead2.googlesyndication.com	7
scdn.cxense.com	7
api.mixpanel.com	6
fastlane.rubiconproject.com	6
securepubads.g.doubleclick.net	6
adx.adform.net	5
api2.branch.io
You do not have the required permissions to view the files attached to this post.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Sat Mar 06, 2021 3:08 pm

If you like to remove a group of DNS you could add a linke like this:

ip dns static remove [find where name~"googleadservices"]

See complete script.
# Script to download adblock list	
# https://www.micu.eu/adblock/adblock.php
#
:log warning "starting adblock update"
:delay 2
:log warning "downloading adblock"
:local hostScriptUrl "https://www.micu.eu/adblock/adblock.php"
:local scriptName "adblock"
do {
	/tool fetch mode=http url=$hostScriptUrl dst-path=("./".$scriptName)
	:delay 20
	:if ([:len [/file find name=$scriptName]] > 0) do={
		:log warning "removing old adblock list"
		/ip dns static remove [find address=127.0.0.1]
		:log warning "importing new adblock list"
		/import file-name=$scriptName
		/file remove $scriptName
		# List of what you like to remove from filter
		ip dns static remove [find where name~"googleadservices"]
		:log warning "adblock list imported"

	} else={
		:log warning "adblock list not downloaded, script stopped"
	}
} on-error={
	:log warning "adblock list download FAILED"
}
At my home, this list do block around 4500 sites a week.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19100
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: modify a 3rd part script

Sun Mar 07, 2021 3:36 pm

Can you explain that a bit better jotne.......
So you access a list from the internet eu something something.

Then I get lost, you import this list to somewhere
Then you remove parts of the list ????
Then somehow the list doesnt work right

Very confusing what you are doing.

And how does this block anything??
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Sun Mar 07, 2021 5:49 pm

Its not my script, just cleaned it up some.

Script do download from internet a list of around 17000 DNS pointers that are added to your router.

Example this list likes to block CNN, it will add your your router www.cnn.com with an ip of 127.0.0.1
So if you do visit at site that like to open at 3rd party url to www.cnn.com, it will not reach it.

This is just a huge list of DNS that are used by advertising company that your will then block.
 
User avatar
mozerd
Forum Veteran
Forum Veteran
Posts: 872
Joined: Thu Oct 05, 2017 3:39 pm
Location: Canada
Contact:

Re: modify a 3rd part script

Sun Mar 07, 2021 7:18 pm

And how does this block anything??
Static DNS on the Tik can act like a hosts file does under a PC OS.
Tiks with low memory will have issues loading this type of list so if one has tiks like hEX memory can be exhausted quickly.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Sun Mar 07, 2021 8:25 pm

I have no problem with this list with 17000 DNS host on my hEX
At the same time I have a fw rule that block all IP that tries any blocked port on my router for 24 hour. This list has between 7000 and 15000 IP at the same time as the DNS block list.

What did eat my memory is the DoH that has a memory bug, so disabled at the moment.

PS also have configuration like a medium large company with VPN, 30+ filter, 15+ NAT rules +++ and running fine.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: modify a 3rd part script

Mon Aug 09, 2021 3:15 am

I consider a true security breach import any file downloaded from 3rd party site with /import file-name=$scriptName command.

If some hacker or the author itself put some commands inside the downloaded file, can do anything he want with the RouterBOARD...
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: modify a 3rd part script

Mon Aug 09, 2021 8:29 am

See my reply on this in other post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: modify a 3rd part script

Mon Aug 09, 2021 10:50 am

See my reply on this in other post.
My reply to your reply ;)
viewtopic.php?f=13&t=146615#p871862

Who is online

Users browsing this forum: marcelofares and 12 guests