pub struct Backup {
pub backup_path: PathBuf,
pub manifest: Manifest,
pub manifest_db: ManifestDb,
}
Expand description
Main entry point for working with an iOS backup.
Provides methods to initialize, configure, and extract data from a backup, including metadata loading, manifest database access, and file decryption.
Fields§
§backup_path: PathBuf
Filesystem path to the specific device backup folder
manifest: Manifest
Parsed manifest and decryption state
manifest_db: ManifestDb
Decrypted manifest database details
Implementations§
Source§impl Backup
impl Backup
Sourcepub fn open<P: AsRef<Path>>(
backup_path: P,
auth: &Authentication,
) -> Result<Self>
pub fn open<P: AsRef<Path>>( backup_path: P, auth: &Authentication, ) -> Result<Self>
Create a new Backup
instance, loading manifest data.
§Arguments
backup_path
- Filesystem path to a specific device backup folder (the UDID directory).auth
-Authentication
specifying password or derived key.
§Errors
Returns BackupError
if paths are invalid, manifest loading fails, or decryption fails.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
println!("UDID: {}", backup.udid()?);
Sourcepub fn udid(&self) -> Result<&str>
pub fn udid(&self) -> Result<&str>
Returns the current device UDID
(the backup folder name).
§Errors
Returns BackupError::InvalidBackupRoot
if the UDID
cannot be retrieved as a string.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let udid = backup.udid()?;
println!("UDID: {}", udid);
Sourcepub fn lockdown(&self) -> &ManifestLockdownInfo
pub fn lockdown(&self) -> &ManifestLockdownInfo
Returns device metadata from Manifest.plist
.
§Returns
Manifest lockdown information parsed from Manifest.plist
.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let lockdown = backup.lockdown();
println!("Device name: {}", lockdown.device_name);
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Sourcepub fn apps(&self) -> &[Application]
pub fn apps(&self) -> &[Application]
Get a reference to the applications in the backup.
§Returns
A reference to a vector of Application
objects parsed from the manifest.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let apps = backup.apps();
for app in apps {
println!("App: {}", app.bundle_id);
}
Sourcepub fn decryption_key_hex(&self) -> Option<String>
pub fn decryption_key_hex(&self) -> Option<String>
Returns the main decryption key as a hex string, if the backup is encrypted.
§Returns
An Option<String>
containing the decryption key in hexadecimal representation,
or None
if the backup is not encrypted.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
if let Some(key_hex) = backup.decryption_key_hex() {
println!("Key: {}", key_hex);
}
Sourcepub fn decryption_key(&self) -> Option<EncryptionKey>
pub fn decryption_key(&self) -> Option<EncryptionKey>
Retrieve the raw 32-byte decryption key, if available.
§Returns
An Option<KeyEncryptionKey>
containing the main decryption key, or None
if not encrypted.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
if let Some(key) = backup.decryption_key() {
println!("Key: {:?}", key);
}
Sourcepub fn query_all_domains(&self) -> Result<HashSet<String>>
pub fn query_all_domains(&self) -> Result<HashSet<String>>
Get all domains present in the backup’s manifest database.
Some common domains, in no particular order, include:
AppDomain
AppDomainGroup
AppDomainPlugin
CameraRollDomain
DatabaseDomain
HealthDomain
HomeDomain
HomeKitDomain
InstallDomain
KeyboardDomain
KeychainDomain
ManagedPreferencesDomain
MediaDomain
MobileDeviceDomain
NetworkDomain
ProtectedDomain
RootDomain
SysContainerDomain
SysSharedContainerDomain
SystemPreferencesDomain
TonesDomain
WirelessDomain
§Returns
A HashSet<String>
containing each unique domain present in the backup.
§Errors
Returns BackupError::ManifestDbNotFound
if the manifest database is unavailable,
or BackupError::Database
if the database query fails.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let domains = backup.query_all_domains()?;
println!("Domains: {:?}", domains);
Sourcepub fn manifest_db_path(&self) -> &Path
pub fn manifest_db_path(&self) -> &Path
Get the filesystem path to the decrypted (or raw) Manifest.db
file.
§Returns
A Path
pointing to the location of the manifest database file.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let db_path = backup.manifest_db_path();
println!("Manifest.db path: {:?}", db_path);
Sourcepub fn entries(&self) -> Result<Vec<BackupFileEntry>>
pub fn entries(&self) -> Result<Vec<BackupFileEntry>>
List all files recorded in Manifest.db
.
§Errors
Returns BackupError::Database
if the database cannot be accessed.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let entries = backup.entries()?;
for entry in entries {
println!("{:?}", entry);
}
Sourcepub fn get_file(&self, file_id: &str) -> Result<BackupFileEntry>
pub fn get_file(&self, file_id: &str) -> Result<BackupFileEntry>
Get a single file entry by its file ID.
§Arguments
file_id
- The file’s unique identifier (SHA1
hash).
§Errors
Returns BackupError::FileNotFoundInBackup
if the specified file ID is not found,
or BackupError::Database
if the database query fails.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let entry = backup.get_file("fileid")?;
println!("File encryption key: {:?}", entry.metadata.encryption_key);
Sourcepub fn decrypt_entry(&self, entry: &BackupFileEntry) -> Result<Vec<u8>>
pub fn decrypt_entry(&self, entry: &BackupFileEntry) -> Result<Vec<u8>>
Decrypt the file represented by BackupFileEntry
, returning plaintext bytes.
All operations are performed in memory, and the decrypted data is returned as a byte vector.
§Arguments
entry
- ABackupFileEntry
containing metadata and encrypted file ID.
§Returns
Plaintext data as a byte vector.
§Errors
Returns BackupError::Crypto
on decryption errors or missing keys.
§Examples
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let entry = backup.get_file("fileid")?;
let data = backup.decrypt_entry(&entry)?;
println!("Data size: {} bytes", data.len());
Sourcepub fn decrypt_entry_stream(
&self,
entry: &BackupFileEntry,
) -> Result<AesCbcDecryptReader<BufReader<File>>>
pub fn decrypt_entry_stream( &self, entry: &BackupFileEntry, ) -> Result<AesCbcDecryptReader<BufReader<File>>>
Decrypt the file represented by BackupFileEntry
, returning a streaming reader.
All operations are streamed from the disk, and the decrypted data is returned as a reader.
§Arguments
entry
- ABackupFileEntry
containing metadata and encrypted file ID.
§Returns
A streaming reader implementing std::io::Read
that yields plaintext as it’s read.
§Errors
Returns BackupError::Crypto
on decryption errors or missing keys.
§Examples
use std::{fs::File, io::copy};
use crabapple::{Backup, Authentication};
let backup = Backup::open(
"/path/to/backup",
&Authentication::Password("pass".into()),
)?;
let file = backup.get_file("41ee3469300471004e6d526ebd09c051c19f8a39")?;
let mut reader = backup.decrypt_entry_stream(&file)?;
let mut plain = Vec::new();
copy(&mut reader, &mut plain)?;