def createWithSystemkbfile(filename, bag1key, deviceKey=None): if filename.startswith("bplist"): #HAX mkb = BPlistReader.plistWithString(filename) else: mkb = BPlistReader.plistWithFile(filename) try: decryptedPlist = AESdecryptCBC(mkb["_MKBPAYLOAD"].data, bag1key, mkb["_MKBIV"].data, padding=True) except: print "FAIL: AESdecryptCBC _MKBPAYLOAD => wrong BAG1 key ?" return None if not decryptedPlist.startswith("bplist"): print "FAIL: decrypted _MKBPAYLOAD is not bplist" return None decryptedPlist = BPlistReader.plistWithString(decryptedPlist) blob = decryptedPlist["KeyBagKeys"].data kb = Keybag.createWithDataSignBlob(blob, deviceKey) if decryptedPlist.has_key("OpaqueStuff"): OpaqueStuff = BPlistReader.plistWithString(decryptedPlist["OpaqueStuff"].data) kb.passcodeComplexity = OpaqueStuff.get("keyboardType") return kb
def getSystemkbfileWipeID(filename): mkb = BPlistReader.plistWithFile(filename) return mkb["_MKBWIPEID"]