-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
hash.py
113 lines (96 loc) · 3.51 KB
/
hash.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python3
import hashlib
hash_pass = input("\033[36mEnter the hash to crack:\033[0m ").lower()
passlist = input("\033[36mEnter the dictionary :\033[0m ")
def sha256(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.sha256(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word + "\n")
def md5(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.md5(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word, end = '')
def sha1(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.sha1(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word, end = '')
def sha512(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.sha512(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word, end = '')
def sha384(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.sha384(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word, end = '')
def sha224(passlist):
with open(passlist,'r') as f:
lines = f.readlines()
for word in lines:
enc_wrd = word.encode()
digest = hashlib.sha224(enc_wrd.strip()).hexdigest().lower()
if digest == hash_pass:
print("\033[1;32;40m---------------------------------------------------")
print(" Password Found! --> " + word, end = '')
print("---------------------------------------------------")
break
else:
print("trying : \033[1;31;40m"+ word, end = '')
if len(hash_pass) == 64:
sha256(passlist)
elif len(hash_pass) == 32:
md5(passlist)
elif len(hash_pass) == 128:
sha512(passlist)
elif len(hash_pass) == 40:
sha1(passlist)
elif len(hash_pass) == 96:
sha384(passlist)
elif len(hash_pass) == 56:
sha224(passlist)
else:
print("Hash not found. Check if its included in md5, sha1, sha224, sha256, sha384, sha512.")