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

69 lines
1.7 KiB
Python
Raw Normal View History

import collections
class DNSBL(object):
def __init__(self, hostname=None):
if not hostname == None:
self.hostname = hostname
2020-09-14 13:32:59 +00:00
def process(self, a_record, txt_record):
out = a_record
if txt_record is not None:
out += f" - {txt_record}"
return out
class ZenSpamhaus(DNSBL):
hostname = "zen.spamhaus.org"
2020-09-14 13:32:59 +00:00
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
if result in ["2", "3", "9"]:
desc = "spam"
elif result in ["4", "5", "6", "7"]:
desc = "exploits"
2020-09-17 14:23:11 +00:00
else:
desc = "unknown"
return f"{result} - {desc}"
class EFNetRBL(DNSBL):
hostname = "rbl.efnetrbl.org"
2020-09-14 13:32:59 +00:00
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
if result == "1":
desc = "proxy"
2019-12-12 14:54:58 +00:00
elif result in ["2", "3"]:
desc = "spamtap"
elif result == "4":
desc = "tor"
elif result == "5":
desc = "flooding"
return f"{result} - {desc}"
2019-12-12 14:54:58 +00:00
class DroneBL(DNSBL):
hostname = "dnsbl.dronebl.org"
2020-08-06 14:12:36 +00:00
class AbuseAtCBL(DNSBL):
hostname = "cbl.abuseat.org"
2020-09-14 13:32:59 +00:00
def process(self, a_record, txt_record):
result = a_record.rsplit(".", 1)[1]
2020-08-06 14:12:36 +00:00
if result == "2":
desc = "abuse"
else:
desc = "unknown"
return f"{result} - {desc}"
2020-08-06 14:12:36 +00:00
2020-09-18 01:02:31 +00:00
class TorExitDan(DNSBL):
hostname = "torexit.dan.me.uk"
def process(self, a_record, txt_record):
return "tor exit"
DEFAULT_LISTS = [
ZenSpamhaus(),
2019-12-12 14:54:58 +00:00
EFNetRBL(),
2020-08-06 14:12:36 +00:00
DroneBL(),
2020-09-18 01:02:31 +00:00
AbuseAtCBL(),
TorExitDan()
]
def default_lists():
return collections.OrderedDict(
(dnsbl.hostname, dnsbl) for dnsbl in DEFAULT_LISTS)