#!/usr/bin/env python#~/Library/Application Support/MobileSync/Backupimport sys
import os
import hashlib
import shutil
mbdx = {}
dict = {}
defgetint(data, offset, intsize):"""Retrieve an integer (big-endian) and new offset from the current offset"""
value = 0while intsize > 0:
value = (value<<8) + ord(data[offset])
offset = offset + 1
intsize = intsize - 1return value, offset
defgetstring(data, offset):"""Retrieve a string and new offset from the current offset into the data"""if data[offset] == chr(0xFF) and data[offset+1] == chr(0xFF):
return'', offset+2# Blank string
length, offset = getint(data, offset, 2) # 2-byte length
value = data[offset:offset+length]
return value, (offset + length)
defprocess_mbdb_file(filename):
mbdb = {} # Map offset of info in this file => file info
data = open(filename).read()
if data[0:4] != "mbdb": raise Exception("This does not look like an MBDB file")
offset = 4
offset = offset + 2# value x05 x00, not sure what this iswhile offset < len(data):
fileinfo = {}
fileinfo['start_offset'] = offset
fileinfo['domain'], offset = getstring(data, offset)