Git Product home page Git Product logo

angela-d / autohosts Goto Github PK

View Code? Open in Web Editor NEW
79.0 6.0 5.0 627 KB

Automate hosts file updates on Linux and MacOS. Block Firefox telemetry, Google snooping and web trackers at the root.

License: GNU General Public License v2.0

Shell 94.25% Roff 5.58% Makefile 0.17%
hosts hostsfile adblocking privacy privacy-tools tracking-protection firefox-telemetry privacy-enhancing-technologies bash bash-script

autohosts's Introduction

Auto Update Ad-blocking Hosts file on Linux and Mac Systems

Automate hosts file updates on Linux-based and MacOS systems.

Linux Mac

v3.1.0 Changes

  • Nothing of interest to Linux users
  • Use LaunchAgents instead of cron (Mac)
  • MDM helper scripts added to repo for mass deployment

Purpose of Hosts Files

Hosts files will reroute unwanted traffic from ad farms, behavioral tracking firms and malware sites to a blackhole; routing to 0.0.0.0 (localhost; your PC) when a request is made to a URL on the blacklist.

Which means any traffic that would have left your system for that destination, is sent inward, to your localhost and then abandoned.

Despite what some may suggest, hosts files are not "1980s technology" and still very useful today, as an additional layer of security.

Hosts file are a useful redundancy when coupled with ad blockers like uBlock Origin and uMatrix - while debugging or 'Temporarily Allow All on this Site' with Noscript can open you up to underlying attacks or privacy intrusions.

  • If you're a Safari user and want a pretty pre-made GUI for your adblocking, try AdGuard - note that this app is a plugin for Safari only; if you want cross-browser blocking, they have paid options, or you can use something like Autohosts for free (this very repo!).

In-browser filters won't protect you if the browser itself is phoning home.

If you have an up-to-date hosts file, the risk is severely lessened.

Auto Hosts will automate the setup process for maintaining an up to date hosts file, by:

  • Installing a weekly cronjob to pull fresh/updated copies of hosts lists (default is every Sunday at 7:22pm)
  • (Default custom_filters and firefox-includes) source appends Facebook trackers, Linkedin ads, Google fonts, Firefox telemetry and other harvester sites that curated lists for whatever reason, have not added to their blacklists
  • Refreshes DNS to instantiate the re-routed changes (Mac Only)
  • If Devdom is installed, append all local virtualhosts (if it is installed - it is -not- a requirement! Autohosts does a conditional check to ensure your dev environment doesn't break if you're using Devdom. Read the code.)
  • Uninstall offers the ability to revert to a fresh hosts file and undo any changes made by Autohosts; a backup will be copied to /tmp
  • Add custom blacklists, whitelists and host sources from ~/autohosts on your desktop

Who Should Use Autohosts?

If you are frequently mobile, your privacy-hardened installs of Pi-Hole, OpenWRT or DD-WRT on your home router will not protect you. Autohosts will shield you while on the go, independent of whose network you logon to.

Likewise, not everyone has the means to flash custom router firmware or the skill necessary to do so. Autohosts can fill that gap.

Installing:

Install

Firefox Snooping list, originally by LocalFigurez

For those of us who want our browser to behave like a browser and not a GPS anklet, this list will prove useful by blocking a plethora of tracking URLs. A few of which, some Firefox users have noticed seem to phone home even when the setting is toggled off in about:config.

Custom filters

You can easily append any domain you want to blacklist directly from your home directory. Your custom preferences will be stored with each subsequent update - set it and forget it!

Whitelisting

If the upstream list curators block a domain you want to see, add it to ~/autohosts/whitelist and run sudo autohosts

Be sure to add nothing other than the domain(s) you want to whitelist to this file! I added 3 examples to the default whitelist file; you can regex it (TLD domain with no prefix or suffix, to whitelist subdomains, too: example) or supply a full TLD: www.example.com

To Install

Debian-based Linux distros:

git clone https://github.com/angela-d/autohosts.git && cd autohosts && sudo apt install ./autohosts.deb

MacOS or non-Debian-based Linux distros:

git clone https://github.com/angela-d/autohosts.git && cd autohosts && sudo ./autohosts

That's it !


To upgrade an existing install

To see which version you're running on your system: grep "VERSION=" /etc/autohosts.conf

Non-Debian-based distros or MacOS:

Due to structural changes in the codebase, an uninstall and reinstall is recommended (unless installed via deb). You can do this without losing your custom filters.

git clone https://github.com/angela-d/autohosts.git /tmp/autohosts && cd /tmp/autohosts && cp ~/autohosts/custom_filters /tmp/custom_filters

Once installation completes, restore your custom filters:

rm ~/autohosts/custom_filters && mv /tmp/custom_filters ~/autohosts/custom_filters

Debian users

Simply download the latest .deb & run (in the directory where you put the download):

apt install ./autohosts.deb

to upgrade to the latest version.


Adding Custom Blacklists or Whitelists

  • These files can be edited in your favorite text editor; command-line modifications are not necessary!

Custom filters are loaded to your home directory:

Filter Option Linux Linux File Location Mac Mac File Location
Blacklist ~/autohosts/custom_filters or /home/your_username/autohosts/custom_filters ~/autohosts/custom_filters or /Users/your_username/autohosts/custom_filters
Whitelist ~/autohosts/whitelist or /home/your_username/autohosts/whitelist ~/autohosts/whitelist or /Users/your_username/autohosts/whitelist
Hosts List Curator ~/autohosts/hosts_source or /home/your_username/autohosts/hosts_source ~/autohosts/hosts_source or /Users/your_username/autohosts/hosts_source

Choosing Hosts Curators

Use as many as you'd like, to strengthen your filtering. Though it would be wise to keep the total to a reasonable amount; as there is not currently any duplicate removal, so the potential for unneeded overhead is certain.

List each curator on a separate line in ~/autohosts/hosts_source - do not add any comments or whitespace to this file - just a list of the raw hosts source. (ie. the plain-text filters).

When an update is ran, Autohosts will probe each curator to ensure the list is responding with a 200/OK response, so the potential for indexing garbled junk to your hosts file is severely lessened.

Adjust the cron time

If your computer is not powered on when the cron is scheduled, you'll miss the update. Ensure the cronjob is set for a time when you're most likely to have it on. You can adjust it by running:

sudo crontab -e

and modifying the dates to suit.

Cron legend:

* * * * * = minute, hour, day of month, month, day of week (0 = Sunday, 6 = Saturday)

(* = every, so 5 straight stars is equal to every minute of every hour of every day and every month.. which you should never run while pulling 3rd party content!)

Uninstalling:

Install

Note: Because this script has to modify /etc/hosts - it needs elevated privileges (running as root or a sudo user). Scripts that require elevated privileges should be read and analyzed so you know what's being done to your system! Read the source code of this script (and any others requiring such permissions) before you install.

Alternative uses with Hosts files

Troubleshooting

If it appears autohosts isn't blocking anything, your browser likely has imposed DoH / DNS Over HTTPS on you.


If you'd like to disable DoH:

Vivaldi or Chrome / Chromium:

  • Enter chrome://flags in your address bar and find: Secure DNS lookups > toggle to disable

Firefox:

  • Enter about:preferences on your address bar and in the search box, enter dns > Settings > scroll to the bottom and un-tick Enable DNS over HTTPS

Known Bugs / To Fix

manpage on Debian isn't seen. No manpage at all for non-Debian installs.

autohosts's People

Contributors

alex-kovac avatar angela-d avatar gitthubba avatar leancode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

autohosts's Issues

Install error and custom_filters not found

Hi,
Thanks for the programme. But I have some problems.

Install on Linux Mint 19.1 half works.
On install I get this

$sudo apt install ./autohosts.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'autohosts' instead of './autohosts.deb'
autohosts is already the newest version (2.0.0).
The following packages were automatically installed and are no longer required:
chromium-codecs-ffmpeg-extra gir1.2-geoclue-2.0 gir1.2-geocodeglib-1.0
gir1.2-gweather-3.0 gjs libgjs0g python3-mutagen youtube-dl
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 55 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up autohosts (2.0.0) ...
dpkg: error processing package autohosts (--configure):
installed autohosts package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
autohosts
E: Sub-process /usr/bin/dpkg returned an error code (1)

Grep version gives:

──╼ $grep "VERSION=" /usr/local/bin/autohosts
grep: /usr/local/bin/autohosts: No such file or directory

Then running autohosts returns:

_- 100%[===================>] 5,48K --.-KB/s in 0s

2019-06-02 01:34:34 (44,8 MB/s) - written to stdout [5609/5609]

No custom filters found at home_user, skipping...
Checking if devdom is installed (will execute devdom hosts update, if so)
Devdom is not installed; skipping.
Hosts update complete!_

Not sure where to go from here.

Also, is it possible to alter which version of Steven Black's hosts file is used?

Thanks!

Uninstalling on mac

Hi there
Newbie...:)
need help for command line in terminal for uninstalling
thanks
Ronnie

mozilla.org is blocked?

i am unable to access mozilla.org with autohosts installed. i removed autohosts to confirm this issue.
i grepped the /etc/hosts file

cat /etc/hosts | grep mozilla.org
0.0.0.0 incoming.telemetry.mozilla.org
0.0.0.0 crash-stats.mozilla.org
0.0.0.0 experiments.mozilla.org
0.0.0.0 incoming.telemetry.mozilla.org
0.0.0.0 input.mozilla.org
0.0.0.0 self-repair.mozilla.org
0.0.0.0 tbpl.mozilla.org
0.0.0.0 telemetry.mozilla.org
0.0.0.0 reps.mozilla.org
0.0.0.0 intranet.mozilla.org
0.0.0.0 activations.mozilla.org
0.0.0.0 dnt.mozilla.org
0.0.0.0 www.mozilla.org.cdn.cloudflare.net
0.0.0.0 ftp.mozilla.org
0.0.0.0 mxr.mozilla.org
0.0.0.0 nightly.mozilla.org
0.0.0.0 pfs.mozilla.org
0.0.0.0 planet.mozilla.org
0.0.0.0 static-san.mozilla.org
0.0.0.0 videos.mozilla.org
0.0.0.0 mana.mozilla.org
0.0.0.0 symbols.mozilla.org
0.0.0.0 dxr.mozilla.org

why and how is mozilla.org blocked?
all of the output has subdomains of mozilla.org blocked but not mozilla.org blocked. how do i unblock this?

Cannot uninstall Autohosts

Angela, I installed Autohosts (Ah) yesterday, but found today that I cannot install Firefox (Ff) extensions anymore. I moved the Ff subfolder from the Ah folder, restarted Ff, but still no joy so put the Ff subfolder back in the Ah folder.
I tried to uninstall Ah altogether but the Terminal tells me there is no Ah folder. I deleted the entire Ah folder, restarted Ff, no joy. I checked the etc/hosts folder: only the original entries are there, though there is a text at the top mentioning the merged lists.
Ubuntu will not uninstall Ah, and I am stuck with Ff to which I cannot extensions. Please advise.

P.S. I am new to Linux, hence my clumsiness.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.