Created
January 30, 2015 12:47
-
-
Save hoosteeno/e6aa6791c0a676950f36 to your computer and use it in GitHub Desktop.
Check url for presence on IP blocklists
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 | |
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