Пример #1
0
def extract_backup(backup_path, output_path, password=""):
    if not os.path.exists(backup_path + "/Manifest.plist"):
        print "Manifest.plist not found"
        return
    manifest = readPlist(backup_path + "/Manifest.plist")
    
    info = readPlist( backup_path + "/Info.plist")
    for i in showinfo:
        print i + " : " + unicode(info.get(i, "missing"))
    
#jsc
#    print "Extract backup to %s ? (y/n)" % output_path
#    if raw_input() == "n":
#        return
    
    print "Backup is %sencrypted" % (int(not manifest["IsEncrypted"]) * "not ")
    
#jsc
#    if manifest["IsEncrypted"] and password == "":
#        print "Enter backup password : "******"BackupKeyBag"):
        print "No BackupKeyBag in manifest, assuming iOS 3.x backup"
        decrypt_backup3(backup_path, output_path, password)
    else:    
        mbdb = MBDB(backup_path)
    
        kb = Keybag.createWithBackupManifest(manifest, password)
        if not kb:
            return
        
        #jsc
        password = kb.bfPassword

        manifest["password"] = password
        makedirs(output_path)
        plistlib.writePlist(manifest, output_path + "/Manifest.plist")
       
        mbdb.keybag = kb
        mbdb.extract_backup(output_path)
        
        #jsc
        print "Bruteforce successful, backup password : %s" % password
        
        print "You can decrypt the keychain using the following command : "
        print "python keychain_tool.py -d \"%s\" \"%s\"" % (output_path + "/KeychainDomain/keychain-backup.plist", output_path + "/Manifest.plist")
Пример #2
0
def extract_backup(backup_path, output_path, password=""):
    if not os.path.exists(backup_path + "/Manifest.plist"):
        print "Manifest.plist not found"
        return
    manifest = readPlist(backup_path + "/Manifest.plist")

    info = readPlist(backup_path + "/Info.plist")
    for i in showinfo:
        print i + " : " + unicode(info.get(i, "missing"))

    print "Extract backup to %s ? (y/n)" % output_path
    if raw_input() == "n":
        return

    print "Backup is %sencrypted" % (int(not manifest["IsEncrypted"]) * "not ")

    if manifest["IsEncrypted"] and password == "":
        print "Enter backup password : "******"BackupKeyBag"):
        print "No BackupKeyBag in manifest, assuming iOS 3.x backup"
        decrypt_backup3(backup_path, output_path, password)
    else:
        mbdb = MBDB(backup_path)

        kb = Keybag.createWithBackupManifest(manifest, password)
        if not kb:
            return
        manifest["password"] = password
        makedirs(output_path)
        plistlib.writePlist(manifest, output_path + "/Manifest.plist")

        mbdb.keybag = kb
        mbdb.extract_backup(output_path)

        print "You can decrypt the keychain using the following command : "
        print "python keychain_tool.py -d %s %s" % (
            output_path + "/keychain-backup.plist",
            output_path + "/Manifest.plist")
Пример #3
0
def extract_backup(backup_path, output_path, password="", app=None):
    '''
    if not os.path.exists(backup_path + "/Manifest.plist"):
        print "Manifest.plist not found"
        return
    manifest = readPlist(backup_path + "/Manifest.plist")
    '''
    manifest = readManifest(backup_path)
    if manifest is None:
        print("Manifest.plist not found")
        return

#    dict = manifest['Applications']
#    for apps in dict.iteritems():
#        print "App Name: " + apps[0]
#        for key, value in apps[1].iteritems():
#            print key + " : " + value
#        print "####################################"

    showinfo = readInfo(backup_path)
    if showinfo is None:
        print("Info.plist not found")
        return
    for i in showinfo:
        value = unicode(showinfo.get(i, "missing"))
        if i == "Product Type":
            value = value + " (" + getIDeviceProductName(value) + ")"
        print(i + " : " + value + "...")

#    print "Extract backup to %s ? (y/n)" % output_path
#    if raw_input() == "n":
#        return

    print("Backup is %sencrypted" % (int(not manifest["IsEncrypted"]) * "not "))

    if manifest["IsEncrypted"] and password == "":
        print ("Enter backup password : "******"BackupKeyBag"):
        print ("No BackupKeyBag in manifest, assuming iOS 3.x backup")
        decrypt_backup3(backup_path, output_path, password)
    else:
        mbdb = MBDB(backup_path)

        kb = Keybag.createWithBackupManifest(manifest, password)
        if not kb:
            return
        manifest["password"] = password
        makedirs(output_path)
        plistlib.writePlist(manifest, output_path + "/Manifest.plist")

        mbdb.keybag = kb

        database, cursor = iOSBackupDB()


        store2db(cursor, mbdb)
        database.commit()
        print_domains(cursor)
        cursor.execute("Select * from indice where mbapp_name= ?", (app,))
        records = cursor.fetchall()
        for record in records:
            dbrecord = MBFileRecordFromDB(record)
            mbdb.extract_backup_from_db(dbrecord, output_path)
Пример #4
0
def extract_backup(backup_path, output_path, password=""):
    if not os.path.exists(backup_path + "/Manifest.plist"):
        print "Manifest.plist not found"
        return
    manifest = readPlist(backup_path + "/Manifest.plist")

    info = readPlist(backup_path + "/Info.plist")
    for i in showinfo:
        print i + " : " + unicode(info.get(i, "missing"))

    print "Extract backup to %s ? (y/n)" % output_path
    if raw_input() == "n":
        return

    print "Backup is %sencrypted" % (int(not manifest["IsEncrypted"]) * "not ")

    if manifest["IsEncrypted"] and password == "":
        print "Enter backup password : "******"BackupKeyBag"):
        print "No BackupKeyBag in manifest, assuming iOS 3.x backup"
        decrypt_backup3(backup_path, output_path, password)
    elif os.path.exists(backup_path + "/Manifest.mbdb"):
        mbdb = MBDB(backup_path)

        kb = Keybag.createWithBackupManifest(manifest, password)
        if not kb:
            return
        manifest["password"] = password
        makedirs(output_path)
        plistlib.writePlist(manifest, output_path + "/Manifest.plist")

        mbdb.keybag = kb
        mbdb.extract_backup(output_path)

        print "You can decrypt the keychain using the following command : "
        print "python keychain_tool.py -d \"%s\" \"%s\"" % (
            output_path + "/KeychainDomain/keychain-backup.plist",
            output_path + "/Manifest.plist")

    elif os.path.exists(backup_path + "/Manifest.db"):
        if 'ManifestKey' in manifest:
            kb = Keybag.createWithBackupManifest(manifest,
                                                 password,
                                                 ios102=True)
        else:
            kb = Keybag.createWithBackupManifest(manifest, password)

        if not kb:
            return
        manifest["password"] = password
        makedirs(output_path)
        plistlib.writePlist(manifest, output_path + "/Manifest.plist")

        manifest_key = None
        if 'ManifestKey' in manifest:
            clas = struct.unpack('<L', manifest['ManifestKey'].data[:4])[0]
            wkey = manifest['ManifestKey'].data[4:]
            manifest_key = kb.unwrapKeyForClass(clas, wkey)

        manifset_db = ManifestDB(backup_path, key=manifest_key)
        manifset_db.keybag = kb
        manifset_db.extract_backup(output_path)

        print "You can decrypt the keychain using the following command: "
        print "python keychain_tool.py -d \"%s\" \"%s\"" % (
            output_path + "/KeychainDomain/keychain-backup.plist",
            output_path + "/Manifest.plist")

    else:
        print "No Manifest database found, Is it a complete backup?"