Skip to content

Instantly share code, notes, and snippets.

@athoune
Created December 16, 2013 09:23
Show Gist options
  • Save athoune/7984375 to your computer and use it in GitHub Desktop.
Save athoune/7984375 to your computer and use it in GitHub Desktop.
Rotten domain detector
#!/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
@athoune
Copy link
Author

athoune commented Dec 16, 2013

Use it threw a pipe:

cat test.txt | ./rotten.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment