Skip to content

Instantly share code, notes, and snippets.

@csabatini
Last active June 8, 2016 00:13
Show Gist options
  • Save csabatini/ef84edaa7b8f041c80b17991cc45d10d to your computer and use it in GitHub Desktop.
Save csabatini/ef84edaa7b8f041c80b17991cc45d10d to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import subprocess, re
import sys
from collections import Counter
urls = []
with open('hosts.txt', 'r') as f:
for line in f:
urls.append('%s.blob.core.windows.net' % line.strip())
cnames = []
for url in urls:
process = subprocess.Popen(["nslookup", url], stdout=subprocess.PIPE)
out = process.communicate()[0].split('\n')
for row in out:
if 'Name' in row:
fqdn = re.sub('\s+(?!$)','',row.replace('Name:',''))
print url + ' : ' + fqdn
cnames.append(fqdn)
c = Counter(cnames)
print '\nNon-unique Storage Stamps\n==========='
for k, v in c.iteritems():
if (v > 1):
print k + ' was found %s times' % v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment