-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashcrack.py
257 lines (214 loc) · 7.74 KB
/
hashcrack.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
from banner.banner import *
import argparse
import hashlib
from beautifultable import BeautifulTable
import time
parse = argparse.ArgumentParser()
########## List of supported hashes
parse.add_argument("--hashes",help="Hashes supported",action='store_true')
########## hash --> MD5
parse.add_argument("--md5",help="MD5 hash")
########## hash --> SHA-1
parse.add_argument("--sha1",help="SHA-1 hash")
########## hash --> SHA-224
parse.add_argument("--sha224",help="SHA-224 hash")
########## hash --> SHA-256
parse.add_argument("--sha256",help="SHA-256 hash")
########## hash --> SHA-384
parse.add_argument("--sha384",help="SHA-384 hash")
########## hash --> SHA-512
parse.add_argument("--sha512",help="SHA-512 hash")
########## hash --> SHA3-224
parse.add_argument("--sha3_224","--sha3-224",help="SHA3-224 hash")
########## hash --> SHA3-256
parse.add_argument("--sha3_256","--sha3-256",help="SHA3-256 hash")
########## hash --> SHA3-384
parse.add_argument("--sha3_384","--sha3-384",help="SHA3-384 hash")
########## hash --> SHA3-512
parse.add_argument("--sha3_512","--sha3-512",help="SHA3-512 hash")
########## Wordlist
parse.add_argument("-w","--wordlist",help="Wordlist")
########## Output
parse.add_argument("-o", "--output",default="stdout",required=False, dest='output', help="Directs the output to a name of your choice")
parse = parse.parse_args()
def hashesSupported():
table = BeautifulTable()
table.columns.header = [f"{RED_NORMAL}HASH{END}", f"{GREEN_NORMAL}COMMAND{END}"]
table.rows.append(["MD5", "--md5"])
table.rows.append(["SHA-1", "--sha1"])
table.rows.append(["SHA-224", "--sha224"])
table.rows.append(["SHA-256", "--sha256"])
table.rows.append(["SHA-384", "--sha384"])
table.rows.append(["SHA-512", "--sha512"])
table.rows.append(["SHA3-224", "--sha3-224"])
table.rows.append(["SHA3-256", "--sha3-256"])
table.rows.append(["SHA3-384", "--sha3-384"])
table.rows.append(["SHA3-512", "--sha3-512"])
print(table)
try:
pass_file = open(parse.wordlist,"r")
except:
pass
f = open(parse.output, "a", encoding='utf-8')
def crackMD5():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.md5(enc.strip()).hexdigest()
if parse.md5 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["MD5", hashe, password])
print(table)
f.write("HASH: MD5\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA1():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha1(enc.strip()).hexdigest()
if parse.sha1 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA-1", hashe, password])
print(table)
f.write("HASH: SHA-1\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA224():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha224(enc.strip()).hexdigest()
if parse.sha224 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA-224", hashe, password])
print(table)
f.write("HASH: SHA-224\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA256():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha256(enc.strip()).hexdigest()
if parse.sha256 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA-256", hashe, password])
print(table)
f.write("HASH: SHA-256\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA384():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha384(enc.strip()).hexdigest()
if parse.sha384 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA-384", hashe, password])
print(table)
f.write("HASH: SHA-384\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA512():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha512(enc.strip()).hexdigest()
if parse.sha512 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA-512", hashe, password])
print(table)
f.write("HASH: SHA-512\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA3_224():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha3_224(enc.strip()).hexdigest()
if parse.sha3_224 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA3-224", hashe, password])
print(table)
f.write("HASH: SHA3-224\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA3_256():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha3_256(enc.strip()).hexdigest()
if parse.sha3_256 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA3-256", hashe, password])
print(table)
f.write("HASH: SHA3-256\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA3_384():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha3_384(enc.strip()).hexdigest()
if parse.sha3_384 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA3-384", hashe, password])
print(table)
f.write("HASH: SHA3-384\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def crackSHA3_512():
for password in pass_file:
password = password.replace("\n","")
enc = password.encode('utf-8')
hashe = hashlib.sha3_512(enc.strip()).hexdigest()
if parse.sha3_512 == hashe:
table = BeautifulTable()
table.columns.header = [f"{WHITE}HASH{END}", f"{RED_NORMAL}ENCRYPTED{END}", f"{GREEN_NORMAL}DECRYPTED{END}"]
table.rows.append(["SHA3-384", hashe, password])
print(table)
f.write("HASH: SHA3-512\nENCRYPTED: {}\nDECRYPTED: {}".format(hashe,password)+'\n'+'\n')
f.close()
break
def main():
if parse.hashes:
hashesSupported()
elif parse.md5:
crackMD5()
elif parse.sha1:
crackSHA1()
elif parse.sha224:
crackSHA224()
elif parse.sha256:
crackSHA256()
elif parse.sha384:
crackSHA384()
elif parse.sha512:
crackSHA512()
elif parse.sha3_224:
crackSHA3_224()
elif parse.sha3_256:
crackSHA3_256()
elif parse.sha3_384:
crackSHA3_384()
elif parse.sha3_512:
crackSHA3_512()
else:
print(f"{RED_NORMAL}[ERR0R]{END} Argument invalid\nRequest help : python3 hashcrack.py --help\nExit the script...")
time.sleep(2)
exit(0)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit()