ipsw.fetch_ipsw_bm(args.ipsw[0], is_verbose) else: sys.exit(parser.print_help(sys.stderr)) utils.log(f'[VERBOSE] Verifying device {device_identifier} exists...', is_verbose) ipsw.verify_device(device_identifier, is_verbose) utils.log(f'[VERBOSE] Verifying iOS {args.version[0]} exists for device {device_identifier}...', is_verbose) ipsw.verify_version(device_identifier, args.version[0], is_verbose) utils.log(f'[INFO] iOS Version: {args.version[0]}', False) if not utils.check_internet(): sys.exit('[ERROR] You are not connected to the Internet. Connect to the internet, then run this script again.\nExiting...') utils.log(f'[VERBOSE] Finding Firmware Bundle for {device_identifier}, {args.version[0]}', is_verbose) firmware_bundle = ipsw.find_bundle(device_identifier, args.version[0], is_verbose) if args.version[0] == '10.1.1' or args.version[0] == '10.1.1': utils.log(f'[VERBOSE] Finding proper buildid for version {args.version[0]}', is_verbose) buildid = ipsw.check_buildid(firmware_bundle) utils.log('[VERBOSE] Checking if device is A9...', is_verbose) if ipsw.is_a9(firmware_bundle): utils.log('[VERBOSE] Device is A9, fetching correct board config...', is_verbose) board_configs = ipsw.fetch_boardconfig(firmware_bundle) if len(board_configs) != 2: utils.log('[ERROR] Firmware Bundle is invalid.\nExiting...', True) sys.exit() firm_bundle_number = input(f'A9 device detected, please choose the number of the correct board config for your device:\n [1] {board_configs[0]}ap\n [2] {board_configs[1]}ap\nChoice: ')
if version_str.startswith('10.'): sys.exit('Error: iOS 10.x IPSWs are not currently supported!\nExiting...') else: sys.exit('Error: You must specify an iOS version!\nExiting...') if args.verbose: print('[VERBOSE] Checking for required dependencies...') ldid_check = subprocess.Popen('/usr/bin/which ldid2', stdout=subprocess.PIPE, shell=True) # Dependency checking time.sleep(5) output = str(ldid_check.stdout.read()) if len(output) == 3: sys.exit('Error: ldid not installed! Please install ldid from Homebrew, then run this script again.') if os.path.exists(f'work'): # In case work directory is still here from a previous run, remove it shutil.rmtree(f'work') print(f'Finding Firmware bundle for {args.device[0]}, {args.version[0]}...') if args.verbose: firmware_bundle = ipsw.find_bundle(args.device[0], args.version[0], 'yes') else: firmware_bundle = ipsw.find_bundle(args.device[0], args.version[0]) if args.verbose: print('[VERBOSE] Checking if device is A9...') is_a9 = ipsw.a9_check(firmware_bundle) if is_a9: if args.verbose: print('[VERBOSE] Device is A9, fetching correct board config...') board_configs = ipsw.fetch_a9_boardconfigs(firmware_bundle) if len(board_configs) != 2: sys.exit('Firmware Bundle for A9 is invalid.\nExiting...') firm_bundle_number = input(f'A9 device detected, please choose the correct board config for your device:\n[1] {board_configs[0]}ap\n[2] {board_configs[1]}ap\nChoice: ') try: int(firm_bundle_number) except ValueError:
def main(): if args.ipsw: if args.device: pass else: sys.exit( 'Error: You must specify a device identifier!\nExiting...') if args.version: version_str = args.version[0] if version_str.startswith('10.'): sys.exit( 'Error: iOS 10.x IPSWs are not currently supported!\nExiting...' ) else: sys.exit('Error: You must specify an iOS version!\nExiting...') if args.verbose: print('[VERBOSE] Checking for required dependencies...') ldid_check = subprocess.Popen('/usr/bin/which ldid2', stdout=subprocess.PIPE, shell=True) # Dependency checking time.sleep(5) output = str(ldid_check.stdout.read()) if len(output) == 3: sys.exit( 'Error: ldid not installed! Please install ldid from Homebrew, then run this script again.' ) if os.path.exists( f'work' ): # In case work directory is still here from a previous run, remove it shutil.rmtree(f'work') print( f'Finding Firmware bundle for {args.device[0]}, {args.version[0]}...' ) if args.verbose: firmware_bundle = ipsw.find_bundle(args.device[0], args.version[0], 'yes') else: firmware_bundle = ipsw.find_bundle(args.device[0], args.version[0]) if args.verbose: print('[VERBOSE] Checking if device is A9...') is_a9 = ipsw.a9_check(firmware_bundle) if is_a9: if args.verbose: print( '[VERBOSE] Device is A9, fetching correct board config...') board_configs = ipsw.fetch_a9_boardconfigs(firmware_bundle) if len(board_configs) != 2: sys.exit('Firmware Bundle for A9 is invalid.\nExiting...') firm_bundle_number = input( f'A9 device detected, please choose the correct board config for your device:\n[1] {board_configs[0]}ap\n[2] {board_configs[1]}ap\nChoice: ' ) try: int(firm_bundle_number) except ValueError: sys.exit('Input not a number!.\nExiting...') firm_bundle_number = int(firm_bundle_number) if 0 < firm_bundle_number < 3: firm_bundle_number = firm_bundle_number - 1 pass else: sys.exit('Invalid input given.\nExiting...') else: firm_bundle_number = 1337 if args.verbose: print('[VERBOSE] Device is not A9, continuing...') if args.verbose: ipsw.extract_ipsw(args.ipsw[0], 'yes') else: ipsw.extract_ipsw(args.ipsw[0]) print('IPSW extracted! Verifying bootchain...') if args.verbose: ipsw.verify_bootchain(firmware_bundle, firm_bundle_number, 'yes') else: ipsw.verify_bootchain(firmware_bundle, firm_bundle_number) print('Bootchain verified! Patching bootchain...') if args.verbose: patch.patch_bootchain(firmware_bundle, firm_bundle_number, 'yes') else: patch.patch_bootchain(firmware_bundle, firm_bundle_number) print('Grabbing latest LLB and iBoot to put into custom IPSW...') ipsw.grab_latest_llb_iboot(args.device[0], firmware_bundle, firm_bundle_number) print( 'Packing everything into custom IPSW. This may take a while, please wait...' ) if args.verbose: ipsw_name = ipsw.make_ipsw(firmware_bundle, 'yes') else: ipsw_name = ipsw.make_ipsw(firmware_bundle) print(f'Done!\nCustom IPSW at: {ipsw_name}') print('Cleaning up...') shutil.rmtree('work') else: exit(parser.print_help(sys.stderr))