aboutsummaryrefslogtreecommitdiff
path: root/modules/dnsbl/lists.py
blob: 0ae6a1b688338e27d29aff2c85ab9ff94a02d70d (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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)