forked from Ikken9/juice_shop_password_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (51 loc) · 2.62 KB
/
main.py
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
import random
import string
import concurrent.futures
def generate_password(words, symbols):
while True:
# Select a random word
word = random.choice(words)
# Ensure each password includes the necessary character types
components = [
word,
random.choice(string.ascii_lowercase),
random.choice(string.ascii_uppercase),
random.choice(string.digits),
random.choice(symbols)
]
# Add additional random characters to meet the minimum length requirement
while len(components) < 12:
components.append(random.choice(string.ascii_letters + string.digits + symbols))
# Shuffle all parts
random.shuffle(components)
# Ensure the password is within the maximum length
password = ''.join(components)
if 12 <= len(password) <= 30:
# Generate the capitalized and non-capitalized versions
capitalized_word = word.capitalize()
non_capitalized_word = word.lower()
# Replace word with both versions
password_with_capitalized_word = password.replace(word, capitalized_word, 1)
password_without_word = password.replace(word, non_capitalized_word, 1)
# Return both versions as a tuple
return password_with_capitalized_word, password_without_word
def generate_and_save_passwords(words, symbols, num_passwords, file_path):
with open(file_path, "w") as file:
with concurrent.futures.ProcessPoolExecutor() as executor:
futures = [executor.submit(generate_password, words, symbols) for _ in range(num_passwords)]
for future in concurrent.futures.as_completed(futures):
password_with_cap, password_without = future.result()
file.write(f"{password_with_cap}\n")
file.write(f"{password_without}\n")
def main():
# The sentence in the secret message was: "The support team password does not comply with the corporate policy for privileged accounts!"
# After removing the articles, auxiliary verbs, prepositions and adverbs from the sentence, left the following words:
words = ["support", "team", "password", "comply", "corporate", "policy", "privileged", "accounts"]
symbols = "@$!%*?&"
# For testing purposes, I will only generate 1 million passwords
num_passwords = 2200000
file_path = "dictionary.txt"
generate_and_save_passwords(words, symbols, num_passwords, file_path)
print("Passwords generated and saved to 'dictionary.txt'")
if __name__ == "__main__":
main()