Skip to content

Instantly share code, notes, and snippets.

@djravine
Forked from barezina/backup.py
Created January 14, 2020 23:34
Show Gist options
  • Save djravine/cbece97e05f09c749b317743a2d6b0c4 to your computer and use it in GitHub Desktop.
Save djravine/cbece97e05f09c749b317743a2d6b0c4 to your computer and use it in GitHub Desktop.
BackupRipper for iOS - Unpack an iOS iPhone Backup into its native files.
import sqlite3
import os
print('BackupRipper for iOS - v1.0')
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
backuppath = '/home/bob/Desktop/bob_iphone_oct_2019/'
conn = sqlite3.connect(backuppath + 'Manifest.db')
conn.row_factory = dict_factory
c = conn.cursor()
c.execute("""
select substr(fileId, 0, 3) as folder, fileID, relativePath
from Files
""")
results = c.fetchall()
for row in results:
folder = row['folder']
fileID = row['fileID']
relativePath = row['relativePath']
fileName = relativePath.split('/').pop()
pathElements = relativePath.split('/')
pathElements.pop()
pathOnly = '/'.join(pathElements)
print(relativePath)
if not os.path.isdir(backuppath + 'EXTRACTED_FILES/' + pathOnly):
os.makedirs(backuppath + 'EXTRACTED_FILES/' + pathOnly)
if os.path.exists(backuppath + folder + '/' + fileID):
os.rename(backuppath + folder + '/' + fileID, backuppath + 'EXTRACTED_FILES/' + relativePath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment