maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [SCRIPT] - Ad-Blocking - Hosts file method (https://talk.maemo.org/showthread.php?t=94627)

Vento 2015-02-18 16:12

Re: [SCRIPT] - Ad-Blocking - Hosts file method
 
the only way to be secure is to trust the provider then xD

Manatus 2015-02-18 18:31

Re: [SCRIPT] - Ad-Blocking - Hosts file method
 
No, after cutting out the comments behind #-characters you can freely grep away any lines containing anything else than 0.0.0.0. :)

Code:

cat hosts.txt | grep -v ^# | cut -d "#" -f 1 | grep 0.0.0.0 | grep -v localhost >> /etc/hosts.tmp && cat /etc/hosts.base /etc/hosts.tmp >> /etc/hosts && rm /etc/hosts.tmp && sed 's/^ *//; s/ *$//; /$/d' /etc/hosts
I tested with this hosts.txt:
Code:

0.0.0.0 im.not.malicious
112.112.112.112 im.malicious.com #localhost.localdomain #localhost #127.0.0.1
112.112.112.113 im.malicious.com localhost.localdomain localhost #127.0.0.1
111.111.111.114 colocalhosted #127.0.0.1 #colocalhosted
111.111.111.115 evil.com  #127.0.0.1
# [ZEDO]
0.0.0.0 zedo.com #[WebBug]
0.0.0.0 ads.zedo.com
0.0.0.0 c1.zedo.com
0.0.0.0 c2.zedo.com #[Tracking.Cookie]
0.0.0.0 c3.zedo.com

Which then resulted in as this hosts-file:
Code:

127.0.0.1 localhost localhost.localdomain
::1 localhost6 localhost6.localdomain6
0.0.0.0 im.not.malicious
0.0.0.0 zedo.com
0.0.0.0 ads.zedo.com
0.0.0.0 c1.zedo.com
0.0.0.0 c2.zedo.com
0.0.0.0 c3.zedo.com


Vento 2015-02-18 20:19

Re: [SCRIPT] - Ad-Blocking - Hosts file method
 
Quote:

Originally Posted by Manatus (Post 1461184)
No, after cutting out the comments behind #-characters you can freely grep away any lines containing anything else than 0.0.0.0. :)
...

Nice trick, I didn't think about it, updating first post right now (but with a shorter version :D).

Vento 2015-08-12 10:52

Re: [SCRIPT] - Ad-Blocking - Hosts file method
 
I know that this is an old thread and not a lot of ppl use this , btw I've only updated the main post: script improved and better guide.


All times are GMT. The time now is 14:17.

vBulletin® Version 3.8.8