def create_ipsw(): utils.log('Verifying IPSW. This may take a while, please wait...', True) is_stock = ipsw.verify_ipsw(device_identifier, args.version[0], args.ipsw[0], buildid, is_verbose) if not is_stock: sys.exit( f'[ERROR] IPSW {args.ipsw[0]} is not verified! Redownload your IPSW, and try again.\nExiting...' ) utils.log('IPSW verified! Extracting IPSW...', True) ipsw.extract_ipsw(args.ipsw[0], is_verbose) utils.log('IPSW extracted! Patching bootchain...', True) patch.patch_bootchain(firmware_bundle, firm_bundle_number, buildid, is_verbose) utils.log( 'Bootchain patched! Grabbing latest LLB and iBoot to put into custom IPSW...', True) ipsw.grab_latest_llb_iboot(device_identifier, args.version[0], firmware_bundle, firm_bundle_number, is_verbose) utils.log( 'Packing everything into custom IPSW. This may take a while, please wait...', True) ipsw_name = ipsw.make_ipsw(firmware_bundle, is_verbose) utils.log(f'Done!\nCustom IPSW at: {ipsw_name}', True) if not args.restore: utils.cleanup(True) return ipsw_name
def restore_ipsw(fresh_ipsw, ipsw_path): processor = ipsw.fetch_processor(firmware_bundle) if fresh_ipsw: utils.log('------------RESTORE-BEGINNING------------', False) utils.log('Restoring freshly created custom IPSW', is_verbose) else: utils.log('Inferius Restore Log', False) utils.log('Checking if IPSW is custom...', False) is_stock = ipsw.verify_ipsw(device_identifier, args.version[0], ipsw_path, buildid, is_verbose) if is_stock: utils.log('[ERROR] IPSW is stock!\nExiting...', False) sys.exit() if args.update: keep_data = True else: keep_data = False device_check = input('Is your device is connected in Pwned DFU mode with signature checks removed? [Y/N]: ') utils.log(f'Is your device is connected in Pwned DFU mode with signature checks removed? [Y/N]: {device_check}', False) if not 'y' in device_check.lower(): utils.log('[ERROR] Specified device is not in pwndfu!\nExiting...', is_verbose) sys.exit() lsusb = subprocess.run('./resources/bin/lsusb', stdout=subprocess.PIPE, universal_newlines=True, shell=True) utils.log(lsusb.stdout, False) if not 'Apple Mobile Device (DFU Mode)' in lsusb.stdout: utils.log('[ERROR] Specified device is not in pwndfu!\nExiting...', is_verbose) sys.exit() os.makedirs('work/ipsw', exist_ok=True) utils.log('Fetching some required info...', True) restore.save_blobs(device_identifier, firm_bundle_number, board_configs, downgrade_10, is_verbose) utils.log('Extracting iBSS and iBEC from custom IPSW...', True) ibss_path, ibec_path = ipsw.extract_bootchain(ipsw_path, firmware_bundle, firm_bundle_number, is_verbose) utils.log('Signing iBSS and iBEC with SHSH blob...', True) restore.sign_bootchain(ibss_path, ibec_path, is_verbose) utils.log('Preparations done! Beginning restore...', True) if downgrade_10: ipsw.fetch_1033_sepbb(device_identifier, args.version[0], is_verbose) restore.send_bootchain(processor, is_verbose) futurerestore = restore.restore(ipsw_path, ipsw.is_cellular(device_identifier), keep_data, downgrade_10, is_verbose) if not futurerestore: sys.exit() else: utils.cleanup(True) utils.log('Done.\nExiting...', True)