![]() |
[SCRIPT] - Ad-Blocking - Hosts file method
Read this page one the wiki if you don't know what I'm talking about (the page talk about ad-blocking on N900 but the hosts file method works with nearly every OS ever created).
And maybe a look here shuld be useful too. So first of all you need root acces, so type: devel-su Backup your current hosts file with: Code:
cp /etc/hosts /etc/hosts.base Now create a file (example: vi update-hosts) with these commands: Code:
#!/bin/bash Make it executable, writable and readable only by root with: Code:
chown root:root update-hosts Code:
devel-su ./update-hosts To restore the original hosts file type: Code:
rm -f /etc/hosts http://i1.kym-cdn.com/photos/images/...047-38imqt.jpg You can test it by yourself on your Jolla with these sites: 1) http://ads-blocker.com/testing (partially works) 2) http://thepcspy.com/blockadblock/ (works!) 3) http://simple-adblock.com/faq/testing-your-adblocker/ (do not work) |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
First of all thanks for this.
It might be a good idea to evaluate the contents for anything else than lines with localhost addresses 127.0.0.1 and ::1. Otherwise you are trusting the provider of hosts.txt file that it does not contain any redirects to malicious proxy sites. |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Quote:
The provider of that hosts file is really famous and everyone download the hosts file from him, but if anyone whuold like to check for malicious redirect fell fre to do it :D and report your progres here pls. |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Quote:
But what I see is that you grep all the lines that mention localhost. That is fine. But ipv4 record can consist of more than that such as Code:
112.112.112.112 im.malicious.com localhost.localdomain localhost I think you need first to drop any lines that contain any other IP than 127.0.0.1 and ::1. And also 127.0.0.1 must not be in the form #127.0.0.1 in the end of line like this (on one line although visible here on two): Code:
112.112.112.112 im.malicious.com localhost.localdomain localhost #127.0.0.1 Code:
112.112.112.112 im.malicious.com #localhost.localdomain #localhost #127.0.0.1 |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Aaaand... I stand corrected. You are right. :)
Lines formed in the way I suggested get cleaned away properly. |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Quote:
|
Re: [SCRIPT] - Ad-Blocking - Hosts file method
I'm correcting myself again. Try hosts.txt (all # on the same line as IP):
Code:
127.0.0.1 im.not.malicious Code:
127.0.0.1 localhost localhost.localdomain The original hosts-file was: Code:
127.0.0.1 localhost localhost.localdomain Code:
cat hosts.txt | grep -v ^# | grep -v localhost | cut -d "#" -f 1 >> /etc/hosts.tmp && cat /etc/hosts.base /etc/hosts.tmp >> /etc/hosts && rm /etc/hosts.tmp && sed 's/^ *//; s/ *$//; /$/d' /etc/hosts |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
With:
Code:
cat hosts.txt | grep -v ^# | cut -d "#" -f 1 | 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 But with: Code:
cat hosts.txt | grep -v "#" | 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 |
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Quote:
|
Re: [SCRIPT] - Ad-Blocking - Hosts file method
Quote:
Example in the end of the file: Code:
# [ZEDO] |
All times are GMT. The time now is 21:44. |
vBulletin® Version 3.8.8