Skip to main content

iphone-backup-decrypt

Decrypt an encrypted, local iPhone backup created from iOS13 or newer. This code was based on this StackOverflow answer, itself based on the iphone-dataprotection code.

Install

PyPI - Version

Requires Python 3.8 or higher.

The backup decryption keys are protected using 10 million rounds of PBKDF2 with SHA256, then 10 thousand further iterations of PBKDF2 with SHA-1. To speed up decryption, fastpbkdf2 is desirable; otherwise the code will fall back to using pycryptodome's implementation. The fallback is ~50% slower at the initial backup decryption step, but does not require the complicated build and install of fastpbkdf2.

Install via pip:

pip install iphone_backup_decrypt
# Optionally:
pip install fastpbkdf2

Or if you have Docker, an alternative is to use the pre-built image: ghcr.io/jsharkey13/iphone_backup_decrypt. A Command Prompt example might look like:

docker run --rm -it ^
    -v "%AppData%/Apple Computer/MobileSync/Backup/[device-specific-hash]":/backup:ro ^
    -v "%cd%/output":/output ^
    ghcr.io/jsharkey13/iphone_backup_decrypt

Usage

This code decrypts the backup using the passphrase chosen when encrypted backups were enabled in iTunes.

The relativePath of the file(s) to be decrypted also needs to be known. Very common files, like those for the call history or text message databases, can be found in the RelativePath class: e.g. use RelativePath.CALL_HISTORY instead of the full Library/CallHistoryDB/CallHistory.storedata.

More complex matching, particularly for non-unique filenames, may require specifying the domain of the files. The DomainLike and MatchFiles classes contain common domains and domain-path pairings.

If the relative path is not known, you can manually open the Manifest.db SQLite database and explore the Files table to find those of interest. After creating the class, use the EncryptedBackup.save_manifest_file(...) method to store a decrypted version.

A minimal example to decrypt and extract some files might look like:

from iphone_backup_decrypt import EncryptedBackup, RelativePath, MatchFiles

passphrase = "..."  # Or load passphrase more securely from stdin, or a file, etc.
backup_path = "%AppData%/Apple Computer/MobileSync/Backup/[device-specific-hash]"
# Or MacOS: "/Users/[user]/Library/Application Support/MobileSync/Backup/[device-hash]"

backup = EncryptedBackup(backup_directory=backup_path, passphrase=passphrase)

# Extract the call history SQLite database:
backup.extract_file(relative_path=RelativePath.CALL_HISTORY, 
                    output_filename="./output/call_history.sqlite")

# Extract the camera roll, using MatchFiles for combined path and domain matching:
backup.extract_files(**MatchFiles.CAMERA_ROLL, output_folder="./output/camera_roll")

# Extract any iCloud camera roll images on the device (may include thumbnails for some
# but not all images offloaded to the cloud, and have duplicates from the camera roll):
backup.extract_files(**MatchFiles.ICLOUD_PHOTOS, output_folder="./output/icloud_photos")

# Extract WhatsApp SQLite database and attachments:
backup.extract_file(relative_path=RelativePath.WHATSAPP_MESSAGES,
                    output_filename="./output/whatsapp.sqlite")
backup.extract_files(**MatchFiles.WHATSAPP_ATTACHMENTS,
                     output_folder="./output/whatsapp", preserve_folders=False)

# Extract Strava workouts:
backup.extract_files(**MatchFiles.STRAVA_WORKOUTS, output_folder="./output/strava")

Alternatives

This library aims to be minimal, providing only what is necessary to extract encrypted files. There are alternatives which claim to offer similar or more advanced functionality:

Release files for iphone-backup-decrypt 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iphone-backup-decrypt 0.10.0
File Size Uploaded
iphone_backup_decrypt-0.10.0.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iphone-backup-decrypt 0.10.0
File Interpreter ABI Platform
iphone_backup_decrypt-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.3 kB

Release files / iphone_backup_decrypt-0.10.0.tar.gz

Download URL iphone_backup_decrypt-0.10.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5f2799e58f908cce28d7929dd82231abc8acd57c25b37bce6a2d6a82e018d343
BLAKE2b-256 checksum
How to use checksums
01b8a2ec2b10d792403d36bb6661fea6357179c31ece1ed3285c442e636d6335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / iphone_backup_decrypt-0.10.0-py3-none-any.whl

Download URL iphone_backup_decrypt-0.10.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ac4345a07b104a3eacab20932b8621cd1e0164e0f03d913e66eed6ea5ee173e
BLAKE2b-256 checksum
How to use checksums
8910349b2a720e012921d1457e1d1c2b921b16300a5f3570c4c64d0d3787539f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

0.11.2

2 release files

0.11.0

2 release files

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page