예제 #1
0
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)
예제 #2
0
        ibss_path, ibec_path = ipsw.extract_ibss_ibec(args.ipsw[0],
                                                      firmware_bundle,
                                                      firm_bundle_number,
                                                      'yes')
    else:
        ibss_path, ibec_path = ipsw.extract_ibss_ibec(args.ipsw[0],
                                                      firmware_bundle,
                                                      firm_bundle_number)
    print('Signing iBSS and iBEC with SHSH blob...')
    if args.verbose:
        patch.sign_ibss_ibec(ibss_path, ibec_path, 'yes')
    else:
        patch.sign_ibss_ibec(ibss_path, ibec_path)
    processor = ipsw.fetch_processor(firmware_bundle)
    print('Preparations done! Beginning restore...')
    if args.verbose:
        restore.send_ibss_ibec(processor, 'yes')
    else:
        restore.send_ibss_ibec(processor)
    if args.verbose:
        restore.restore(args.ipsw[0], restore.is_cellular(args.device[0]),
                        keep_data, 'yes')
    else:
        restore.restore(args.ipsw[0], restore.is_cellular(args.device[0]),
                        keep_data)
    print('Restore finished! Cleaning up...')
    shutil.rmtree('work')
    print('Done.')
else:
    exit(parser.print_help(sys.stderr))