-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpcat.py
525 lines (490 loc) · 18.5 KB
/
helpcat.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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
import PySimpleGUI as sg
import random
import pyperclip
from string import (
ascii_lowercase,
ascii_uppercase,
digits,
punctuation)
from lib import (
max_lengths,
min_lengths,
uppercase_letter,
lowercase_letter,
digit_character,
special_character,
flags,
positionals,
attack_types)
from documents import Documents
document_names = list(Documents.keys())
current_password = ""
flag_flags = list(flags.keys())
flag_desc = list(flags.values())
attacks = list(attack_types.values())
attacks_number = list(attack_types.keys())
added_flags = []
attack_type = []
hash_string = "<hash>"
def get_hash_from_file(filename: str) -> str:
""" providing a filepath, will read the hashfile and return the string """
global hash_string
if filename == '':
return
with open(filename, 'r') as rfile:
lines = [x.strip("\n") for x in rfile.readlines()]
if lines[0] != "":
hash_string = lines[0]
def get_attack_from_desc(attack_description:str) -> str or None:
""" given the description of the attack type, will return the number string to use for that attack type """
global attack_type
attack_type = []
for index, a in enumerate(attacks):
if a == attack_description:
return attacks_number[index]
return None
def search_box(search_input:str) -> str or None:
""" fetches the match for the autofill """
search_box = [x for x in document_names if x.startswith(search_input.lower()) or x.startswith(search_input.upper())]
try:
return search_box[0]
except:
return None
def get_flag_From_desc(desc:str) -> str or None:
""" given the description, will match the flag to use for the command str """
for index, flag in enumerate(flag_desc):
if desc == flag:
return flag_flags[index]
return None
def search_flags(search_input:str) -> str or None:
""" searches the flags for a match, this is a helper function for the autofill functionality """
flags_search = [x for x in flag_desc if x.startswith(search_input.lower()) or x.startswith(search_input.upper())]
try:
return flags_search[0]
except:
return None
def make_sequence(string: str) -> str:
""" assembles the sequence for the command string """
sequences = []
sequence = str(string).split(']')
for x in sequence:
if x.startswith("[u"):
sequences.append(random.choice(ascii_uppercase))
if x.startswith("[l"):
sequences.append(random.choice(ascii_lowercase))
if x.startswith("[s"):
sequences.append(random.choice(punctuation))
if x.startswith("[i"):
sequences.append(random.choice(digits))
x = "".join(sequences)
return x
def make_examples(password, minimum_length: int) -> list[str]:
""" makes a list of examples to place in the listbox widget """
passwords_ = []
for x in range(0,minimum_length+1):
p = make_sequence(password)
passwords_.append(p)
return passwords_
def make_command(length, maximum, statusbar_sequence: str, document_type: str) -> str:
""" makes the command status bar string for display """
global hash_string
global attack_type
flagsx = " ".join([x for x in added_flags if x != None])
if attack_type == [] or attack_type[0] == None:
attack = ""
else:
attack = f"-a {attack_type[0]}"
sbs = statusbar_sequence.split("]")
my_sequence = []
m_tag = '-m'
if document_type == '':
m_tag = ''
docu = ''
else:
docu=Documents[document_type]
for x in sbs:
if x.startswith("[u"):
my_sequence.append('?u')
if x.startswith("[l"):
my_sequence.append('?l')
if x.startswith("[s"):
my_sequence.append('?s')
if x.startswith("[i"):
my_sequence.append('?d')
x = "".join(my_sequence)
cmdstr = f"hashcat {attack} -1 ?l?u?d?s -i {flagsx} --increment-min={length} --increment-max={maximum} {m_tag} {docu} {hash_string} {x}"
return cmdstr
def main():
global attack_type
global current_password
global added_flags
global hash_string
sg.SetOptions(margins=(0,0), element_padding=(0,0))
minimum_length = 0
maximum_length = 8
#
##
### LAYOUT
##
#
layout = [
[sg.T("Hashcat Helpcat", font='ubuntu 24', pad=(5,5))], # title
[sg.HorizontalSeparator()],
[sg.T("Search for hash type:"), sg.Input("", key='SEARCH', enable_events=True, pad=(5,5)),
sg.Combo(values=document_names, key='DOC', size=(50,30), enable_events=True)],
[sg.T("Hash"),
sg.StatusBar(
"<hash>",
size=(150, 1),
text_color='green',
background_color='black',
font='ubuntu 8',
key='HASH'),
sg.StatusBar("",
size=(50, 1),
text_color='green',
background_color='black',
font='ubuntu 8',
key="HASHFILE"),
sg.FileBrowse(
"Upload Hashfile",
key='BROWSEHASHFILE')],
[ sg.T("Attack Type ", size=(17,1), pad=(5,5)),
sg.Combo(attacks, enable_events=True, key='ATTACK',pad=(5,5)),
sg.T("Set minimum length:", pad=(5,5)),
sg.Combo( # minimum combo
min_lengths,
default_value=minimum_length,
enable_events=True,
key='MINIMUM_LENGTH',pad=(5,5)),
sg.T("Set maximum length:",pad=(5,5)),
sg.Combo( # maximum combo
max_lengths,
enable_events=True,
default_value=maximum_length,
key="MAXIMUM_LENGTH")
],
[sg.B("Uppercase Letter", # uppercase button
key="ULETTER"),
sg.B('Lowercase Letter', # lowercase button
key='LLETTER'),
sg.B("Digit", key='DIGIT'),
sg.Button("Special Character", # special character button
key='SCHARACTER'),
sg.B('Back Space', key="BACKSPACE"), # backspace button
sg.B("Clear", # clear button
key="CLEAR")],
[sg.HorizontalSeparator()],
[sg.StatusBar(current_password, # description status box
text_color="green",
background_color='black',
font='ubuntu 8',
key='CURRENT_PASSWORD_SET',
size=(200, 1))],
[sg.T("Examples:", font='boldUbuntu 12')],
[sg.Multiline("",
size=(100, 4),
key='EXAMPLES',
background_color='black',
text_color='red',
font='italicubuntu 10')],
[sg.T("Search for flags:"), sg.Input("", key='FLAGS_SEARCH', enable_events=True, pad=(5,5))],
[sg.Button("Add Flag"),
sg.Combo(values=flag_desc, key='FLAGS', size=(50,30), enable_events=True),
sg.Input("", key='HIDDEN POSITIONAL', visible=False)],
[sg.Input(f"",
key="COMMAND",
size=(200,1),
text_color='green',
background_color='black')], # command output
[sg.Button("Copy To Clipboard"), sg.T("Copied to Clipboard!", text_color='Red', background_color='black', visible=False, key='COPIED')],
[sg.Exit()],]
w = sg.Window("hash helper", layout)
#
##
### event loop ####################################
##
#
document_type = ""
while True:
event_key, values = w.read()
w.refresh()
document_type=values['DOC']
print(event_key, values)
if w['BROWSEHASHFILE'] != "" or event_key in ['BROWSEHASHFILE', 'Upload Hashfile']:
w.refresh()
get_hash_from_file(values['BROWSEHASHFILE'])
w['HASH'].update(hash_string)
w.refresh()
if event_key == 'Copy To Clipboard':
w.refresh()
pyperclip.copy(str(values['COMMAND']))
w['COPIED'].update(visible=True)
w.refresh()
else:
w['COPIED'].update(visible=False)
w.refresh()
if event_key == 'ATTACK':
atk_desc = values['ATTACK']
atk = get_attack_from_desc(atk_desc)
attack_type.append(atk)
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
if event_key == 'BROWSEHASHFILE':
w.refresh()
print("event hashfile")
print(w["BROWSEHASHFILE"])
if not w['FLAGS'] == "":
description = values['FLAGS']
flag = get_flag_From_desc(description)
if flag in positionals:
w['HIDDEN POSITIONAL'].update(visible=True)
else:
w['HIDDEN POSITIONAL'].update(visible=False)
w['HIDDEN POSITIONAL'].update("")
if event_key == 'Add Flag':
description = values['FLAGS']
flag = get_flag_From_desc(description)
if not flag in added_flags:
added_flags.append(flag)
if not w['HIDDEN POSITIONAL'] == '':
added_flags.append(values['HIDDEN POSITIONAL'])
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
w.refresh()
if event_key == 'SEARCH':
w['SEARCH'].update(values['SEARCH'])
w.refresh()
search_for = values['SEARCH']
if not search_for == '' or not search_for == None:
search = search_box(search_for)
w['DOC'].update(search)
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
w.refresh()
#
# update document
#
if event_key == 'DOC':
w['DOC'].update(values['DOC'])
w.refresh()
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
#
# FLAG search
#
if event_key == 'FLAGS_SEARCH':
w['FLAGS_SEARCH'].update(values['FLAGS_SEARCH'])
w.refresh()
search_for_flag = values['FLAGS_SEARCH']
if not search_for_flag == '' or not search_for_flag == None:
searchf = search_flags(search_for_flag)
w['FLAGS'].update(searchf)
adding_to_flags = get_flag_From_desc(search_for_flag)
added_flags.append(adding_to_flags)
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
w.refresh()
#
# update flags
#
if event_key == 'FLAGS':
w['FLAGS'].update(values['FLAGS'])
w.refresh()
w['COMMAND'].update(make_command(
length=minimum_length,
maximum=maximum_length,
statusbar_sequence=current_password,
document_type=document_type))
#
# window close or exit
#
if event_key==sg.WINDOW_CLOSED or event_key=='Exit':
w.close()
break
#
# uppercase letter button event
#
if event_key=="ULETTER":
minimum_length+=1
if minimum_length>maximum_length:
maximum_length = minimum_length
w['MINIMUM_LENGTH'].update(minimum_length)
w['MAXIMUM_LENGTH'].update(maximum_length)
xcurrent_password = current_password + uppercase_letter
current_password=xcurrent_password
w["CURRENT_PASSWORD_SET"].update(str(current_password))
w["COMMAND"].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type))
w.refresh()
w["EXAMPLES"].update("")
for x in make_examples(xcurrent_password, minimum_length):
w["EXAMPLES"].print(x)
w.refresh()
#
# lowercase letter button event
#
if event_key=="LLETTER":
minimum_length+=1
if minimum_length>maximum_length:
maximum_length = minimum_length
w['MINIMUM_LENGTH'].update(minimum_length)
w['MAXIMUM_LENGTH'].update(maximum_length)
xcurrent_password = current_password + lowercase_letter
current_password=xcurrent_password
w["CURRENT_PASSWORD_SET"].update(str(current_password))
w["COMMAND"].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type)
)
w.refresh()
w["EXAMPLES"].update("")
for x in make_examples(xcurrent_password, minimum_length):
w["EXAMPLES"].print(x)
w.refresh()
#
# special character button event
#
if event_key=="SCHARACTER":
minimum_length+=1
if minimum_length>maximum_length:
maximum_length = minimum_length
w['MINIMUM_LENGTH'].update(minimum_length)
w['MAXIMUM_LENGTH'].update(maximum_length)
xcurrent_password = current_password + special_character
current_password=xcurrent_password
w["CURRENT_PASSWORD_SET"].update(str(xcurrent_password))
w["COMMAND"].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type)
)
w.refresh()
w["EXAMPLES"].update("")
for x in make_examples(current_password, minimum_length):
w["EXAMPLES"].print(x)
w.refresh()
#
# digit button event
#
if event_key=="DIGIT":
minimum_length+=1
if minimum_length>maximum_length:
maximum_length = minimum_length
w['MINIMUM_LENGTH'].update(minimum_length)
w['MAXIMUM_LENGTH'].update(maximum_length)
xcurrent_password = current_password + digit_character
current_password=xcurrent_password
w["CURRENT_PASSWORD_SET"].update(str(current_password))
w["COMMAND"].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type)
)
w.refresh()
w["EXAMPLES"].update("")
for x in make_examples(current_password, minimum_length):
w["EXAMPLES"].print(x)
w.refresh()
#
# minimum combo box event
#
if event_key=="MINIMUM_LENGTH":
w['MAXIMUM_LENGTH'].update(maximum_length)
w['MINIMUM_LENGTH'].update(minimum_length)
minimum_length = values["MINIMUM_LENGTH"]
w['MINIMUM_LENGTH'].update(minimum_length)
if round(minimum_length) > round(maximum_length):
w['MAXIMUM_LENGTH'].update(minimum_length)
maximum_length = minimum_length
w.refresh()
w['COMMAND'].update(make_command(minimum_length,
maximum_length,
current_password, document_type=document_type)
)
w.refresh()
#
# maximum combo box event
#
if event_key=="MAXIMUM_LENGTH":
maximum_length = values["MAXIMUM_LENGTH"]
w['MAXIMUM_LENGTH'].update(maximum_length)
w.refresh()
if minimum_length > maximum_length:
w['MAXIMUM_LENGTH'].update(minimum_length)
maximum_length = minimum_length
w.refresh()
w['COMMAND'].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type))
w.refresh()
if event_key=="CURRENT_PASSWORD_SET":
pass
if event_key=="DOCUMENT_TYPE":
pass
#
# clear button event
#
if event_key=="CLEAR":
minimum_length=0
maximum_length=8
added_flags = []
w['MINIMUM_LENGTH'].update(minimum_length)
w['MAXIMUM_LENGTH'].update(maximum_length)
w["EXAMPLES"].update("")
w['CURRENT_PASSWORD_SET'].update("")
w['COMMAND'].update(make_command(minimum_length,
maximum_length,
current_password,
document_type=document_type))
w.refresh()
current_password = ""
#
# backspace combo event
#
if event_key == 'BACKSPACE':
minimum_length = minimum_length-1
w['MINIMUM_LENGTH'].update(minimum_length)
w.refresh()
if minimum_length < 0:
minimum_length = 0
for x in digit_character:
current_password = current_password[:-1]
w["CURRENT_PASSWORD_SET"].update(current_password)
if round(minimum_length) > round(maximum_length):
w['MAXIMUM_LENGTH'].update(minimum_length)
w.refresh()
maximum_length = maximum_length
if digit_character != 1:
for x in make_examples(current_password, minimum_length):
w["EXAMPLES"].print(x)
w.refresh()
else:
w['EXAMPLES'] = ""
w.refresh()
w.refresh()
if round(minimum_length) > round(maximum_length):
w['MAXIMUM_LENGTH'].update(minimum_length)
maximum_length = minimum_length
w.refresh()
w['MINIMUM_LENGTH'].update(minimum_length)
main()