Giter Site home page Giter Site logo

parseword / nolovia Goto Github PK

View Code? Open in Web Editor NEW
21.0 8.0 6.0 74.29 MB

Nolovia is an ad/malware blocking configuration file generator for bind, NSD, and other DNS resolvers

License: Apache License 2.0

PHP 100.00%
php bind dns dns-zone-manager blackhole blacklist sinkhole dns-firewall

nolovia's Introduction

nolovia

nolovia is an ad-blocking config file generator for bind, NSD, or other DNS resolvers

From Latin, loosely: nolo, I don't want; via, a path or route.

nolovia helps you implement a blackholing DNS server or DNS "sinkhole" firewall, by generating configuration files that block potentially malicious servers.

nolovia ingests several public lists of advertising, tracking, analytics, malware, cryptojacking, and other undesirable servers. These lists are merged and minimized, then exported as a config file suitable for use with the bind or nsd DNS resolvers. A corresponding blackhole zone file is included.

Why operate a local DNS server?

Running your own DNS is a more powerful alternative to hosts file-based ad blocking and tracker blocking.

  • A DNS server can blackhole entire domains, even when you don't know all of their hostnames or subdomains.
  • With a local DNS server, you configure your blocking rules in one place, instead of constantly updating a text file on all the devices on your network.
  • Unlike hosts files, practically every smartphone will let you configure the DNS server without rooting it or installing custom software.

Using nolovia with bind

  1. Ensure you already have a working instance of the bind DNS resolver prior to starting. There are lots of tutorials on installing bind for your OS.

  2. Make a backup of your existing named.conf file.

  3. Obtain and run nolovia:

mkdir nolovia && cd nolovia
git clone https://github.com/parseword/nolovia.git .
php nolovia.php

This will generate a file named blackhole.conf.

  1. Copy blackhole.conf and the included blackhole.zone file to locations that suit your bind installation, like /var/named/ or c:\bind\.

  2. Edit your named.conf to define an access control list (ACL) named "recursers," this will determine who's allowed to query your DNS server recursively. For security purposes, only hosts on your local network should be allowed:

    acl recursers { localhost; localnets; };

Now look at the options { ... } stanza in your named.conf and find the recursion settings. To enable recursion for the recursers ACL only, set:

recursion yes;
allow-recursion { recursers; };
  1. Finally, add the following to the end of named.conf, specifying the path to which you copied blackhole.conf:

    include "/var/named/blackhole.conf";

Restart bind with service named restart or rndc reload as appropriate for your system, and make sure all the devices on your network are set to use your bind instance as their DNS server.

Using nolovia with NSD

  1. Ensure you already have a working instance of the NSD DNS resolver prior to starting. There are lots of tutorials on installing NSD for your OS.

  2. Make a backup of your existing nsd.conf file.

  3. Obtain nolovia and create its configuration file:

mkdir nolovia && cd nolovia
git clone https://github.com/parseword/nolovia.git .
cp config.php-dist config.php

  1. Edit config.php to enable NSD support

Out of the box, nolovia's NSD support isn't enabled. Open the config.php file in the editor of your choice, and look for this section, which is around line 70 as of this writing:

//nsd (disabled by default)
$r = new ResolverConfiguration('nsd');
$r->setEnabled(false);
...

Change $r->setEnabled(false); to $r->setEnabled(true); and save the file.

  1. Run nolovia

php nolovia.php

This will generate a file named blackhole-nsd.conf.

  1. Copy blackhole-nsd.conf to your system's NSD configuration directory, e.g.
    /etc/nsd/conf.d/. The default settings for NSD should automatically load any .conf files in that directory; if this doesn't occur, you'll need to edit your nsd.conf file and add the line

    include: "/path/to/blackhole-nsd.conf".

  2. The nolovia distribution includes a blackhole.zone file. Copy this file into your NSD zonesdir, which is probably /etc/nsd/.

Restart NSD with service nsd restart or nsd-control reconfig as appropriate
for your system, and make sure the devices on your network are set to use your NSD instance as their DNS server.

After installation

Now see what breaks! Some sites you use might lose functionality because of server blocking. Edit the personal-whitelist.txt and personal-blacklist.txt files to tweak nolovia's generated lists to your liking, then run it again to create a new blackhole.conf file. Once you've worked out any kinks, consider setting up a daily cron job to make an updated blackhole.conf, copy it to wherever your resolver looks for it, and reload the name server.

TODO:

  • Export zone files for additional resolvers
  • Add capability to filter entire TLDs (e.g. .top)
  • Filter hostnames N levels deep instead of just 2, e.g. if metric.gstatic.com is blocked, p2-aahhyknavsj2m-wtnlrzkba6lht33q-if-v6exp3-v4.metric.gstatic.com should be recognized as a subdomain instead of making a separate entry
  • Support RPZ or hole-punching (e.g. "block all of evilcompany.tld except safeserver.evilcompany.tld")

nolovia's People

Contributors

ampersign avatar parseword avatar

Stargazers

 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  avatar  avatar

nolovia's Issues

Failure to fetch "SANS ISC Suspicious Domains"

Although I check that there is a corresponding file as far as accessing with the browser, even if running nolovia.php seems to download as below.

21:24:40 -   0.01s -     427808 bytes - Processing list: SANS ISC Suspicious Domains
21:24:40 -   0.01s -     427840 bytes - Retrieving URI (try #1): https://isc.sans.edu/feeds/suspiciousdomains_Low.txt
21:25:40 -  60.22s -     428256 bytes - Fetched 0 bytes
21:25:40 -  60.22s -     428312 bytes - Server response was only 0 bytes, expected at least 4096
21:25:40 -  60.22s -     428312 bytes - Server response is missing validation text "Suspicious Domain List"
21:25:40 -  60.22s -     428328 bytes - Retrieving URI (try #2): https://isc.sans.edu/feeds/suspiciousdomains_Low.txt
21:26:40 - 120.28s -     428256 bytes - Fetched 0 bytes
21:26:40 - 120.28s -     428312 bytes - Server response was only 0 bytes, expected at least 4096
21:26:40 - 120.28s -     428312 bytes - Server response is missing validation text "Suspicious Domain List"
21:26:40 - 120.28s -     428328 bytes - Retrieving URI (try #3): https://isc.sans.edu/feeds/suspiciousdomains_Low.txt
21:27:40 - 180.35s -     428256 bytes - Fetched 0 bytes
21:27:40 - 180.35s -     428312 bytes - Server response was only 0 bytes, expected at least 4096
21:27:40 - 180.35s -     428312 bytes - Server response is missing validation text "Suspicious Domain List"
21:27:40 - 180.35s -     428312 bytes - Exhausted retry attempts fetching SANS ISC Suspicious Domains
21:27:40 - 180.35s -     428328 bytes - Not writing list SANS ISC Suspicious Domains to disk due to fetch failure
21:27:40 - 180.35s -     428328 bytes - FAILURE: The previous error was fatal; exiting

hubs.ly

So this is HubSpot's URL shortener service
There is some tracking behind the scenes, but so does every URL shortening service have a little tracking
I think we should be consistent and either block all the URL shortener services, or unblock them all.

no list

It seems to get a list of the following URLs, but it does not seem to exist at present.

http://www.networksec.org/grabbho/block.txt

By myself, by commenting out for the time being, it responds to download failure.

my.plexapp.com

false positive
used for managing plex account
on skel/hosts-hphosts-legacy.txt

Invalid characters in adblock list

The below domains contain invalid/illegal characters and should be removed from the ad blocklists
endurableshop.com^
myetherwället.org
verifìcation.com

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.