Skip to main content

Introduction

The impacket.krb5 module provides a comprehensive implementation of the Kerberos v5 network authentication protocol (RFC 4120) with Microsoft extensions from [MS-KILE] and [MS-PAC]. This module enables Python applications to:
  • Request and manage Kerberos tickets (TGT/TGS)
  • Perform Kerberos authentication operations
  • Manipulate credential caches and keytabs
  • Handle ASN.1 structures for Kerberos messages
  • Encrypt/decrypt Kerberos messages with various cipher suites
  • Process Privilege Attribute Certificates (PAC)

Module Structure

The Kerberos implementation is organized into several specialized modules:

Core Components

Authentication Flow

The typical Kerberos authentication workflow:

Principal Names

Principal objects represent Kerberos identities:

Tickets

Ticket objects encapsulate Kerberos tickets:

Encryption Types

Supported encryption algorithms:

Principal Name Types

Common principal name types:

Ticket Flags

Kerberos ticket flags control ticket properties:

Error Handling

Kerberos operations raise KerberosError exceptions:

Common Error Codes

Time Handling

Kerberos timestamps use the KerberosTime class:

Credential Management

Using Credential Caches

Using Keytabs

Authentication Methods

Password Authentication

Hash Authentication (Pass-the-Hash)

AES Key Authentication

GSS-API Integration

The module supports GSS-API for application-level authentication:

Best Practices

Security Considerations

  1. Use AES encryption: Prefer AES-256 over RC4 or DES
  1. Handle clock skew: Ensure system time is synchronized
  1. Secure credential storage: Protect keytabs and caches
  1. Request PAC when needed: Include authorization data

Performance Tips

  1. Cache tickets: Reuse TGT for multiple TGS requests
  2. Specify KDC host: Avoid DNS lookups
  3. Use appropriate cipher: Balance security and performance

Advanced Features

Ticket Renewal

S4U Extensions

Service-for-User extensions for constrained delegation:

Module Reference

Core Modules

Supporting Modules

  • constants - Enumerations and error codes
  • types - Type definitions (Principal, Ticket, etc.)
  • keytab - Keytab file handling
  • pac - Privilege Attribute Certificate
  • gssapi - GSS-API integration

Examples

Complete Authentication Example

See Also