Skip to content

Instantly share code, notes, and snippets.

@atucom
Created March 19, 2018 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atucom/1a3b5850c8a63ab74f3d72d8861d80c8 to your computer and use it in GitHub Desktop.
Save atucom/1a3b5850c8a63ab74f3d72d8861d80c8 to your computer and use it in GitHub Desktop.
Chop off subdomains from an FQDN
#!/usr/bin/env python3
#pip3 install tldextract
#Hostnames listed one/line in supplied file
#@atucom
with open('ips.txt.ssl_and_dns.hostnames') as f:
hostnames = f.readlines()
for hostname in hostanmes:
domain = tldextract.extract(hostname)
print(domain.registered_domain)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment