Skip to content

Commit

Permalink
Merge pull request fortra#9 from wqreytuk/getST
Browse files Browse the repository at this point in the history
ccache-refactor
  • Loading branch information
ShutdownRepo authored May 2, 2022
2 parents f31bc0a + 6ee80f3 commit 90866d4
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions examples/getST.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,23 +659,12 @@ def doS4U(self, tgt, cipher, oldSessionKey, sessionKey, nthash, aesKey, kdcHost)
def run(self):

# Do we have a TGT cached?
tgt = None
try:
ccache = CCache.loadFile(os.getenv('KRB5CCNAME'))
logging.debug("Using Kerberos Cache: %s" % os.getenv('KRB5CCNAME'))
principal = 'krbtgt/%s@%s' % (self.__domain.upper(), self.__domain.upper())
creds = ccache.getCredential(principal)
if creds is not None:
# ToDo: Check this TGT belogns to the right principal
TGT = creds.toTGT()
tgt, cipher, sessionKey = TGT['KDC_REP'], TGT['cipher'], TGT['sessionKey']
oldSessionKey = sessionKey
logging.info('Using TGT from cache')
else:
logging.debug("No valid credentials found in cache. ")
except:
# No cache present
pass
domain, _, TGT, _ = CCache.parseFile(self.__domain)

# ToDo: Check this TGT belogns to the right principal
if TGT is not None:
tgt, cipher, sessionKey = TGT['KDC_REP'], TGT['cipher'], TGT['sessionKey']
oldSessionKey = sessionKey

if tgt is None:
# Still no TGT
Expand Down

0 comments on commit 90866d4

Please sign in to comment.