Skip to content

Instantly share code, notes, and snippets.

@incogbyte
Created June 7, 2023 12:24
Show Gist options
  • Save incogbyte/713a0ee7931b09694be02400929f875e to your computer and use it in GitHub Desktop.
Save incogbyte/713a0ee7931b09694be02400929f875e to your computer and use it in GitHub Desktop.
extract words from subdomains to make a wordlist
import re
import sys
def extract_subdomains(filename):
subdomains = set()
pattern = r"(?:https?://)?(?:www\.)?([^.]+\.[^.]+)"
with open(filename, 'r') as file:
for line in file:
match = re.search(pattern, line)
if match:
domain = match.group(1)
subdomain = domain.split('.')[0]
subdomains.add(subdomain)
return subdomains
filename = sys.argv[1] # first argument is the filename with domains
result = extract_subdomains(filename)
for line in result:
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment