Skip to content

Commit 8ad8008

Browse files
authored
Create password-cracker.py
1 parent a05a990 commit 8ad8008

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import hashlib
2+
print("**************PASSWORD CRACKER ******************")
3+
4+
# To check if the password
5+
# found or not.
6+
pass_found = 0
7+
8+
input_hash = input("Enter the hashed password:")
9+
10+
pass_doc = input("\nEnter passwords filename including path(root / home/):")
11+
12+
try:
13+
# trying to open the password file.
14+
pass_file = open(pass_doc, 'r')
15+
except:
16+
print("Error:")
17+
print(pass_doc, "is not found.\nPlease give the path of file correctly.")
18+
quit()
19+
20+
21+
# comparing the input_hash with the hashes
22+
# of the words in password file,
23+
# and finding password.
24+
25+
for word in pass_file:
26+
# encoding the word into utf-8 format
27+
enc_word = word.encode('utf-8')
28+
29+
# Hashing a word into md5 hash
30+
hash_word = hashlib.md5(enc_word.strip())
31+
32+
# digesting that hash into a hexa decimal value
33+
digest = hash_word.hexdigest()
34+
35+
if digest == input_hash:
36+
# comparing hashes
37+
print("Password found.\nThe password is:", word)
38+
pass_found = 1
39+
break
40+
41+
# if password is not found.
42+
if not pass_found:
43+
print("Password is not found in the", pass_doc, "file")
44+
print('\n')
45+
print("***************** Thank you **********************")

0 commit comments

Comments
 (0)