IPSW Parser

1.6.0 · active · verified Thu Apr 16

ipsw-parser is a Python 3 utility for parsing and extracting data from Apple IPSW (iPhone Software) firmware files. It provides programmatic access to various components within an IPSW, such as kernelcaches, build manifests, and device class hashes (DSC). The library is actively maintained with frequent minor updates, currently at version 1.6.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `IPSW` parser with a firmware file, retrieve basic information like the device class and build ID, and extract common components such as the kernelcache and device class hashes (DSC).

from ipsw_parser.ipsw import IPSW
from ipsw_parser.exceptions import IPSWError
import os

# For demonstration, assume an IPSW file exists or is specified via environment variable.
# Replace 'path/to/your/firmware.ipsw' with an actual path to an IPSW file.
# You can often find these files on websites like ipsw.me
ipsw_file_path = os.environ.get('IPSW_FILE_PATH', 'path/to/your/firmware.ipsw')

if not os.path.exists(ipsw_file_path):
    print(f"Warning: IPSW file not found at '{ipsw_file_path}'. Please provide a valid path.")
    print("Skipping quickstart example as no IPSW file is available.")
else:
    try:
        # Initialize the IPSW parser with the file path
        ipsw = IPSW(ipsw_file_path)
        print(f"Successfully loaded IPSW from: {ipsw.path}")

        # Access basic information
        print(f"Device Class: {ipsw.build_identity.device_class}")
        print(f"Build ID: {ipsw.build_identity.build_id}")

        # Example: Extract the kernelcache
        # This will extract to a default temporary location or specified directory
        kernel_path = ipsw.extract_kernelcache()
        print(f"Kernelcache extracted to: {kernel_path}")

        # Example: Extract the device class hashes (DSC) if available
        # Note: In v1.5.0+, dsc extraction logic was moved to a separate module.
        # This example uses the primary IPSW object method which wraps the new logic.
        dsc_path = ipsw.extract_dsc()
        if dsc_path:
            print(f"Device Class Hashes (DSC) extracted to: {dsc_path}")
        else:
            print("No DSC found or extracted.")

    except IPSWError as e:
        print(f"Error parsing IPSW file: {e}")
    except FileNotFoundError:
        print(f"Error: The specified IPSW file '{ipsw_file_path}' was not found.")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →