CAB Format

Purpose

This guide covers working with Microsoft Cabinet (CAB) files using Excavate.

Concepts

CAB (Cabinet) is a Microsoft archive format commonly used for software distribution and Windows system files. CAB files support multiple compression algorithms and can span multiple files.

Basic Usage

Extract CAB File

Excavate::Archive.new('archive.cab').extract

Extract Self-Extracting CAB

Some .exe files are self-extracting CAB archives:

# Excavate tries CAB after 7-Zip for .exe files
Excavate::Archive.new('installer.exe').extract

CAB Characteristics

Characteristic Description

File extension

.cab

Magic bytes

MSCF

Max file size

2 GB

Compression

None, LZSS, MSZIP, LZX, Quantum

Multi-part

Yes (spanned cabinets)

Platform

Windows (primary)

Compression Algorithms

CAB files support multiple compression methods:

  • None - Uncompressed storage

  • LZSS - Simple dictionary compression

  • MSZIP - Deflate-based (ZIP-compatible)

  • LZX - High compression ratio

  • Quantum - Memory-efficient compression

Excavate handles all compression types automatically.

Embedded CABs

CAB files are often embedded in other containers:

CAB in MSI

# Extract MSI and embedded CABs
Excavate::Archive.new('installer.msi').extract(recursive_packages: true)

CAB in EXE

# Self-extracting CAB executables
Excavate::Archive.new('sfx.exe').extract

Salvage Mode

Excavate uses Cabriolet’s salvage mode for corrupted CAB files:

# Cabriolet handles checksum errors gracefully
# Damaged files are extracted with warnings
Excavate::Archive.new('damaged.cab').extract

CLI Usage

# Extract CAB file
excavate archive.cab

# Extract recursively
excavate -r installer.cab

Common Use Cases

Extract Windows System Files

# Extract compressed system files from CAB
Excavate::Archive.new('windows.cab').extract(
  filter: '**/*.dll'
)

Extract Font Files

# Fonts are often distributed in CAB format
Excavate::Archive.new('fonts.cab').extract(
  filter: '**/*.{ttf,otf}'
)

Technical Details

Excavate uses the Cabriolet gem for CAB extraction:

  • Salvage mode enabled for error tolerance

  • Self-extracting archive support

  • Multi-part cabinet handling

  • All compression algorithms supported