-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_domains
More file actions
executable file
·72 lines (61 loc) · 2.29 KB
/
Copy pathgenerate_domains
File metadata and controls
executable file
·72 lines (61 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/python3
#------------------------------------------------------------------------------
#
# GENERATE n LETTER/NUMBER DOMAIN NAMES
#
# RICK PFAHL <pfahlr@gmail.com>
# 16 MAY 2024
#
# OPTIONS:
# --length | -n : Length of the domain name
# --include-digits | -d : Include 0-9 if set
# --include-chars | -c : Include '-' if set
# --long | -l : Print each domain on a newline if set
#
#------------------------------------------------------------------------------
import itertools
import string
import sys
import argparse
def generate_domain_permutations(n, include_digits=False, include_chars=False):
# Generate the character set based on the provided flags
lowercase = string.ascii_lowercase
if include_digits:
digits = string.digits
else:
digits = ''
if include_chars:
characters = '-.'
else:
characters = ''
# Generate all possible permutations of domain names of length n
permutations = itertools.product(lowercase+digits+characters, repeat=n)
# Convert tuples to string
domain_names = [''.join(p) for p in permutations]
return domain_names
def main():
# Set up argument parser
parser = argparse.ArgumentParser(description="Generate domain name permutations.")
parser.add_argument('--length', '-n', type=int, default=3, help="Length of the domain name permutations (default: 3)")
parser.add_argument('--include-digits', '-d', action='store_true', help="Include digits in the permutations")
parser.add_argument('--include-chars', '-c', action='store_true', help="Include special characters in the permutations")
parser.add_argument('--long', '-l', action='store_true', help="Print each domain on a newline")
# Parse arguments
args = parser.parse_args()
# Validate the length argument
if args.length < 1 or args.length > 20:
print("The value of --length must be between 1 and 20.")
sys.exit(1)
# Generate domain permutations
domain_names = generate_domain_permutations(args.length, args.include_digits, args.include_chars)
# Print each domain name
counter = 1
output = ''
for domain in domain_names:
if args.long:
output += domain+'\n'
else:
output += domain+' '
print(output)
if __name__ == "__main__":
main()