#!/usr/bin/env bash ipsw_openssh=1 # OpenSSH will be added to jailbreak/custom IPSW if set to 1. device_rd_build="" # You can change the version of SSH Ramdisk and Pwned iBSS/iBEC here. (default is 10B329 for most devices) jelbrek="../resources/jailbreak" ssh_port=6414 bash_test=$(echo -n 0) (( bash_test += 1 )) if [ "$bash_test" != "1" ] || [ -z $BASH_VERSION ]; then echo "[Error] Detected that script is not running with bash on runtime. Please run the script properly using bash." exit 1 fi bash_ver=$(/usr/bin/env bash -c 'echo ${BASH_VERSINFO[0]}') if (( bash_ver > 3 )); then shopt -s compat32 fi 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}" echo print "* Save the terminal output now if needed. (macOS: Cmd+S, Linux: Ctrl+Shift+S)" if [[ -n $version_current && -n $git_hash ]]; then print "* Legacy iOS Kit $version_current ($git_hash)" else print "* Legacy iOS Kit" fi if [[ -n $platform ]]; then print "* Platform: $platform ($platform_ver - $platform_arch) $live_cdusb_str" fi exit 1 } pause() { input "Press Enter/Return to continue (or press Ctrl+C to cancel)" read -s } clean() { kill $httpserver_pid $iproxy_pid $anisette_pid 2>/dev/null popd &>/dev/null rm -rf "$(dirname "$0")/tmp$$/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp$$/" 2>/dev/null if [[ $platform == "macos" && $(ls "$(dirname "$0")" | grep -v tmp$$ | grep -c tmp) == 0 ]]; then # ill disable this for now since finder is annoying, ill just keep them in a stopped state. : killall -CONT AMPDevicesAgent AMPDeviceDiscoveryAgent MobileDeviceUpdater fi } clean_sudo() { clean sudo rm -rf /tmp/futurerestore /tmp/*.json "$(dirname "$0")/tmp$$/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp$$/" sudo kill $sudoloop_pid } clean_usbmuxd() { clean_sudo if [[ $(ls "$(dirname "$0")" | grep -v tmp$$ | grep -c tmp) != 0 ]]; then return fi sudo killall -9 usbmuxd usbmuxd2 2>/dev/null if [[ $(command -v systemctl) ]]; then sudo systemctl restart usbmuxd elif [[ $(command -v rc-service) ]]; then sudo rc-service usbmuxd start fi } display_help() { echo ' *** Legacy iOS Kit *** - Script by LukeZGD - Usage: ./restore.sh [Options] List of options: --debug For script debugging (set -x and debug mode) --device= Specify device type --dfuhelper Launch to DFU Mode Helper only --disable-sudoloop Disable running tools as root for Linux --ecid= Specify device ECID --entry-device Enable manual device type and ECID entry --exit-recovery Attempt to exit recovery mode --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 --pwn Pwn the connected device --sshrd Enter SSH ramdisk mode (requires additional arguments) --sshrd-menu Re-enter SSH ramdisk menu (device must be in SSH ramdisk mode) For 32-bit devices compatible with restores/downgrades (see README): --activation-records Enable dumping/stitching activation records --dead-bb Disable bbupdate completely without dumping/stitching baseband --disable-bbupdate Disable bbupdate and enable dumping/stitching baseband --gasgauge-patch Enable multipatch to get past "gas gauge" error (aka error 29 in iTunes) --ipsw-hacktivate Enable hacktivation for creating IPSW (iPhone 2G/3G/3GS only) --ipsw-verbose Enable verbose boot option (3GS and powdersn0w only) --jailbreak Enable jailbreak option --just-boot Tether boot the device (requires additional arguments) --memory Enable memory option for creating IPSW --pwned-recovery Assume that device is in pwned recovery mode (experimental) --skip-first Skip first restore and flash NOR IPSW only for powdersn0w 4.2.x and lower --skip-ibss Assume that pwned iBSS has already been sent to the device For 64-bit checkm8 devices compatible with pwned restores: --skip-blob Enable futurerestore skip blob option for OTA/onboard/factory blobs --use-pwndfu Enable futurerestore pwned restore option * Default IPSW path: