Peter Davies

Ramblings

Recovering the password on your own iPhone backup

If you turned on "Encrypt local backup" for an iPhone and then forgot the password, the backup is useless, as iTunes (and Finder on newer macOS) will not restore it without that password. There is no reset: the encryption is tied to the password, not to your Apple ID. What you can do, for a backup that is your own, is pull the verifier out of the backup and let hashcat try to find the password for you.

This only works on a backup you own and only as fast as the password is weak. A strong, random password is not coming back this way, which is rather the point of the feature.

What you are attacking

An encrypted backup stores a password verifier derived with PBKDF2 over a very large number of iterations. iOS 10.2 raised that iteration count sharply, which is why the hash format, and the hashcat mode, differs by iOS version:

The parameters live in the backup's Manifest.plist. You do not read them by hand; a small extractor reads the plist and emits the single line hashcat expects.

Extract the hash

On a backup folder you own, point an iTunes-backup-to-hashcat extractor at it. There is a well-known open one, itunes_backup2hashcat, that takes the Manifest.plist and prints the hash:

python3 itunes_backup2hashcat.py Manifest.plist > backup.hash

The result is one line beginning with $itunes_backup$. That line is the only thing hashcat needs; the rest of the backup stays where it is.

Run hashcat

Point hashcat at the extracted hash with the mode that matches the iOS version. A straight dictionary attack (-a 0) against a wordlist is the sensible first pass, especially if you have any idea what you tend to use:

hashcat -m 14800 -a 0 -w 4 -o cracked.txt backup.hash wordlist.txt

When it finishes, --show prints the recovered password next to the hash:

hashcat -m 14800 --show backup.hash

Be realistic about speed. Mode 14800 is deliberately slow (that high PBKDF2 iteration count again), so guess rates are low even on a good GPU. A dictionary or a rule-mangled wordlist based on passwords you actually use is far more likely to land than brute force. If you have the right password but the backup still will not restore, you have probably got the wrong iOS-version mode, so try the other one.

There is a good write-up of the format and the end-to-end process here: https://medium.com/taptuit/breaking-into-encrypted-iphone-backups-4dacc39403f0

The honest takeaway cuts both ways. For your own locked-out backup this is a genuine route back in if the password was guessable. And if it was not guessable, that is the system working: an encrypted iOS backup with a strong password is, for practical purposes, not recoverable without it, so store that password somewhere you will not lose it.