bitbot-3.11-fork/modules/dnsbl/lists.py

60 lines
1.6 KiB
Python
Raw Normal View History

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"
def process(self, result):
result = result.rsplit(".", 1)[1]
if result == "1":
return "proxy"
2019-12-12 14:54:58 +00:00
elif result in ["2", "3"]:
return "spamtap"
elif result == "4":
return "tor"
elif result == "5":
return "flooding"
2019-12-12 14:54:58 +00:00
class DroneBL(DNSBL):
hostname = "dnsbl.dronebl.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
if result in ["8", "9", "10", "11", "14"]:
return "proxy"
elif result in ["3", "6", "7"]:
return "flooding"
elif result in ["12", "13", "15", "16"]:
return "exploits"
2020-08-06 14:12:36 +00:00
class AbuseAtCBL(DNSBL):
hostname = "cbl.abuseat.org"
def process(self, result):
result = result.rsplit(".", 1)[1]
if result == "2":
return "abuse"
DEFAULT_LISTS = [
ZenSpamhaus(),
2019-12-12 14:54:58 +00:00
EFNetRBL(),
2020-08-06 14:12:36 +00:00
DroneBL(),
AbuseAtCBL()
]
def default_lists():
return collections.OrderedDict(
(dnsbl.hostname, dnsbl) for dnsbl in DEFAULT_LISTS)