aboutsummaryrefslogtreecommitdiff
path: root/modules/dnsbl/lists.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-12-12 14:13:17 +0000
committerGravatar jesopo2019-12-12 14:13:17 +0000
commitfbe1acf220b69e244776105390b1abf5b77a96e8 (patch)
tree46dfcb8182ea2a069809b936e5ae72271995ad89 /modules/dnsbl/lists.py
parentlist.insert() takes an index! (diff)
signature
refactor dnsbl module, show reason for positive detection when possible
Diffstat (limited to 'modules/dnsbl/lists.py')
-rw-r--r--modules/dnsbl/lists.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/dnsbl/lists.py b/modules/dnsbl/lists.py
new file mode 100644
index 00000000..0ae6a1b6
--- /dev/null
+++ b/modules/dnsbl/lists.py
@@ -0,0 +1,40 @@
+import collections
+
+class DNSBL(object):
+ def __init__(self, hostname=None):
+ if not hostname == None:
+ self.hostname = hostname
+
+ def process(self, result: str):
+ return "unknown"
+
+class ZenSpamhaus(DNSBL):
+ hostname = "zen.spamhaus.org"
+ def process(self, result):
+ result = result.rsplit(".", 1)[1]
+ if result in ["2", "3", "9"]:
+ return "spam"
+ elif result in ["4", "5", "6", "7"]:
+ return "exploits"
+class EFNetRBL(DNSBL):
+ hostname = "rbl.efnetrbl.org"
+ SPAMTRAP = ["2", "3"]
+ def process(self, result):
+ result = result.rsplit(".", 1)[1]
+ if result == "1":
+ return "proxy"
+ elif result in self.SPAMTRAP:
+ return "spamtap"
+ elif result == "4":
+ return "tor"
+ elif result == "5":
+ return "flooding"
+
+DEFAULT_LISTS = [
+ ZenSpamhaus(),
+ EFNetRBL()
+]
+
+def default_lists():
+ return collections.OrderedDict(
+ (dnsbl.hostname, dnsbl) for dnsbl in DEFAULT_LISTS)