Skip to content

Instantly share code, notes, and snippets.

@hoosteeno
Created January 30, 2015 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoosteeno/e6aa6791c0a676950f36 to your computer and use it in GitHub Desktop.
Save hoosteeno/e6aa6791c0a676950f36 to your computer and use it in GitHub Desktop.
Check url for presence on IP blocklists
import socket
import dns.resolver
urls = ["freecreditreportblog.net"]
bls = ["zen.spamhaus.org", "spam.abuse.ch", "cbl.abuseat.org", "virbl.dnsbl.bit.nl", "dnsbl.inps.de",
"ix.dnsbl.manitu.net", "dnsbl.sorbs.net", "bl.spamcannibal.org", "bl.spamcop.net",
"xbl.spamhaus.org", "pbl.spamhaus.org", "dnsbl-1.uceprotect.net", "dnsbl-2.uceprotect.net",
"dnsbl-3.uceprotect.net", "db.wpbl.info"]
for url in urls:
ips = socket.gethostbyname_ex(url)[2]
print ips
for ip in ips:
print 'Working on %s' %(ip)
for bl in bls:
try:
my_resolver = dns.resolver.Resolver()
query = '.'.join(reversed(str(ip).split("."))) + "." + bl
answers = my_resolver.query(query, "A")
answer_txt = my_resolver.query(query, "TXT")
print 'URL: %s IS listed in %s (%s: %s)' %(url, bl, answers[0], answer_txt[0])
except dns.resolver.NXDOMAIN:
print 'URL: %s is NOT listed in %s' %(url, bl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment