Created
June 7, 2023 12:24
-
-
Save incogbyte/713a0ee7931b09694be02400929f875e to your computer and use it in GitHub Desktop.
extract words from subdomains to make a wordlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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