avibrazil / iOSbackup

A Python 3 class that reads and extracts files from a password-encrypted iOS backup created by iTunes on Mac and Windows. Compatible with iOS 14. Class works on Linux too.
225 stars 38 forks source link

Decryption fails on large files #3

Closed jl6 closed 4 years ago

jl6 commented 4 years ago

Firstly, thank you for creating iOSbackup!

I am trying to extract all my photos and videos from an encrypted backup, using getFolderDecryptedCopy(). It works for most files, but gives the following error which I suspect is due to one of my video files being 3.2GB in size:

  File "./extract_all.py", line 58, in <module>
    b.getFolderDecryptedCopy(i, targetFolder=TARGET_FOLDER_MEDIA, includeDomains="CameraRollDomain")
  File "/home/username/.local/lib/python3.7/site-packages/iOSbackup/__init__.py", line 466, in getFolderDecryptedCopy
    (info,decrypted)=self.getFileDecryptedData(fileNameHash=f['fileID'],manifestData=f['file'])
  File "/home/username/.local/lib/python3.7/site-packages/iOSbackup/__init__.py", line 558, in getFileDecryptedData
    dataDecrypted = iOSbackup.AESdecryptCBC(dataEncrypted, key)[:fileData['Size']]
  File "/home/username/.local/lib/python3.7/site-packages/iOSbackup/__init__.py", line 807, in AESdecryptCBC
    dec = Crypto.Cipher.AES.new(key, Crypto.Cipher.AES.MODE_CBC, iv).decrypt(todec)
  File "/usr/lib/python3/dist-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt
    return self._cipher.decrypt(ciphertext)
OverflowError: size does not fit in an int
avibrazil commented 4 years ago

I'll try that in the following days. Thanks for pointing out.

avibrazil commented 4 years ago

I switched decryption from PyCrypto to PyCryptodome. Please try new version with pip3 install -U iOSbackup —user to try it and let me know. Reopen bug if it still fails.