Skip to main content

Overview

The impacket.krb5.ccache module implements the Kerberos credential cache file format used to store Kerberos tickets (TGT and TGS) for single sign-on. The implementation supports:
  • Reading/writing ccache files (versions 3 and 4)
  • Extracting tickets from cache
  • Converting between ccache and ticket formats
  • Converting to/from Kirbi format (Mimikatz)
  • Parsing credentials from environment variables

Module Location

Source: impacket/krb5/ccache.py

CCache Class

Main class for credential cache operations.

File Format

CCache File Structure

Version Support

  • Version 3: Basic format without headers
  • Version 4: Includes header section (recommended)

Loading Credentials

Load from File

Load ccache from file path:

Load from Environment

Automatically use KRB5CCNAME environment variable:

Load from Binary Data

Parse ccache from bytes:

Saving Credentials

Save to File

Create from TGT

Convert AS-REP to ccache:

Create from TGS

Convert TGS-REP to ccache:

Credential Structure

Credential Class

Represents a single cached ticket:

Credential Fields

Retrieving Credentials

Get Credential by SPN

Find cached ticket for service:

Match Any SPN

Find ticket with flexible matching:

Iterate All Credentials

Credential Conversion

Convert to TGT Format

Convert cached credential to TGT dict:

Convert to TGS Format

Convert cached credential to TGS dict:

Change SPN

Modify service principal in ticket:

Kirbi Format

Load Kirbi File

Load Mimikatz .kirbi file:

Save as Kirbi

Convert ccache to Mimikatz format:

Kirbi Format Details

Kirbi files use KRB-CRED ASN.1 structure:

Principal Structure

Principal Class

Represents Kerberos principal in ccache:

Create Principal

Key Block Structure

KeyBlock Classes

Version 3 and 4 have different key formats:

Access Key Data

Time Structure

Times Class

Stores ticket validity times:

Access Times

Practical Examples

Dump Ccache Contents

Extract and Use Ticket

Merge Ccache Files

Convert Between Formats

Renew Expired Ticket

Security Considerations

File Permissions

Protect ccache files:

Credential Expiration

Check ticket validity:

See Also