Changeset 156
- Timestamp:
- 02/03/10 20:28:58 (5 months ago)
- Files:
-
- 1 modified
-
trunk/misc/dns-o-matic.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/misc/dns-o-matic.py
r129 r156 6 6 # $ ./dns-o-matic.py > report.html 7 7 # 8 # This script requires the python DNS module available from http://pydns.sourceforge.net/ which is8 # This script requires the python DNS and netaddr modules, which are 9 9 # probably already available in your favourite Linux distribution. 10 10 # From Ubuntu: 11 # $ apt-get install python-dns 11 # $ apt-get install python-dns python-netaddr 12 12 # From Fedora: 13 # $ yum install python-pydns 13 # $ yum install python-pydns python-netaddr 14 14 15 15 16 16 import sys 17 17 import DNS 18 from netaddr import IPNetwork, IPAddress 19 18 20 DNS.DiscoverNameServers() 19 21 … … 56 58 # reverse lookup request gives you all the hostnames that the given ip address resolves to 57 59 if type == 'PTR': 58 a,b,c,d = record.split('.')59 r = Request( '.'.join([d,c,b,a]) + '.in-addr.arpa',type,nameserver)60 rec = IPAddress(record) 61 r = Request(rec.reverse_dns,type,nameserver) 60 62 61 63 # forward lookup request gives you all the ip addresses that the given hostname resolves to … … 136 138 137 139 # iterate through all valid addresses in the subnet 138 for count in range(1,255): 139 #for count in range(28,29): 140 ip = subnet + "." + `count` 140 for ip in [x for x in list(subnet) if x != subnet.broadcast and x != subnet.ip]: 141 141 sys.stderr.write("Processing %s\n" % ip); 142 address = {'ip': ip, 'results':[]}142 address = {'ip':str(ip), 'results':[]} 143 143 for ns,pri in nameservers: 144 RecursiveLookup(address, ip,'PTR',ns)144 RecursiveLookup(address,str(ip),'PTR',ns) 145 145 146 146 # forget about addresses that don't have records in *any* nameservers … … 208 208 <html> 209 209 <head> 210 <title>DNS-o- matic Report</title>210 <title>DNS-o-Matic Report</title> 211 211 <style> 212 212 th { … … 239 239 </head> 240 240 <body> 241 <h1>DNS-o- matic Report</h1>241 <h1>DNS-o-Matic Report</h1> 242 242 """ 243 243 244 244 domain = 'cse-servelec.com' 245 subnets = [IPNetwork('194.62.153.0/24'), 246 IPNetwork('194.62.154.0/24'), 247 ] 248 245 249 nslist = GetNameServers(domain) 246 250 PrintNameServers(domain,nslist) 247 PrintSubnetAnalysis(GetSubnetAnalysis(nslist, '194.62.153')) 248 #PrintSubnetAnalysis(GetSubnetAnalysis(nslist, '194.62.154')) 251 for subnet in subnets: 252 analysis = GetSubnetAnalysis(nslist, subnet) 253 PrintSubnetAnalysis(analysis) 249 254 250 255 print """