Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d39d8c

Browse files
committed
add custom wordlist generator tutorial
1 parent3a8392a commit2d39d8c

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
5050
-[How to Implement the Caesar Cipher in Python](https://thepythoncode.com/article/implement-caesar-cipher-in-python). ([code](ethical-hacking/caesar-cipher))
5151
-[How to Crack the Caesar Cipher in Python](https://thepythoncode.com/article/how-to-crack-caesar-cipher-in-python). ([code](ethical-hacking/caesar-cipher))
5252
-[How to Lock PDFs in Python](https://thepythoncode.com/article/lock-pdfs-in-python).[(code)](ethical-hacking/pdf-locker)
53+
-[How to Create a Custom Wordlist in Python](https://thepythoncode.com/article/make-a-wordlist-generator-in-python). ([code](ethical-hacking/bruteforce-wordlist-generator))
5354

5455
-###[Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
5556
-###[Natural Language Processing](https://www.thepythoncode.com/topic/nlp)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#[How to Create a Custom Wordlist in Python](https://thepythoncode.com/article/make-a-wordlist-generator-in-python)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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}")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp