def restore32(device, iosversion): if os.path.exists("resources/bin/futurerestore"): shutil.move("resources/bin/futurerestore", "futurerestore") elif os.path.exists("resources/bin/igetnonce"): shutil.move("resources/bin/igetnonce", "igetnonce") elif os.path.exists("resources/bin/tsschecker"): shutil.move("resources/bin/tsschecker", "tsschecker") elif os.path.exists("resources/bin/irecovery"): shutil.move("resources/bin/irecovery", "irecovery") print("Getting SHSH...") ecid = localdevice.getecid() device32 = str(localdevice.getmodel()) cmd = f'./tsschecker -d {device32} -i {iosversion} -o -m resources/manifests/BuildManifest_{device32}.plist -e {ecid} -s' so = subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL) returncode = so.returncode if returncode != 0: print( "Saving SHSH failed.\nPlease try again and report the error + full logs if it persists.\nExiting..." ) exit(938862428) dir_name = os.getcwd() test = os.listdir(dir_name) for item in test: if item.endswith(".shsh2"): shutil.move(os.path.join(dir_name, item), "resources/other/apnonce.shsh") print("Restoring...") print( '\033[91m' + "Note that errors about 'BbSkeyId', 'FDR Client' and 'BasebandFirmware Node' are not important, just ignore them and only report errors that actually stop the restore." + '\033[0m') if device32 != "iPad2,1" or "iPad2,4" or "iPad2,5" or "iPad3,1" or "iPad3,4" or "iPod5,1": cmd2 = './futurerestore -t resources/other/apnonce.shsh --use-pwndfu --latest-baseband custom.ipsw' so = subprocess.run(cmd2, shell=True, stdout=subprocess.DEVNULL) returncode = so.returncode if returncode != 0: print( "Resoting Failed.\nPlease try again and report the error + full logs if it persists.\nExiting..." ) exit(938862428) else: cmd2 = './futurerestore -t resources/other/apnonce.shsh --no-baseband --use-pwndfu custom.ipsw' so = subprocess.run(cmd2, shell=True, stdout=subprocess.DEVNULL) returncode = so.returncode print(returncode) if returncode != 0: print( "Resoting Failed.\nPlease try again and report the error + full logs if it persists.\nExiting..." ) exit(938862428)
def unzipIPSW(): devicemodel = str(localdevice.getmodel()) arm64check = ('iPhone6,2') if any(ext in devicemodel for ext in arm64check): pwndfumode() restore64(devicemodel) else: print("ERROR: Unsupported model or device not connected!") exit(82)
def saveshsh(path): print("Getting SHSH...") if not os.path.exists("igetnonce"): shutil.move("resources/bin/igetnonce", "igetnonce") if not os.path.exists("tsschecker"): shutil.move("resources/bin/tsschecker", "tsschecker") device = localdevice.getmodel() ecid = localdevice.getecid() nonce = localdevice.getapnonce() if device != "iPad4,3": cmd = f'./tsschecker -d {device} -i 10.3.3 -o -m resources/manifests/BuildManifest_{device}.plist -e {ecid} --apnonce {nonce} -s' else: cmd = f'./tsschecker -d iPad4,3 --boardconfig j73AP -i 10.3.3 -o -m resources/manifests/BuildManifest_iPad4,3.plist -e {ecid} --apnonce {nonce} -s' so = subprocess.run(cmd, shell=True, stdout=open('errorlogshsh.txt', 'w')) returncode = so.returncode output = 'errorlogshsh.txt' if returncode != 0: with open(output, 'r') as fin: print(fin.read()) print("ERROR..\nReturn code:", returncode) print( "SHSH Saving Failed.\nPlease try again and report the error/full logs and the 'errorlogshsh.txt' file if it persists.\nExiting..." ) exit(938862428) else: if os.path.exists('errorlogshsh.txt'): os.remove('errorlogshsh.txt') dir_name = os.getcwd() test = os.listdir(dir_name) if not str(path).endswith("/"): path = path + "/" dest_name = path + "OTA.shsh" for item in test: if item.endswith(".shsh"): if os.path.exists(dest_name): os.remove(dest_name) shutil.move(os.path.join(dir_name, item), dest_name) if os.path.exists("igetnonce"): shutil.move("igetnonce", "resources/bin/igetnonce") if os.path.exists("tsschecker"): shutil.move("tsschecker", "resources/bin/tsschecker") return dest_name
def restore32(device, iosversion): print("Getting SHSH...") ecid = localdevice.getecid() device32 = str(localdevice.getmodel()) if iosversion == "6.1.3": cmd = f'{tsschecker} -d {device32} -i {iosversion} -o -m resources/manifests/BuildManifest613_{device32}.plist -e {"0x" + ecid} -s' else: cmd = f'{tsschecker} -d {device32} -i {iosversion} -o -m resources/manifests/BuildManifest_{device32}.plist -e {"0x" + ecid} -s' so = subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL) returncode = so.returncode if returncode != 0: print( "Saving SHSH failed.\nPlease try again and report the error + full logs if it persists.\nExiting..." ) exit(938862428) dir_name = os.getcwd() test = os.listdir(dir_name) for item in test: if item.endswith(".shsh2"): shutil.move(os.path.join(dir_name, item), "resources/other/apnonce.shsh") print("Restoring...") print( '\033[91m' + "Note that errors about 'BbSkeyId', 'FDR Client', 'BasebandFirmware Node' and 'ERROR: zip_name_locate: Firmware/all_flash/manifest' are not important.\nJust ignore them and only report errors that actually stop the restore." + '\033[0m') futurerestore = "resources/bin/futurerestore" if device32 == "iPad2,1" or device32 == "iPad2,4" or device32 == "iPad2,5" or device32 == "iPad3,1" or device32 == "iPad3,4" or device32 == "iPod5,1": cmd2 = f'{futurerestore} -t resources/other/apnonce.shsh --no-baseband --use-pwndfu custom.ipsw' so2 = subprocess.run(cmd2, shell=True, stdout=open('errorlogrestore.txt', 'w')) returncode = so2.returncode output = 'errorlogrestore.txt' if returncode != 0: with open(output, 'r') as fin: print(fin.read()) print("ERROR..\nReturn code:", returncode) print( "Restore Failed.\nPlease try again and report the error/send me the full logs and the 'errorlogrestore.txt' file if it persists\nExiting..." ) exit(938862428) else: if os.path.exists('errorlogrestore.txt'): os.remove('errorlogrestore.txt') else: cmd2 = f'{futurerestore} -t resources/other/apnonce.shsh --use-pwndfu --latest-baseband custom.ipsw' so2 = subprocess.run(cmd2, shell=True, stdout=open('errorlogrestore.txt', 'w')) returncode = so2.returncode output = 'errorlogrestore.txt' if returncode != 0: with open(output, 'r') as fin: print(fin.read()) print("ERROR..\nReturn code:", returncode) print( "Restore Failed.\nPlease try again and report the error/send me the full logs and the 'errorlogrestore.txt' file if it persists\nExiting..." ) exit(938862428) else: if os.path.exists('errorlogrestore.txt'): os.remove('errorlogrestore.txt')
def unzipIPSW_ORG(fname): # from: vieux my1 armv7 = [ 'iPhone4,1', 'iPad2,1', 'iPad2,2', 'iPad2,3', 'iPad2,4', 'iPad2,5', 'iPad2,6', 'iPad2,7', 'iPod5,1' ] armv7s = [ 'iPhone5,1', 'iPhone5,2', 'iPad3,4', 'iPad3,5', 'iPad3,6', 'iPad3,1', 'iPad3,2', 'iPad3,3' ] #if os.path.exists("custom.ipsw"): #os.remove("custom.ipsw") outputFolder = "IPSW" newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) if not os.path.exists('IPSW'): os.mkdir('IPSW') while not testFile or not fname.endswith != (".ipsw"): print( "Invalid filepath/filename.\nPlease try again with a valid filepath/filename." ) fname = input( "Enter the path to the IPSW file (Or drag and drop the IPSW into this window):\n" ) newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) if testFile and fname.endswith(".ipsw"): if not os.path.exists('IPSW'): removeFiles() with ZipFile(fname, 'r') as zip_ref: zip_ref.extractall(outputFolder) source = ("IPSW/Firmware/dfu/") dest1 = os.getcwd() files = os.listdir(source) for f in files: shutil.move(source + f, dest1) devicemodel = str(localdevice.getmodel()) version = False supportedModels = str(readmanifest("IPSW/BuildManifest.plist", version)) arm64check = ('iPhone6,2') if any(ext in devicemodel for ext in arm64check): # devicemodel == NULL if something wrong pwndfumode() # my1 createCustomIPSW64(devicemodel) else: print("ERROR: Unsupported model or device not connected!") exit(82) else: print('\033[91m' + "Invalid filepath!")
def unzipIPSW(fname): if os.path.exists("custom.ipsw"): os.remove("custom.ipsw") print("Starting IPSW unzipping") outputFolder = os.getcwd() newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) while not testFile or not fname.endswith != (".ipsw"): print( "Invalid filepath/filename.\nPlease try again with a valid filepath/filename." ) fname = input( "Enter the path to the IPSW file (Or drag and drop the IPSW into this window):\n" ) newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) else: #Will now continue with new valid file print("Continuing...") if testFile and fname.endswith(".ipsw"): if os.path.exists("resources/restoreFiles/igetnonce"): shutil.move("resources/restoreFiles/igetnonce", "igetnonce") if os.path.exists("resources/restoreFiles/tsschecker"): shutil.move("resources/restoreFiles/tsschecker", "tsschecker") if os.path.exists("resources/restoreFiles/futurerestore"): shutil.move("resources/restoreFiles/futurerestore", "futurerestore") if os.path.exists("resources/restoreFiles/irecovery"): shutil.move("resources/restoreFiles/irecovery", "irecovery") print("IPSW found at given path...") print("Cleaning up old files...") removeFiles() print("Unzipping..") with ZipFile(fname, 'r') as zip_ref: zip_ref.extractall(outputFolder) source = ("Firmware/dfu/") dest1 = os.getcwd() files = os.listdir(source) for f in files: shutil.move(source + f, dest1) devicemodel = str(localdevice.getmodel()) t = localdevice.pick3264(devicemodel, fname) if t == 32: createCustomIPSW32(fname) elif t == 64: pwndfumode() createCustomIPSW64(fname, devicemodel) else: exit(2) else: print('\033[91m' + "ERROR: Not valid filepath...") print("ERROR: Try again" + '\033[0m')
def unzipIPSW(fname): armv7 = ['iPhone4,1'] armv7s = ['iPhone5,1', 'iPhone5,2'] if is_zipfile(fname): # First of all, check to see if fname is an actual ipsw, by verifying the file is a zip archive (ipsw's are just zip files). print(f'{fname} is a zip archive!') else: sys.exit(f'{fname} is not a zip archive! Are you sure you inserted the correct ipsw path?') if os.path.exists("custom.ipsw"): os.remove("custom.ipsw") print("Starting IPSW unzipping") outputFolder = "IPSW" newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) if os.path.exists('IPSW'): shutil.rmtree('IPSW') os.mkdir('IPSW') elif not os.path.exists('IPSW'): os.mkdir('IPSW') while not testFile or not fname.endswith!=(".ipsw"): print("Invalid filepath/filename.\nPlease try again with a valid filepath/filename.") fname = input("Enter the path to the IPSW file (Or drag and drop the IPSW into this window):\n") newpath = fname.rstrip() fname = str(newpath) testFile = os.path.exists(fname) else: print("Continuing...") if testFile and fname.endswith(".ipsw"): if os.path.exists("resources/bin/igetnonce"): shutil.move("resources/bin/igetnonce", "igetnonce") if os.path.exists("resources/bin/tsschecker"): shutil.move("resources/bin/tsschecker", "tsschecker") if os.path.exists("resources/bin/futurerestore"): shutil.move("resources/bin/futurerestore", "futurerestore") if os.path.exists("resources/bin/irecovery"): shutil.move("resources/bin/irecovery", "irecovery") print("IPSW found at given path...") print("Cleaning up old files...") removeFiles() print("Unzipping..") with ZipFile(fname, 'r') as zip_ref: zip_ref.extractall(outputFolder) source = ("IPSW/Firmware/dfu/") dest1 = os.getcwd() files = os.listdir(source) for f in files: shutil.move(source + f, dest1) devicemodel = str(localdevice.getmodel()) version = False supportedModels = str(readmanifest("IPSW/BuildManifest.plist", version)) if supportedModels in armv7: createCustomIPSW32(fname) else: if supportedModels in armv7s: createCustomIPSW32(fname) else: arm64check = ('iPhone6,1', 'iPhone6,2', 'iPad4,1', 'iPad4,2', 'iPad4,3', 'iPad4,4', 'iPad4,5') if any(ext in supportedModels for ext in arm64check): if any(ext in devicemodel for ext in arm64check): pwndfumode() createCustomIPSW64(fname, devicemodel) else: print("ERROR: Unsupported model...\nExiting...") exit(82) else: print("ERROR: Unsupported model...\nExiting...") exit(82) else: print('\033[91m' + "ERROR: Not valid filepath...") print("ERROR: Try again" + '\033[0m')