Skip to main content

Module kernelcache

Module kernelcache 

Source
Expand description

Kernelcache parsing, search, and extraction.

Supports Mach-O kernel collections (MH_FILESET) and legacy prelinked kernels (MH_EXECUTE with __PRELINK_INFO), either raw or wrapped in IMG4 or IM4P containers and compressed with LZFSE or complzss.

File offsets in fileset members are collection-relative. Legacy prelinked kexts use image-relative offsets and are located through prelink metadata. Extracted images retain unslid virtual addresses and are intended for static analysis.

§Example

use dylex::KernelCacheContext;

fn main() -> dylex::Result<()> {
    let cache = KernelCacheContext::open("kernelcache.release.mac16j")?;
    let sandbox = cache.resolve_image("com.apple.security.sandbox")?;
    std::fs::write("sandbox.macho", cache.extract_image(sandbox)?)?;
    Ok(())
}

Structs§

CollectionIdentity
Build identities read from a kernelcache.
DiscoveryCommand
One captured command execution. Standard output and error are kept separate.
InputEncoding
Container and compression removed while decoding the input.
KernelCacheContext
A decoded kernelcache with validated embedded Mach-O headers.
KernelCandidate
The inspection result for one candidate kernelcache.
KernelDiscoveryReport
Runtime identities, inspected candidates, command evidence, and issues.
KernelImage
The kernel or an executable kext embedded in a kernelcache.
KernelUuid
A 128-bit Mach-O build UUID.

Enums§

Compression
Compression applied to a kernelcache payload.
Container
Container format that wrapped a kernelcache payload.
KernelCacheFormat
Layout of a decoded kernelcache.

Constants§

KERNEL_IMAGE_ID
Image ID of the kernel itself.

Functions§

discover_kernelcaches
Locates boot kernelcaches matching the running macOS kernel and, optionally, the loaded kext whose bundle identifier is exactly target.