-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNSGenerator.py
More file actions
39 lines (33 loc) · 1.02 KB
/
DNSGenerator.py
File metadata and controls
39 lines (33 loc) · 1.02 KB
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
32
33
34
35
36
37
38
39
#
# Tool for creating DNS traffic to test Safe Networking
__author__ = 'Kevin Walsh'
import socket
# Some counters
counter = 0
good_domains = 0
bad_domains = 0
sinkhole_domains = 0
Sinkhole_addr = '72.5.65.111'
file = 'AV_2547.txt'
# Input file. This code reads domain names from a .txt file and will
# attempt to resolve the IP Addr of the domain
with open(file, 'r') as f:
# Procssing of the file
for line in f:
counter += 1
try:
addr1 = line.strip()
addr2 = socket.gethostbyname(addr1)
print('{}: {}: {}'.format(counter, addr1, addr2))
if (addr2 == Sinkhole_addr):
sinkhole_domains += 1
good_domains += 1
except socket.gaierror:
print('{}: Cannot resolve hostname {}'.format(counter, line))
bad_domains += 1
# Wrap up
print('Finished!')
print('Total Domains tried:', counter)
print('Domains resolved:', good_domains)
print('Blocked domains:', bad_domains)
print('Sinkhole domains: ', sinkhole_domains)