-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathhashmash.py
More file actions
299 lines (258 loc) · 7.2 KB
/
Copy pathhashmash.py
File metadata and controls
299 lines (258 loc) · 7.2 KB
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/usr/bin/python
import itertools
import sys
import hashlib
import getopt
from datetime import timedelta, datetime
infile=""
delim=1
alldels = ["",":"," ","&",",",".","-","_","|",";"]
hashtype=1
intimes=""
intimef=""
match=""
stype="s"
def usage():
print '''
/$$ /$$ /$$ /$$
| $$ | $$ | $$ | $$
| $$ | $$ /$$$$$$ /$$$$$$$| $$$$$$$ /$$$$$$/$$$$ /$$$$$$ /$$$$$$$| $$$$$$$
| $$$$$$$$ |____ $$ /$$_____/| $$__ $$| $$_ $$_ $$ |____ $$ /$$_____/| $$__ $$
| $$__ $$ /$$$$$$$| $$$$$$ | $$ \ $$| $$ \ $$ \ $$ /$$$$$$$| $$$$$$ | $$ \ $$
| $$ | $$ /$$__ $$ \____ $$| $$ | $$| $$ | $$ | $$ /$$__ $$ \____ $$| $$ | $$
| $$ | $$| $$$$$$$ /$$$$$$$/| $$ | $$| $$ | $$ | $$| $$$$$$$ /$$$$$$$/| $$ | $$
|__/ |__/ \_______/|_______/ |__/ |__/|__/ |__/ |__/ \_______/|_______/ |__/ |__/
version 0.2
-h You're here
--alg Hashing algorithm to use
1 MD5 (default)
2 SHA1
3 SHA224
4 SHA256
5 SHA384
6 SHA512
--delim Include a delimiter between values
1 None (default)
2 Colon
3 Space
4 Ampersand
5 Comma
6 Period
7 Hyphen
8 Underscore
9 Pipe
10 Semi-colon
11 All of the above (slow)
--match Specify a hash to match i.e. --match e23e4ae268f4ba432e74e625e6600e59
--file File containing values (one per line)
Example:
name
surname
email@rebootuser.com
phone_number
Generate Epochs (unix timestamps) between specified dates/times.
Each timestamp will be tested with defined values from --file
--st Define a start time [used with --et]
--et Define an end time [used with --st]
--sec Seconds since Epoch (default)
--milli Milliseconds since Epoch
Example ("year-mon-day hour-min-second"):
--st "2016-01-01 09:23:01" --et "2016-01-01 09:25:01" --milli
'''
def md5hash(suppliedhash):
hashed=hashlib.md5(suppliedhash).hexdigest()
return hashed
def sha1hash(suppliedhash):
hashed=hashlib.sha1(suppliedhash).hexdigest()
return hashed
def sha224hash(suppliedhash):
hashed=hashlib.sha224(suppliedhash).hexdigest()
return hashed
def sha256hash(suppliedhash):
hashed=hashlib.sha256(suppliedhash).hexdigest()
return hashed
def sha384hash(suppliedhash):
hashed=hashlib.sha384(suppliedhash).hexdigest()
return hashed
def sha512hash(suppliedhash):
hashed=hashlib.sha512(suppliedhash).hexdigest()
return hashed
def epochcalc():
epoch = datetime(1970,1,1)
start_time = datetime.strptime(intimes, '%Y-%m-%d %H:%M:%S')
end_time = datetime.strptime(intimef, '%Y-%m-%d %H:%M:%S')
if stype == "s":
timeint = timedelta(seconds=1)
else:
timeint = timedelta(milliseconds=1)
global testtimes
global epochtimes
testtimes = []
epochtimes = []
while start_time <= end_time:
testtimes.append(start_time.strftime('%H:%M:%S'))
if stype == "s":
epochtimes.append(str("{0:.0f}".format((start_time - epoch).total_seconds())))
else:
epochtimes.append(str("{0:.0f}".format((start_time - epoch).total_seconds()*1000)))
start_time += timeint
def itterate():
for val in range(1, len(combos)+1):
for subval in itertools.permutations(combos, val):
if delim == 1:
subvaljoin="".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 2:
subvaljoin=":".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 3:
subvaljoin=" ".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 4:
subvaljoin="&".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 5:
subvaljoin=",".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 6:
subvaljoin=".".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 7:
subvaljoin="-".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 8:
subvaljoin="_".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 9:
subvaljoin="|".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 10:
subvaljoin=";".join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
elif delim == 11:
for dels in alldels:
subvaljoin=dels.join(subval)
print "Cleartext Value: " + subvaljoin
hashtest(subvaljoin)
else:
sys.exit()
def hashtest(subvaljoin):
if hashtype == 1:
hashed = md5hash(subvaljoin)
print hashed
elif hashtype == 2:
hashed = sha1hash(subvaljoin)
print hashed
elif hashtype == 3:
hashed = sha224hash(subvaljoin)
print hashed
elif hashtype == 4:
hashed = sha256hash(subvaljoin)
print hashed
elif hashtype == 5:
hashed = sha384hash(subvaljoin)
print hashed
elif hashtype == 6:
hashed = sha512hash(subvaljoin)
print hashed
else:
sys.exit()
if match == hashed:
print ("\n[+] Gotya! \n%s\n")%subvaljoin
sys.exit()
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h",["match=","alg=","delim=","file=","st=","et=","sec","milli"])
if len(sys.argv) < 2:
usage()
sys.exit()
except getopt.GetoptError:
usage()
sys.exit()
try:
for opt, arg in opts:
if opt == "-h":
usage()
print "[+] Looks like you need some help here!"
sys.exit()
elif opt == "--match":
global match
match = str(arg)
elif opt == "--st":
global intimes
intimes = str(arg)
elif opt == "--et":
global intimef
intimef = str(arg)
elif opt == "--sec":
global stype
stype = 's'
elif opt == '--milli':
stype = 'm'
elif opt == "--file":
global infile
infile = str(arg)
try:
open(infile)
except IOError:
print "[+] Error opening the file %s - does this exist?" %infile
return
elif opt == "--alg":
global hashtype
hashtype = int(arg)
if 1 <= hashtype <= 6:
pass
else:
usage()
print "[+] Hash algorithm not defined!"
sys.exit()
elif opt == "--delim":
global delim
delim = int(arg)
if 1 <= delim <= 11:
pass
else:
usage()
print "[+] Delimeter not defined!"
sys.exit()
else:
print "[+] errrr something went wrong bob!"
sys.exit()
except SystemExit:
sys.exit()
if not infile:
usage()
print "[+] You need to specify an input file containing your variables (--file)"
sys.exit()
if not match:
usage()
print "[+] Where's the hash I need to --match?"
sys.exit()
else:
pass
with open(infile) as inputvals:
global combos
combos = inputvals.read().splitlines()
if intimes:
if intimef:
epochcalc()
for t in epochtimes:
combos.insert(0,t)
itterate()
combos.remove(t)
else:
print "[+] Finish time not defined!"
else:
itterate()
if __name__ == "__main__":
main()