Skip to content

Instantly share code, notes, and snippets.

@subtosilencio
Created August 25, 2021 23:54
Show Gist options
  • Save subtosilencio/e76c68355a824cf1c26351492faf87b6 to your computer and use it in GitHub Desktop.
Save subtosilencio/e76c68355a824cf1c26351492faf87b6 to your computer and use it in GitHub Desktop.
Check if domain is listed "dbl.spamhaus.org"
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