Skip to content

Commit fde5491

Browse files
committed
Fix parsing STs from S4U2Self
1 parent 9c2d8b6 commit fde5491

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

impacket/krb5/ccache.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ def getCredential(self, server, anySPN=True):
426426
for c in self.credentials:
427427
# Let's search for any TGT/TGS that matches the server w/o the SPN's service type/port, returns
428428
# the first one
429+
# If server has no '/' we assume it's a ST from S4U2Self without a service type
429430
if c['server'].prettyPrint().find(b'/') >=0:
430431
# Let's take the port out for comparison
431432
cachedSPN = (c['server'].prettyPrint().upper().split(b'/')[1].split(b'@')[0].split(b':')[0] + b'@' + c['server'].prettyPrint().upper().split(b'/')[1].split(b'@')[1])
@@ -434,6 +435,13 @@ def getCredential(self, server, anySPN=True):
434435
if cachedSPN == b(searchSPN):
435436
LOG.debug('Returning cached credential for %s' % c['server'].prettyPrint().upper().decode('utf-8'))
436437
return c
438+
else:
439+
# Should be of form 'hostname$@REALM'
440+
cachedSPN = (c['server'].prettyPrint().upper().split(b'@')[0].split(b':')[0] + b'@' + c['server'].prettyPrint().upper().split(b'@')[1])
441+
searchSPN = f"{server.upper().split('/')[1].split('@')[0].split(':')[0].split('.')[0]}$@{server.upper().split('/')[1].split('@')[1]}"
442+
if cachedSPN == b(searchSPN):
443+
LOG.debug('Returning cached credential for %s' % c['server'].prettyPrint().upper().decode('utf-8'))
444+
return c
437445

438446
return None
439447

0 commit comments

Comments
 (0)