2019-12-12 14:13:17 +00:00
|
|
|
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
|
2019-12-12 14:13:17 +00:00
|
|
|
|
|
|
|
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]
|
2019-12-12 14:13:17 +00:00
|
|
|
if result in ["2", "3", "9"]:
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "spam"
|
2019-12-12 14:13:17 +00:00
|
|
|
elif result in ["4", "5", "6", "7"]:
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "exploits"
|
2020-09-17 14:23:11 +00:00
|
|
|
else:
|
|
|
|
desc = "unknown"
|
2020-09-08 15:48:14 +00:00
|
|
|
return f"{result} - {desc}"
|
|
|
|
|
2019-12-12 14:13:17 +00:00
|
|
|
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]
|
2019-12-12 14:13:17 +00:00
|
|
|
if result == "1":
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "proxy"
|
2019-12-12 14:54:58 +00:00
|
|
|
elif result in ["2", "3"]:
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "spamtap"
|
2019-12-12 14:13:17 +00:00
|
|
|
elif result == "4":
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "tor"
|
2019-12-12 14:13:17 +00:00
|
|
|
elif result == "5":
|
2020-09-08 15:48:14 +00:00
|
|
|
desc = "flooding"
|
|
|
|
return f"{result} - {desc}"
|
2019-12-12 14:13:17 +00:00
|
|
|
|
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":
|
2020-09-08 15:48:14 +00:00
|
|
|
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"
|
|
|
|
|
2019-12-12 14:13:17 +00:00
|
|
|
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()
|
2019-12-12 14:13:17 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def default_lists():
|
|
|
|
return collections.OrderedDict(
|
|
|
|
(dnsbl.hostname, dnsbl) for dnsbl in DEFAULT_LISTS)
|