|
| 1 | +# Import the argparse module for handling command line arguments. |
| 2 | +# Import the itertools module for generating combinations. |
| 3 | +importargparse,itertools |
| 4 | + |
| 5 | + |
| 6 | +# Define a function to generate a wordlist based on given parameters. |
| 7 | +defgenerate_wordlist(characters,min_length,max_length,output_file): |
| 8 | +# Open the output file in write mode. |
| 9 | +withopen(output_file,'w')asfile: |
| 10 | +# Iterate over the range of word lengths from min_length to max_length. |
| 11 | +forlengthinrange(min_length,max_length+1): |
| 12 | +# Generate all possible combinations of characters with the given length. |
| 13 | +forcombinationinitertools.product(characters,repeat=length): |
| 14 | +# Join the characters to form a word and write it to the file |
| 15 | +word=''.join(combination) |
| 16 | +file.write(word+'\n') |
| 17 | + |
| 18 | + |
| 19 | +# Create an ArgumentParser object for handling command line arguments. |
| 20 | +parser=argparse.ArgumentParser(description="Generate a custom wordlist similar to crunch.") |
| 21 | + |
| 22 | +# Define command line arguments. |
| 23 | +parser.add_argument("-c","--characters",type=str,default="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", |
| 24 | +help="Set of characters to include in the wordlist") |
| 25 | +parser.add_argument("-min","--min_length",type=int,default=4,help="Minimum length of the words") |
| 26 | +parser.add_argument("-max","--max_length",type=int,default=6,help="Maximum length of the words") |
| 27 | +parser.add_argument("-o","--output_file",type=str,default="custom_wordlist.txt",help="Output file name") |
| 28 | + |
| 29 | +# Parse the command line arguments. |
| 30 | +args=parser.parse_args() |
| 31 | + |
| 32 | +# Call the generate_wordlist function with the provided arguments. |
| 33 | +generate_wordlist(args.characters,args.min_length,args.max_length,args.output_file) |
| 34 | + |
| 35 | +# Print a message indicating the wordlist has been generated and saved. |
| 36 | +print(f"[+] Wordlist generated and saved to{args.output_file}") |