Skip to content

Instantly share code, notes, and snippets.

@tsvsys
Forked from mudge/blocklist.sh
Created April 9, 2024 16:41
Show Gist options
  • Save tsvsys/48b82ececd0023f5b1177ddd047e83a7 to your computer and use it in GitHub Desktop.
Save tsvsys/48b82ececd0023f5b1177ddd047e83a7 to your computer and use it in GitHub Desktop.

Revisions

  1. @mudge mudge revised this gist Jun 7, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -56,4 +56,4 @@ IFS=$'\n\t'
    grep '^0\.0\.0\.0' | # Filter out any comments, etc. that aren't rules
    tr -d '\r' | # Normalize line endings by removing Windows carriage returns
    sort -u | # Remove any duplicates
    awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\"\nlocal-data: \""$2" AAAA ::\""}' # Convert to Unbound configuration
    awk '{print "local-zone: \""$2".\" redirect\nlocal-data: \""$2". IN A 0.0.0.0\"\nlocal-data: \""$2". IN AAAA ::\""}' # Convert to Unbound configuration
    2 changes: 1 addition & 1 deletion safelist.sh
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,4 @@ IFS=$'\n\t'
    # [0]: https://github.com/anudeepND/whitelist
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" |
    sort -u | # Remove any duplicates
    awk '{print "local-zone: \""$1"\" always_transparent"}' # Convert to Unbound configuration
    awk '{print "local-zone: \""$1".\" always_transparent"}' # Convert to Unbound configuration
  2. @mudge mudge revised this gist Jun 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -56,4 +56,4 @@ IFS=$'\n\t'
    grep '^0\.0\.0\.0' | # Filter out any comments, etc. that aren't rules
    tr -d '\r' | # Normalize line endings by removing Windows carriage returns
    sort -u | # Remove any duplicates
    awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}' # Convert to Unbound configuration
    awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\"\nlocal-data: \""$2" AAAA ::\""}' # Convert to Unbound configuration
  3. @mudge mudge revised this gist Jun 7, 2020. 2 changed files with 52 additions and 0 deletions.
    46 changes: 46 additions & 0 deletions unbound.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    server:
    verbosity: 0

    interface: 0.0.0.0
    access-control: 192.168.1.0/24 allow

    port: 53
    do-ip4: yes
    do-ip6: no
    do-udp: yes
    do-tcp: yes

    root-hints: "/var/lib/unbound/root.hints"
    harden-glue: yes

    # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS
    harden-dnssec-stripped: yes

    # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes
    # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details
    use-caps-for-id: no

    # Reduce EDNS reassembly buffer size.
    # Suggested by the unbound man page to reduce fragmentation reassembly problems
    edns-buffer-size: 1472

    # Perform prefetching of close to expired message cache entries
    # This only applies to domains that have been frequently queried
    prefetch: yes

    # One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1.
    num-threads: 1

    # Ensure kernel buffer is large enough to not lose messages in traffic spikes
    so-rcvbuf: 1m

    # Ensure privacy of local IP ranges
    private-address: 192.168.0.0/16
    private-address: 169.254.0.0/16
    private-address: 172.16.0.0/12
    private-address: 10.0.0.0/8
    private-address: fd00::/8
    private-address: fe80::/10

    # Include blocklist and safelist
    include: /etc/unbound/lists.d/*.conf
    6 changes: 6 additions & 0 deletions update-blocklists.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/bin/bash
    set -euo pipefail

    /opt/blocklists/safelist.sh > /etc/unbound/lists.d/01-safelist.conf
    /opt/blocklists/blocklist.sh > /etc/unbound/lists.d/02-blocklist.conf
    service unbound reload
  4. @mudge mudge revised this gist Jun 7, 2020. 2 changed files with 9 additions and 2 deletions.
    7 changes: 6 additions & 1 deletion blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -51,4 +51,9 @@ IFS=$'\n\t'

    # Other Lists
    curl -sSf "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" ;
    ) | cat | grep '^0\.0\.0\.0' | tr -d '\r' | sort -u | awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}'
    ) |
    cat | # Combine all lists into one
    grep '^0\.0\.0\.0' | # Filter out any comments, etc. that aren't rules
    tr -d '\r' | # Normalize line endings by removing Windows carriage returns
    sort -u | # Remove any duplicates
    awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}' # Convert to Unbound configuration
    4 changes: 3 additions & 1 deletion safelist.sh
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,6 @@ IFS=$'\n\t'
    # Download Anudeep's commonly safelisted domains [0] and allow Unbound lookups to them.
    #
    # [0]: https://github.com/anudeepND/whitelist
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" | sort -u | awk '{print "local-zone: \""$1"\" always_transparent"}'
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" |
    sort -u | # Remove any duplicates
    awk '{print "local-zone: \""$1"\" always_transparent"}' # Convert to Unbound configuration
  5. @mudge mudge revised this gist Jun 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion safelist.sh
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@ IFS=$'\n\t'
    # Download Anudeep's commonly safelisted domains [0] and allow Unbound lookups to them.
    #
    # [0]: https://github.com/anudeepND/whitelist
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" | sort -u | awk '{print "local-zone: \""$1"\" transparent"}'
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" | sort -u | awk '{print "local-zone: \""$1"\" always_transparent"}'
  6. @mudge mudge revised this gist Jun 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -51,4 +51,4 @@ IFS=$'\n\t'

    # Other Lists
    curl -sSf "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" ;
    ) | cat | grep '^0\.0\.0\.0' | sort -u | awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}'
    ) | cat | grep '^0\.0\.0\.0' | tr -d '\r' | sort -u | awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}'
  7. @mudge mudge revised this gist Jun 7, 2020. 2 changed files with 22 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,18 @@
    set -euo pipefail
    IFS=$'\n\t'

    # Download all ticked blocklists from The Firebog's "The Big Blocklist
    # Collection" [0] and block access to them with Unbound by redirecting traffic
    # to 0.0.0.0.
    #
    # [0]: https://firebog.net
    (
    # Suspicious Lists
    curl -sSf "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts_without_controversies.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts" ;
    curl -sSf "https://v.firebog.net/hosts/static/w3kbl.txt" ;

    # Advertising Lists
    curl -sSf "https://adaway.org/hosts.txt" ;
    curl -sSf "https://v.firebog.net/hosts/AdguardDNS.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Admiral.txt" ;
    @@ -15,12 +23,16 @@ IFS=$'\n\t'
    curl -sSf "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts" ;
    curl -sSf "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts" ;

    # Tracking & Telemetry Lists
    curl -sSf "https://v.firebog.net/hosts/Easyprivacy.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Prigent-Ads.txt" ;
    curl -sSf "https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts" ;
    curl -sSf "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt" ;
    curl -sSf "https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt" ;

    # Malicious Lists
    curl -sSf "https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alternate%20versions%20Anti-Malware%20List/AntiMalwareHosts.txt" ;
    curl -sSf "https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt" ;
    curl -sSf "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt" ;
    @@ -36,5 +48,7 @@ IFS=$'\n\t'
    curl -sSf "https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts" ;
    curl -sSf "https://urlhaus.abuse.ch/downloads/hostfile/" ;

    # Other Lists
    curl -sSf "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" ;
    ) | cat | grep '^0\.0\.0\.0' | sort -u | awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}'
    8 changes: 8 additions & 0 deletions safelist.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/bin/bash
    set -euo pipefail
    IFS=$'\n\t'

    # Download Anudeep's commonly safelisted domains [0] and allow Unbound lookups to them.
    #
    # [0]: https://github.com/anudeepND/whitelist
    curl -sSf "https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt" | sort -u | awk '{print "local-zone: \""$1"\" transparent"}'
  8. @mudge mudge created this gist Jun 7, 2020.
    40 changes: 40 additions & 0 deletions blocklist.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/bin/bash
    set -euo pipefail
    IFS=$'\n\t'

    (
    curl -sSf "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts_without_controversies.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts" ;
    curl -sSf "https://v.firebog.net/hosts/static/w3kbl.txt" ;
    curl -sSf "https://adaway.org/hosts.txt" ;
    curl -sSf "https://v.firebog.net/hosts/AdguardDNS.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Admiral.txt" ;
    curl -sSf "https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt" ;
    curl -sSf "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Easylist.txt" ;
    curl -sSf "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts" ;
    curl -sSf "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts" ;
    curl -sSf "https://v.firebog.net/hosts/Easyprivacy.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Prigent-Ads.txt" ;
    curl -sSf "https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts" ;
    curl -sSf "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt" ;
    curl -sSf "https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt" ;
    curl -sSf "https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alternate%20versions%20Anti-Malware%20List/AntiMalwareHosts.txt" ;
    curl -sSf "https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt" ;
    curl -sSf "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt" ;
    curl -sSf "https://mirror1.malwaredomains.com/files/justdomains" ;
    curl -sSf "https://v.firebog.net/hosts/Prigent-Crypto.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Prigent-Malware.txt" ;
    curl -sSf "https://mirror.cedia.org.ec/malwaredomains/immortal_domains.txt" ;
    curl -sSf "https://www.malwaredomainlist.com/hostslist/hosts.txt" ;
    curl -sSf "https://bitbucket.org/ethanr/dns-blacklists/raw/8575c9f96e5b4a1308f2f12394abd86d0927a4a0/bad_lists/Mandiant_APT1_Report_Appendix_D.txt" ;
    curl -sSf "https://phishing.army/download/phishing_army_blocklist_extended.txt" ;
    curl -sSf "https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt" ;
    curl -sSf "https://v.firebog.net/hosts/Shalla-mal.txt" ;
    curl -sSf "https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt" ;
    curl -sSf "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts" ;
    curl -sSf "https://urlhaus.abuse.ch/downloads/hostfile/" ;
    curl -sSf "https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser" ;
    ) | cat | grep '^0\.0\.0\.0' | sort -u | awk '{print "local-zone: \""$2"\" redirect\nlocal-data: \""$2" A 0.0.0.0\""}'