#!/usr/bin/env bash device_disable_bbupdate="iPad2,3" # Disable baseband update for this device. You can also change this to your device if needed. ipsw_openssh=1 # If this value is 1, OpenSSH will be added to custom IPSW. (8.4.1 daibutsu and 6.1.3 p0sixspwn only) print() { echo "${color_B}${1}${color_N}" } input() { echo "${color_Y}[Input] ${1}${color_N}" } log() { echo "${color_G}[Log] ${1}${color_N}" } warn() { echo "${color_Y}[WARNING] ${1}${color_N}" } error() { echo -e "${color_R}[Error] ${1}\n${color_Y}${*:2}${color_N}" clean_and_exit 1 } pause() { input "Press Enter/Return to continue (or press Ctrl+C to cancel)" read -s } clean() { rm -rf "$(dirname "$0")/tmp/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp/" if [[ $device_sudoloop == 1 ]]; then sudo rm -rf /tmp/futurerestore /tmp/*.json "$(dirname "$0")/tmp/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp/" fi } clean_and_exit() { if [[ $platform == "windows" ]]; then input "Press Enter/Return to exit." read -s fi clean kill $iproxy_pid $httpserver_pid $sudoloop_pid 2>/dev/null exit $1 } bash_version=$(/usr/bin/env bash -c 'echo ${BASH_VERSINFO[0]}') if (( bash_version < 5 )); then error "Your bash version ($bash_version) is too old. Install a newer version of bash to continue." \ "* For macOS users, install bash, libimobiledevice, and libirecovery from Homebrew or MacPorts" \ $'\n* For Homebrew: brew install bash libimobiledevice libirecovery' \ $'\n* For MacPorts: sudo port install bash libimobiledevice libirecovery' fi display_help() { echo '******* iOS-OTA-Downgrader ******* - Downgrader script by LukeZGD - Usage: ./restore.sh [Options] NOTE: CLI implementation is NOT COMPLETE (yet) List of options: --debug For script debugging (set -x and debug mode) --device-ecid [ECID] Provide device ECID (must be decimal) --device-type [Type] Provide device type (eg. iPad2,1) --entry-device Enable manual device and ECID entry --help Display this help message --no-color Disable colors for script output --no-device Enable no device mode --no-version-check Disable script version checking --sudoloop Run some tools as root for device detection For 32-bit devices: --kdfu Place device in kDFU mode For devices compatible with downgrades (see README): --custom-ipsw [version] Create custom IPSW for provided iOS version --downgrade [version] Downgrade/Restore to provided iOS version --ipsw [IPSW path] Set path to IPSW --ipsw-verbose Enable verbose boot option (iPhone 4 only) --jailbreak Enable jailbreak option --memory Enable memory option for creating IPSW --save-blobs [version] Save OTA blobs for provided iOS version --shsh [SHSH path] Set path to SHSH * For jailbreak option on 8.4.1, also provide [jailbreak] (etasonjb | daibutsu) * For "Other" downgrades with SHSH, provide "Other" without quotes as version * Default IPSW path: