-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary_attack.py
More file actions
27 lines (20 loc) · 828 Bytes
/
dictionary_attack.py
File metadata and controls
27 lines (20 loc) · 828 Bytes
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
def dictionary_attack(target_password, dictionary_file):
try:
with open(dictionary_file, "r", encoding="utf-8", errors="ignore") as file:
for line in file:
guess = line.strip()
print(f"Trying password: {guess}")
if guess == target_password:
print(f"Password found: {guess}")
return True
print("Password not found in the dictionary.")
return False
except FileNotFoundError:
print(f"Dictionary file '{dictionary_file}' not found.")
return False
# Target password to crack
target_password = input("Enter the password to crack: ")
# Path to the dictionary file
dictionary_file = "passwords.txt"
# Start the dictionary attack
dictionary_attack(target_password, dictionary_file)