Adblocking with /etc/hosts

Share your own howto's etc. Not for support questions!

Re: Adblocking with /etc/hosts

Postby Head_on_a_Stick » 2018-08-25 09:45

kevinthefixer wrote:
Head_on_a_Stick wrote:https://github.com/StevenBlack/hosts

Ran into dependency problems with this one (running Stretch)

You can use the supplied hosts file directly instead.

milomak wrote:how is this better than say using ublock origin?

It blocks the bad addresses for all software and it operates with zero overhead, unlike a plugin.
ESTRAGON: We always find something, eh, Didi, to give us the impression we exist?
VLADIMIR (impatiently): Yes, yes, we're magicians.
User avatar
Head_on_a_Stick
 
Posts: 7893
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Adblocking with /etc/hosts

Postby debiman » 2018-08-26 07:14

bedtime wrote:
debiman wrote:i've been using https://github.com/gaenserich/hostsblock for years.

I installed this program, and it renamed my home directory to 'hostsblock'. Anyhow, long story short, I ended up losing a bunch of files whilst uninstalling and getting things back to normal—config files and scripts that took hours and hours to make. :(

Please be careful if you chose to install this app.

you are right, and i am very, very sorry.
i guess you were using the install.sh script? I had problems with it, too, but the developer said they fixed it.
may i ask which version / how you installed? maybe i should re-open that issue:
https://github.com/gaenserich/hostsblock/issues/87

fwiw, the AUR installation method has always been reliable, and so is the script once you have it installed properly.

edit:
seems i cannot re-open the issue, i created a new one:
https://github.com/gaenserich/hostsblock/issues/88
User avatar
debiman
 
Posts: 2790
Joined: 2013-03-12 07:18

Re: Adblocking with /etc/hosts

Postby bedtime » 2018-08-26 16:11

debiman wrote:
bedtime wrote:
debiman wrote:i've been using https://github.com/gaenserich/hostsblock for years.

I installed this program, and it renamed my home directory to 'hostsblock'. Anyhow, long story short, I ended up losing a bunch of files whilst uninstalling and getting things back to normal—config files and scripts that took hours and hours to make. :(

Please be careful if you chose to install this app.

you are right, and i am very, very sorry.

It's not at all your fault; you cannot be responsible for a program that somebody else maintains. We all know that there is a small risk when playing around with Github stuff. I took the chance, and I take responsibility.

i guess you were using the install.sh script? I had problems with it, too, but the developer said they fixed it.
may i ask which version / how you installed? maybe i should re-open that issue:
https://github.com/gaenserich/hostsblock/issues/87

fwiw, the AUR installation method has always been reliable, and so is the script once you have it installed properly.

edit:
seems i cannot re-open the issue, i created a new one:
https://github.com/gaenserich/hostsblock/issues/88

Not sure of the version, but I know that I used the generic OS .zip file and installed it using the install.sh: https://github.com/gaenserich/hostsbloc ... master.zip

Thank you so much for re-opening the bug. That was awesome of you! *gives a star* :D

I wonder why they opted to have this program make its own user? Security? Seems unnecessary to me. :?


Here is my—very crude—hosts setup that I use for now if anybody is interested:
Code: Select all
#!/bin/sh

if ! [ $(id -u) = 0 ]; then
   echo "This script must be run as root. Exiting."
   exit 1
fi

hostfile="/etc/hosts"
cd /home/user/scripts
echo "Updating hosts..."

echo "127.0.0.1       localhost\n127.0.1.1       debian.mydomain debian\n" > $hostfile

# Pick one filter below: Unified hosts = (adware + malware), Unified hosts + fakenews + gambling + social, Unified hosts + fakenews + gambling + porn + social
hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
#hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts"
#hostblockurl="https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts"

# Append to hosts
wget -O - $hostblockurl >> $hostfile

file="hosts.txt"
# Check if primary (longterm) hosts file exists.
if [ -f "$file" ]; then
        echo "$file found. Skipping download."
else
        echo "$file not found. Retrieving file..."
        wget https://hosts-file.net/download/hosts.zip; unzip hosts.zip
fi

# Append to hosts
cat hosts.txt >> $hostfile

# Fetch and append secondary updated hosts (goes along with the above primary host file)
hostblockurl="https://hosts-file.net/hphosts-partial.txt"
wget -O - $hostblockurl >> $hostfile

blocked=$(wc -l /etc/hosts | awk '{print $1;}')
echo "Hosts blocked: "$blocked

As can be seen, it combines the Steve's Github hosts with the huge hosts-file.net hosts. Yes, it's redundant and inefficient (750,000+ hosts blocked, but who knows if half of them even still exist or how many overlap). It will suffice until I have the time to make it more proper.
OS: Debian GNU/Linux (Buster—testing); Kernel: 4.16.0-2-amd64; Shell: sh; WM: i3
Machine: HP ProDesk 600 G3—i7-7700, 8GB RAM, 256 SSD, Intel HD Graphics 630

bedtime
 
Posts: 88
Joined: 2012-12-16 19:34

Re: Adblocking with /etc/hosts

Postby debiman » 2018-08-28 05:08

just to clarify:
gaenserich's hostsblock itself works well; it's the install.sh script that doesn't.

but i agree that it's slightly overkill for the situation; otoh it's good to have multiple sources combined.

bedtime wrote:I wonder why they opted to have this program make its own user? Security? Seems unnecessary to me. :?

it didn't at first, then at some point they changed it.
makes sense to me; it's never good to download stuff from the internet as root (btw, apt is doing the same nowadays).
if you want to know exactly why i guess you'd need to go trawling the archlinux forums thread.

i'm keeping the new issue alive.
i know it might take a while til the developer answers, but they will evtl.

bedtime, which debian version?
anything particular we need to know about?
User avatar
debiman
 
Posts: 2790
Joined: 2013-03-12 07:18

Previous

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable