当前位置: 首页>>代码示例>>Python>>正文


Python Keybag.unwrapKeyForClass方法代码示例

本文整理汇总了Python中keystore.keybag.Keybag.unwrapKeyForClass方法的典型用法代码示例。如果您正苦于以下问题:Python Keybag.unwrapKeyForClass方法的具体用法?Python Keybag.unwrapKeyForClass怎么用?Python Keybag.unwrapKeyForClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keystore.keybag.Keybag的用法示例。


在下文中一共展示了Keybag.unwrapKeyForClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from keystore.keybag import Keybag [as 别名]
# 或者: from keystore.keybag.Keybag import unwrapKeyForClass [as 别名]
def main():
    key = ""
    keyfile = ""
    getkey = 0
    opts,args = getopt.getopt(sys.argv[1:],"",["keyfile=","getkey"]);
    for o,a in opts:
        if o in ("--keyfile"):
            keyfile=a
            pass
        elif o in ("--getkey"):
            getkey=1
        pass
    args.insert(0,sys.argv[0])
    sys.argv=args
    if len(sys.argv)!=2:
        print "Usage: extract_encfiles.py (--keyfile keyfile) (--getkey) backupdir"
        sys.exit(0)
    backup_path = sys.argv[1]
    manifest = readPlist(backup_path + "/Manifest.plist")
    kb = Keybag(manifest["BackupKeyBag"].data)
    if not keyfile or getkey:
        password=getpass.getpass()
    else:
        password = ''
    if password:
        key=kb.getPasscodekeyFromPasscode(password,ios102=True)
        if getkey:
            if (len(key)==32):
                if keyfile:
                    f=open(keyfile,"w")
                    f.write(base64.b64encode(key))
                    f.close()
                else:
                    print base64.b64encode(key)
                    pass
            else:
                print "There was a problem extracting the key."
                pass
            sys.exit(0)
        pass
    f=open(keyfile,"r")
    key=base64.b64decode(f.read())
    key=key[0:32];
    kb.unlockWithPasscodeKey(key)
    manifest["password"] = password
    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)
    manifest_db = ManifestDB(backup_path, key=manifest_key)
    manifest_db.keybag = kb
    for filename, mbfile in manifest_db.files.iteritems():
        if (mbfile.domain=="HomeDomain"):
            if mbfile.relative_path in ("Library/SMS/sms.db","Library/AddressBook/AddressBook.sqlitedb"):
                mbfile.domain="."
                mbfile.relative_path=os.path.basename(mbfile.relative_path)
                if mbfile.relative_path=="sms.db":
                    mbfile.relative_path="sms-1.db"
                    pass
                if mbfile.relative_path=="AddressBook.sqlitedb":
                    mbfile.relative_path="addresses.db"
                    pass
                manifest_db._extract_file(filename,mbfile,"sms")
开发者ID:grandejf,项目名称:iphoneutil,代码行数:66,代码来源:extract_encfiles.py


注:本文中的keystore.keybag.Keybag.unwrapKeyForClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。