A simple, synchronous, rate-limiting DoH client to check if a given response is filtered by the specified resolver.
Project description
dns-mollusc
A simple, synchronous, rate-limiting DoH client to check if a given response is filtered by the specified resolver.
dns-mollusc does the bare minimum to reliably accomplish the above job, and is not intended as a general purpose DoH client. For excellent DNS shenanigans in Python, I'd recommend dnspython.
Usage
dns-mollusc uses Cloudflare's secure DNS as default, which blocks known-malicious domains, with a rate limit of 100 queries per second. If no query type is given, dns-mollusc will query for an A record (IPv4 address). The simplest usage of dns-mollusc would be:
from dns_mollusc import mollusc_client
client = mollusc_client()
result = client.query("malware.testcategory.com")
result.is_blocked_by_server() # returns True
However, you can set your preferred resolver and/or rate limit, such as using Adguard DNS and a QPS limit of 10 requests/s:
client = mollusc_client("https://dns.adguard.com/resolve?", 10)
And when querying, you can request any record type (though resolvers may not filter all request types):
result = client.query("malware.testcategory.com", "AAAA")
Known-Supported Resolvers
dns-mollusc uses a non-standard DoH JSON API popularized by Google's public DNS service. It does not (and will not in the future) implement RFC 8484, which limits the number of resolves that work with dns-mollusc. The following resolvers are tested and working, sorted by what they filter.
Filters malware:
- Cloudflare Secure DNS,
https://security.cloudflare-dns.com/dns-query?
Filters adult content and malware:
- Cloudflare Family DNS,
https://family.cloudflare-dns.com/dns-query?
Filters ads:
- Adguard DNS,
https://dns.adguard.com/resolve?
Filters (almost) whatever you want:
- NextDNS, subscription-only (copy the "DNS-over-HTTPS" endpoint from your account's Setup tab)
Unfiltered:
- Google DNS (8.8.8.8),
https://dns.google/resolve?
- Cloudflare DNS (1.1.1.1),
https://cloudflare-dns.com/dns-query?
- NextDNS public,
https://dns.nextdns.io/dns-query?
Why?
A bot used on r/cybersecurity checks any live links in comments and posts for obviously malicious or unwanted content (the logic included here was originally ripped from that bot). This allows us to get low-grade but constantly-updated protection as a supplement to other tools that we have.
The name "dns-mollusc" stems from the fact that molluscs can be used to monitor water for contamination, often in conjunction with more sophisticated methods. From Wikipedia:
Bivalve molluscs are used as bioindicators to monitor the health of aquatic environments in both fresh water and the marine environments. Their population status or structure, physiology, behaviour or the level of contamination with elements or compounds can indicate the state of contamination status of the ecosystem. ... Potamopyrgus antipodarum is used by some water treatment plants to test for estrogen-mimicking pollutants from industrial agriculture.
I was going to go with "dns-clam" but didn't want people to associate it with ClamAV.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dns-mollusc-0.2.tar.gz
.
File metadata
- Download URL: dns-mollusc-0.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11b8d35bd8a244150a7f5f3691ac353e3461064895fc252323a4a3e98527a024 |
|
MD5 | 4f95f1228f532e876f05350d31204234 |
|
BLAKE2b-256 | 52d38ef5f1125eae798f5d6b92dafeebd605f6c74718014778a88f5f81b76d5e |
File details
Details for the file dns_mollusc-0.2-py3-none-any.whl
.
File metadata
- Download URL: dns_mollusc-0.2-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98b302fcd02df2ddc631d03d4a8a4d3aea1451f23a7990fc0f9bacf32313f129 |
|
MD5 | 085c63022ac9e2d5b56598c669cf2667 |
|
BLAKE2b-256 | cdb7dd014c23b88281e5dc1716ebde67b4bf3a2f750a1b73e77ce2a637f77305 |