Overview
Theimpacket.krb5.asn1 module implements all ASN.1 (Abstract Syntax Notation One) structures defined in RFC 4120 and Microsoft extensions from [MS-KILE]. These structures represent Kerberos protocol messages, tickets, and data types encoded using Distinguished Encoding Rules (DER).
Module Location
impacket/krb5/asn1.py
Basic Data Types
Primitive Types
Int32
32-bit signed integer used throughout Kerberos messages.UInt32
32-bit unsigned integer for nonces and sequence numbers.Microseconds
Microsecond values for timestamps.KerberosString
UTF-8 encoded general string.Realm
Kerberos realm name (domain).KerberosTime
Generalized time format: YYYYMMDDHHMMSSzKerberosFlags
Bit string for flags (32 bits minimum).Principal Names
PrincipalName
Represents a Kerberos principal identity.name-type: Principal type (NT_PRINCIPAL, NT_SRV_INST, etc.)name-string: Sequence of name components
NT_PRINCIPAL = 1: User principal (user@REALM)NT_SRV_INST = 2: Service with instance (krbtgt/REALM)NT_SRV_HST = 3: Service with host (host/server.domain)NT_ENTERPRISE = 10: UPN format
Encryption Structures
EncryptionKey
Cryptographic key with type identifier.keytype: Encryption algorithm identifierkeyvalue: Raw key bytes
1: DES-CBC-CRC3: DES-CBC-MD516: DES3-CBC-SHA117: AES128-CTS-HMAC-SHA1-9618: AES256-CTS-HMAC-SHA1-9623: RC4-HMAC
EncryptedData
Encrypted data with algorithm and optional version.etype: Encryption typekvno: Key version number (optional)cipher: Encrypted ciphertext
Checksum
Integrity checksum for messages.cksumtype: Checksum algorithmchecksum: Checksum value
12: HMAC-SHA1-DES315: HMAC-SHA1-96-AES12816: HMAC-SHA1-96-AES256-138: HMAC-MD5 (0xffffff76)
Ticket Structures
Ticket
Kerberos ticket for service access.tkt-vno: Ticket version (always 5)realm: Service realmsname: Service principal nameenc-part: Encrypted ticket contents
EncTicketPart
Decrypted ticket contents (encrypted in ticket).flags: Ticket flags (forwardable, renewable, etc.)key: Session key for client-service communicationcrealm: Client realmcname: Client principal nameauthtime: Initial authentication timestarttime: Ticket valid start timeendtime: Ticket expiration timerenew-till: Renewable until timeauthorization-data: MS-PAC and other authz data
TicketFlags
Bit flags controlling ticket behavior.- Bit 1:
forwardable- Can be forwarded to another service - Bit 2:
forwarded- Ticket was forwarded - Bit 3:
proxiable- Can be used to obtain proxy - Bit 8:
renewable- Can be renewed - Bit 9:
initial- Initial authentication - Bit 10:
pre-authent- Pre-authentication used
Request Structures
AS-REQ (Authentication Service Request)
Initial authentication request for TGT.pvno: Protocol version (5)msg-type: Message type (10 for AS-REQ)padata: Pre-authentication datareq-body: Request body
KDC_REQ_BODY
Request body for AS-REQ and TGS-REQ.kdc-options: Request options (forwardable, renewable, etc.)cname: Client name (AS-REQ only)realm: Target realmsname: Service nametill: Requested expiration timenonce: Random nonce for replay protectionetype: Acceptable encryption types
TGS-REQ (Ticket Granting Service Request)
Request for service ticket.PA_DATA
Pre-authentication data.1: PA-TGS-REQ (AP-REQ for TGS)2: PA-ENC-TIMESTAMP (encrypted timestamp)11: PA-ETYPE-INFO (salt information)19: PA-ETYPE-INFO2 (extended salt info)128: PA-PAC-REQUEST (request PAC)129: PA-FOR-USER (S4U2Self)
Response Structures
AS-REP (Authentication Service Reply)
TGT response from KDC.pvno: Protocol version (5)msg-type: Message type (11 for AS-REP)crealm: Client realmcname: Client nameticket: The TGTenc-part: Encrypted part (session key, times, etc.)
EncASRepPart
Decrypted AS-REP encrypted part.key: Session key for TGS-REQnonce: Must match request nonceflags: Ticket flags grantedauthtime: Authentication timeendtime: TGT expirationsrealm: Server realmsname: Server name (krbtgt/REALM)
TGS-REP (Ticket Granting Service Reply)
Service ticket response.msg-type: 13ticket: Service ticket (not TGT)- Encrypted with TGS session key
EncTGSRepPart
Decrypted TGS-REP encrypted part.Application Protocol
AP-REQ (Application Request)
Client authentication to service.pvno: 5msg-type: 14ap-options: Request optionsticket: Service ticket from TGS-REPauthenticator: Encrypted authenticator
- Bit 2:
mutual-required- Request AP-REP
Authenticator
Proof of session key possession.crealm: Client realmcname: Client namecksum: Checksum of application data (optional)cusec: Microseconds of ctimectime: Current timesubkey: Optional session subkeyseq-number: Sequence number
AP-REP (Application Reply)
Mutual authentication response.pvno: 5msg-type: 15enc-part: Encrypted EncAPRepPart
EncAPRepPart
Decrypted AP-REP contents.Error Messages
KRB_ERROR
Error response from KDC or service.stime: Server timeerror-code: Kerberos error codee-text: Human-readable errore-data: Additional error data