Created
December 16, 2013 09:23
-
-
Save athoune/7984375 to your computer and use it in GitHub Desktop.
Rotten domain detector
This file contains hidden or 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
#!/usr/bin/env python | |
import socket | |
import sys | |
import re | |
DOMAIN = re.compile("https?://([a-zA-Z0-9.-_]*\.[\w]{2,})") | |
dejavue = set() | |
for line in sys.stdin: | |
domains = DOMAIN.findall(line) | |
for domain in domains: | |
if domain in dejavue: | |
continue | |
q = "%s.multi.surbl.org" % domain | |
try: | |
host = socket.gethostbyname(q) | |
except socket.gaierror: | |
pass | |
else: | |
dejavue.add(domain) | |
print host, domain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use it threw a pipe: