Created
August 25, 2021 23:54
-
-
Save subtosilencio/e76c68355a824cf1c26351492faf87b6 to your computer and use it in GitHub Desktop.
Check if domain is listed "dbl.spamhaus.org"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
def checkBlacklist(domain): | |
''' Check if domain is listed "dbl.spamhaus.org" ''' | |
rCode = '' | |
rTXT = {"127.0.1.2": "spam domain", | |
"127.0.1.4": "phish domain", | |
"127.0.1.5": "malware domain", | |
"127.0.1.6": "botnet C&C domain", | |
"127.0.1.102": "abused legit spam", | |
"127.0.1.103": "abused spammed redirector domain", | |
"127.0.1.104": "abused legit phish", | |
"127.0.1.105": "abused legit malware", | |
"127.0.1.106": "abused legit botnet C&C", | |
"127.0.1.255": "IP queries prohibited!", | |
"127.255.255.252": "Any Typing error in DNSBL name", | |
"127.255.255.254": "Any Anonymous query through public resolver", | |
"127.255.255.255": "Any Excessive number of queries"} | |
rblhost = domain + '.dbl.spamhaus.org' | |
rCode = socket.getaddrinfo(rblhost, 43)[0][-1][0] | |
if rCode: | |
return (True, rTXT[rCode]) | |
return (False, rCode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment