Skip to content

Commit 20c643e

Browse files
committed
Fix preauth flow for hash/key auth and remove PA_PAC_REQUEST from probe
Two fixes: - Move step 2 (authenticated AS-REQ) out of the password-only else block into its own if-preAuth-is-True block, fixing enc-part error when using NTLM hash or AES key authentication - Remove PA_PAC_REQUEST from probe AS-REQ to match kinit exactly, fixing extra UDP-to-TCP fallback caused by larger KDC response
1 parent 6a47c41 commit 20c643e

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

impacket/krb5/kerberosv5.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ def getKerberosTGT(clientName, password, domain, lmhash, nthash, aesKey='', kdcH
276276
return tgt, cipher, key, sessionKey
277277

278278
# Step 1: Probe AS-REQ without PA_ENC_TIMESTAMP (matching kinit)
279-
pacRequest = KERB_PA_PAC_REQUEST()
280-
pacRequest['include-pac'] = requestPAC
281-
encodedPacRequest = encoder.encode(pacRequest)
282-
283279
asReq = AS_REQ()
284280
asReq['pvno'] = 5
285281
asReq['msg-type'] = int(constants.ApplicationTagNumbers.AS_REQ.value)
@@ -291,9 +287,6 @@ def getKerberosTGT(clientName, password, domain, lmhash, nthash, aesKey='', kdcH
291287
asReq['padata'][1] = noValue
292288
asReq['padata'][1]['padata-type'] = int(constants.PreAuthenticationDataTypes.PA_REQ_ENC_PA_REP.value)
293289
asReq['padata'][1]['padata-value'] = b''
294-
asReq['padata'][2] = noValue
295-
asReq['padata'][2]['padata-type'] = int(constants.PreAuthenticationDataTypes.PA_PAC_REQUEST.value)
296-
asReq['padata'][2]['padata-value'] = encodedPacRequest
297290

298291
reqBody = seq_set(asReq, 'req-body')
299292

@@ -392,6 +385,7 @@ def getKerberosTGT(clientName, password, domain, lmhash, nthash, aesKey='', kdcH
392385
raise Exception('No Encryption Data Available!')
393386
key = cipher.string_to_key(password, encryptionTypesData[enctype], None)
394387

388+
if preAuth is True:
395389
# Step 2: Authenticated AS-REQ with PA_ENC_TIMESTAMP (matching kinit)
396390
timeStamp = PA_ENC_TS_ENC()
397391
now = datetime.datetime.now(datetime.timezone.utc)

0 commit comments

Comments
 (0)