-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrack.py
32 lines (26 loc) · 1.08 KB
/
crack.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
import hashlib
import concurrent.futures
def hash_password(password, num_hashes):
print(password, end=":")
for i in range(num_hashes):
password = hashlib.md5(password.encode('utf-8')).hexdigest()
print(password)
return password
def dictionary_attack(dictionary, hashed_password, num_hashes):
with open(dictionary, 'r', errors='ignore') as f:
for word in f:
word = word.strip()
if hash_password(word, num_hashes) == hashed_password:
return word
return None
if __name__ == '__main__':
dictionary = input('Enter the path to the dictionary file: ')
hashed_password = input('Enter the hashed password to crack: ')
num_hashes = int(input('Enter the number of times the password was hashed: '))
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(dictionary_attack, dictionary, hashed_password, num_hashes)
result = future.result()
if result is not None:
print(f'The password is: {result}')
else:
print('Password not found in dictionary')