-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckDomains.py
executable file
·31 lines (24 loc) · 1.12 KB
/
checkDomains.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import argparse, dns.resolver
from time import sleep
parser = argparse.ArgumentParser(description='Given a list of domains, figure out which are valid and which are not')
parser.add_argument('--filename', type=str, help='File with domains, separated by line', required=True)
parser.add_argument('--interval', type=int, help='How long to sleep between DNS requests (in ms)', default=100, required=False)
args, unknownArgs = parser.parse_known_args()
print('Reading domains from file %s' % args.filename)
with open(args.filename, encoding='utf-8') as domainListFile:
lines = domainListFile.readlines()
print('Found %d domains to check' % len(lines))
for line in lines:
domain = line.strip()
try:
sleep(args.interval / 1000)
result = dns.resolver.query(domain, 'MX')
print('%s, Accept' % domain)
except dns.resolver.NoAnswer:
print('%s, Reject' % domain)
except dns.resolver.NoNameservers:
print('%s, Reject' % domain)
except Exception:
print('%s, Reject' % domain)
print('Processing complete')