support dnsbl TXT records
This commit is contained in:
parent
b6e8f668c4
commit
6d99a9fae6
2 changed files with 22 additions and 33 deletions
|
@ -43,14 +43,22 @@ class Module(ModuleManager.BaseModule):
|
||||||
failed = []
|
failed = []
|
||||||
for list in lists:
|
for list in lists:
|
||||||
record = self._check_list(list.hostname, address)
|
record = self._check_list(list.hostname, address)
|
||||||
if not record == None:
|
if record is not None:
|
||||||
reason = list.process(record) or "unknown"
|
a_record, txt_record = record
|
||||||
|
reason = list.process(a_record, txt_record) or "unknown"
|
||||||
failed.append((list.hostname, reason))
|
failed.append((list.hostname, reason))
|
||||||
return failed
|
return failed
|
||||||
|
|
||||||
def _check_list(self, list, address):
|
def _check_list(self, list, address):
|
||||||
list_address = "%s.%s" % (address, list)
|
list_address = "%s.%s" % (address, list)
|
||||||
try:
|
try:
|
||||||
return dns.resolver.query(list_address, "A")[0].to_text()
|
a_record = dns.resolver.query(list_address, "A")[0].to_text()
|
||||||
except dns.resolver.NXDOMAIN:
|
except dns.resolver.NXDOMAIN:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
txt_record = dns.resolver.query(list_address, "TXT")[0].to_text()
|
||||||
|
except:
|
||||||
|
txt_record = None
|
||||||
|
|
||||||
|
return (a_record, txt_record)
|
||||||
|
|
|
@ -5,13 +5,16 @@ class DNSBL(object):
|
||||||
if not hostname == None:
|
if not hostname == None:
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
|
|
||||||
def process(self, result: str):
|
def process(self, a_record, txt_record):
|
||||||
return result
|
out = a_record
|
||||||
|
if txt_record is not None:
|
||||||
|
out += f" - {txt_record}"
|
||||||
|
return out
|
||||||
|
|
||||||
class ZenSpamhaus(DNSBL):
|
class ZenSpamhaus(DNSBL):
|
||||||
hostname = "zen.spamhaus.org"
|
hostname = "zen.spamhaus.org"
|
||||||
def process(self, result):
|
def process(self, a_record, txt_record):
|
||||||
result = result.rsplit(".", 1)[1]
|
result = a_record.rsplit(".", 1)[1]
|
||||||
if result in ["2", "3", "9"]:
|
if result in ["2", "3", "9"]:
|
||||||
desc = "spam"
|
desc = "spam"
|
||||||
elif result in ["4", "5", "6", "7"]:
|
elif result in ["4", "5", "6", "7"]:
|
||||||
|
@ -20,8 +23,8 @@ class ZenSpamhaus(DNSBL):
|
||||||
|
|
||||||
class EFNetRBL(DNSBL):
|
class EFNetRBL(DNSBL):
|
||||||
hostname = "rbl.efnetrbl.org"
|
hostname = "rbl.efnetrbl.org"
|
||||||
def process(self, result):
|
def process(self, a_record, txt_record):
|
||||||
result = result.rsplit(".", 1)[1]
|
result = a_record.rsplit(".", 1)[1]
|
||||||
if result == "1":
|
if result == "1":
|
||||||
desc = "proxy"
|
desc = "proxy"
|
||||||
elif result in ["2", "3"]:
|
elif result in ["2", "3"]:
|
||||||
|
@ -32,35 +35,13 @@ class EFNetRBL(DNSBL):
|
||||||
desc = "flooding"
|
desc = "flooding"
|
||||||
return f"{result} - {desc}"
|
return f"{result} - {desc}"
|
||||||
|
|
||||||
DRONEBL_CATEGORIES = {
|
|
||||||
3: "IRC drone",
|
|
||||||
5: "bottler",
|
|
||||||
6: "unknown spambot or drone",
|
|
||||||
7: "DDoS drone",
|
|
||||||
8: "open SOCKS proxy",
|
|
||||||
9: "open HTTP proxy",
|
|
||||||
10: "proxychain",
|
|
||||||
11: "web page proxy",
|
|
||||||
12: "open DNS resolver",
|
|
||||||
13: "brute force attacker",
|
|
||||||
14: "open WINGATE proxy",
|
|
||||||
15: "compromised router/gateway",
|
|
||||||
16: "autorooting malware",
|
|
||||||
17: "detected botnet IP",
|
|
||||||
18: "DNS/MX on IRC",
|
|
||||||
19: "abused VPN service"
|
|
||||||
}
|
|
||||||
class DroneBL(DNSBL):
|
class DroneBL(DNSBL):
|
||||||
hostname = "dnsbl.dronebl.org"
|
hostname = "dnsbl.dronebl.org"
|
||||||
def process(self, result):
|
|
||||||
result = int(result.rsplit(".", 1)[1])
|
|
||||||
desc = DRONEBL_CATEGORIES.get(result, "unknown")
|
|
||||||
return f"{result} - {desc}"
|
|
||||||
|
|
||||||
class AbuseAtCBL(DNSBL):
|
class AbuseAtCBL(DNSBL):
|
||||||
hostname = "cbl.abuseat.org"
|
hostname = "cbl.abuseat.org"
|
||||||
def process(self, result):
|
def process(self, a_record, txt_record):
|
||||||
result = result.rsplit(".", 1)[1]
|
result = a_record.rsplit(".", 1)[1]
|
||||||
if result == "2":
|
if result == "2":
|
||||||
desc = "abuse"
|
desc = "abuse"
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue