Improve your security and privacy by blocking ads, tracking and malware domains. https://hblock.molinero.dev
  • Shell 87.4%
  • Makefile 5.5%
  • Roff 4.4%
  • M4 2.7%
Find a file
Héctor Molinero Fernández 225f00993f Removed DShield blocklist
2020-10-17 19:42:20 +02:00
resources Replaced whitelist and blacklist terms with allowlist and denylist. 2020-10-11 22:11:43 +02:00
.gitignore Create deb and rpm packages 2019-01-05 17:01:10 +01:00
.gitlab-ci.yml Updated Busybox script 2020-10-17 18:58:14 +02:00
BSDmakefile Huge project overhaul with a new command line parser and a general refactorization 2020-10-11 21:35:57 +02:00
hblock Removed DShield blocklist 2020-10-17 19:42:20 +02:00
LICENSE.md Updated license year 2020-02-01 14:49:22 +01:00
Makefile Replaced whitelist and blacklist terms with allowlist and denylist. 2020-10-11 22:11:43 +02:00
package.json 2.1.7 2020-09-05 15:09:26 +02:00
README.md Removed DShield blocklist 2020-10-17 19:42:20 +02:00
SHA256SUMS 2.1.7 2020-09-05 15:09:26 +02:00

Build Website License


Improve your security and privacy by blocking ads, tracking and malware domains.

Table of contents

What is this for?

This POSIX-compliant shell script, designed for Unix-like systems, gets a list of domains that serve ads, tracking scripts and malware from multiple sources and creates a hosts file (alternative formats are also supported) that prevents your system from connecting to them.

Is it safe to use?

Absolutely, this script selects only the domain names for each source, so if a domain name is redirected to a rogue server your system will not be affected. In the worst scenario you can lose access to a legitimate domain name due a false positive, but you can reverse it by adding that domain to the allowlist.

Nightly builds

Nightly builds of the hosts file are available here among other formats.

https://hblock.molinero.dev

Installation

Manual

curl -o /tmp/hblock 'https://raw.githubusercontent.com/hectorm/hblock/v2.1.7/hblock' \
  && echo 'e357fc9439d7b79036c7939f976aab9cbd25878c4651e5a757e30ff96452edc2  /tmp/hblock' | shasum -c \
  && sudo mv /tmp/hblock /usr/local/bin/hblock \
  && sudo chown root:root /usr/local/bin/hblock \
  && sudo chmod 755 /usr/local/bin/hblock

Note: you can use this systemd timer to regularly update the hosts file for new additions.

Arch Linux

A package for Arch Linux users is available in the Arch User Repository (AUR).

Use your favorite AUR helper to perform the installation.

Gentoo

  • Add the src_prepare overlay with the help of the official repository.

  • Unmask the net-firewall/hblock package with the help of the Gentoo wiki.

  • Install hBlock through Portage:

    emerge --verbose net-firewall/hblock
    

FreeBSD

A package for FreeBSD users is available in FreshPorts.

pkg install hblock

Node.js

A package for Node.js users is available in npm.

npm install -g hblock

or

npx hblock

Usage

Script arguments

 -O, --output <FILE>
        Output file location.
         * Environment variable: HBLOCK_OUTPUT_FILE
         * Default value: /etc/hosts
 -H, --header <FILE>
        File to be included at the beginning of the output file.
        If the default file does not exist or equals "builtin" the built-in
        value is used instead.
         * Environment variable: HBLOCK_HEADER_FILE
         * Default value: /etc/hblock/header
 -F, --footer <FILE>
        File to be included at the end of the output file.
        If the default file does not exist or equals "builtin" the built-in
        value is used instead.
         * Environment variable: HBLOCK_FOOTER_FILE
         * Default value: /etc/hblock/footer
 -S, --sources <FILE>
        File with line separated URLs used to generate the blocklist.
        If the default file does not exist or equals "builtin" the built-in
        value is used instead.
         * Environment variable: HBLOCK_SOURCES_FILE
         * Default value: /etc/hblock/sources.list
 -A, --allowlist <FILE>
        File with line separated entries to be removed from the blocklist.
        If the default file does not exist or equals "builtin" the built-in
        value is used instead.
         * Environment variable: HBLOCK_ALLOWLIST_FILE
         * Default value: /etc/hblock/allow.list
 -D, --denylist <FILE>
        File with line separated entries to be added to the blocklist.
        If the default file does not exist or equals "builtin" the built-in
        value is used instead.
         * Environment variable: HBLOCK_DENYLIST_FILE
         * Default value: /etc/hblock/deny.list
 -R, --redirection <REDIRECTION>
        Redirection for all entries in the blocklist.
         * Environment variable: HBLOCK_REDIRECTION
         * Default value: 0.0.0.0
 -W, --WRAP <NUMBER>
        Break blocklist lines after this number of entries.
         * Environment variable: HBLOCK_WRAP
         * Default value: 1
 -T, --template <TEMPLATE>
        POSIX BREs replacement applied to each entry.
        Capturing group backreferences: \1 = <DOMAIN>, \2 = <REDIRECTION>
         * Environment variable: HBLOCK_TEMPLATE
         * Default value: \2 \1
 -C, --comment <COMMENT>
        Character used for comments.
         * Environment variable: HBLOCK_COMMENT
         * Default value: #
 -l, --[no-]lenient
        Match all entries from sources regardless of their IP, instead
        of 0.0.0.0, 127.0.0.1, ::, ::1 or nothing.
         * Environment variable: HBLOCK_LENIENT
         * Default value: false
 -r, --[no-]regex
        Use POSIX BREs in the allowlist instead of fixed strings.
         * Environment variable: HBLOCK_REGEX
         * Default value: false
 -c, --[no-]continue
        Do not abort if a download error occurs.
         * Environment variable: HBLOCK_CONTINUE
         * Default value: false
 -q, --[no-]quiet
        Suppress non-error messages.
         * Environment variable: HBLOCK_QUIET
         * Default value: false
 -x, --color <auto|true|false>
        Colorize the output.
         * Environment variable: HBLOCK_COLOR
         * Default value: auto
 -v, --version
        Show version number and quit.
 -h, --help
        Show this help and quit.

Run preview

asciicast

Sources

Name Primary Mirror
adaway.org URL URL
AdBlock NoCoin List URL URL
AdGuard - Simplified URL URL
AntiPopads URL URL
disconnect.me - Ad URL URL
disconnect.me - Malvertising URL URL
disconnect.me - Malware URL URL
disconnect.me - Tracking URL URL
EasyList URL URL
EasyPrivacy URL URL
ETH Phishing Detect URL URL
FadeMind - add.2o7Net URL URL
FadeMind - add.Dead URL URL
FadeMind - add.Risk URL URL
FadeMind - add.Spam URL URL
Geoffrey Frogeye - First-party trackers URL URL
hostsVN URL URL
KADhosts URL URL
lightswitch05 - Ads & Tracking URL URL
malwaredomainlist.com URL URL
malwaredomains.com - Immortal domains URL URL
malwaredomains.com - Just domains URL URL
matomo.org - Spammers URL URL
mitchellkrogza - Badd-Boyz-Hosts URL URL
pgl.yoyo.org URL URL
Phishing Army URL URL
someonewhocares.org URL URL
spam404.com URL URL
StevenBlack URL URL
uBlock URL URL
uBlock - Abuse URL URL
uBlock - Badware URL URL
uBlock - Privacy URL URL
URLhaus URL URL
winhelp2002.mvps.org URL URL
ZeroDot1 - CoinBlockerLists URL URL

Disclaimer

This script, by default, replaces the /etc/hosts file of your system. I am not responsible for any damage or loss, always make backups.

License

See the license file.