Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set_tool_paths
- if [[ $no_internet_check != 1 ]]; then
- log "Checking Internet connection..."
- local try=("google.com" "www.apple.com" "208.67.222.222")
- local check
- local timeout="-w3"
- [[ $platform == "macos" ]] && timeout="-t3"
- for i in "${try[@]}"; do
- ping -c1 $timeout $i | sed -n '1,2p'
- check=${PIPESTATUS[0]}
- if [[ $check == 0 ]]; then
- break
- fi
- done
- if [[ $check != 0 ]]; then
- error "Please check your Internet connection before proceeding."
- fi
- fi
- local checks=(curl git xxd)
- local check_fail
- for check in "${checks[@]}"; do
- if [[ $debug_mode == 1 ]]; then
- log "Checking for $check in PATH"
- fi
- if [[ ! $(command -v $check) ]]; then
- warn "$check not found in PATH"
- check_fail=1
- fi
- done
- if [[ -z $unzip2 || -z $zip2 ]]; then
- warn "unzip/zip not found in PATH"
- check_fail=1
- fi
- if [[ -s ../resources/firstrun ]]; then
- mv ../resources/firstrun ../saved/
- fi
- if [[ ! -s ../saved/firstrun || $(cat ../saved/firstrun) != "$platform_ver" || $check_fail == 1 ]]; then
- install_depends
- fi
- version_check
- device_get_info
- mkdir -p ../saved/baseband ../saved/$device_type ../saved/shsh
- mode=
- if [[ -n $main_argmode ]]; then
- mode="$main_argmode"
- else
- menu_main
- fi
- case $mode in
- "custom-ipsw" )
- ipsw_preference_set
- restore_deviceprepare
- ipsw_prepare
- log "Done creating custom IPSW"
- ;;
- "downgrade" )
- ipsw_preference_set
- restore_deviceprepare
- ipsw_prepare
- restore_prepare
- ;;
- "baseband" )
- device_dump baseband
- log "Baseband dumping is done"
- print "* To stitch baseband to IPSW, run Legacy iOS Kit with --disable-bbupdate flag:"
- print " > ./restore.sh --disable-bbupdate"
- ;;
- "actrec" )
- device_dump activation
- log "Activation records dumping is done"
- print "* The output tar file contains the plist file(s) dumped. Activation record plist is all you need for activation"
- print "* Note: Using the activation records only works on iOS 9.2.1 or lower. It will not work on iOS 9.3+"
- if (( device_proc < 7 )); then
- print "* To stitch activation to IPSW, run Legacy iOS Kit with --activation-records flag:"
- print " > ./restore.sh --activation-records"
- fi
- ;;
- "restore-update" ) restore_latest update;;
- "kdfu" ) device_enter_mode kDFU;;
- "ramdisknvram" ) device_ramdisk clearnvram;;
- "pwned-ibss" ) device_enter_mode pwnDFU;;
- "enterrecovery") device_enter_mode Recovery;;
- "exitrecovery" )
- log "Attempting to exit Recovery mode."
- $irecovery -n
- if [[ $device_proc != 1 && $device_type != "iPod2,1" ]] && (( device_proc < 7 )); then
- print "* Note: For tethered downgrades, you need to boot your device using the Just Boot option. Exiting recovery mode will not work."
- fi
- if [[ $device_canpowder == 1 ]]; then
- print "* Note 2: If your device is stuck in recovery mode, it may have been restored with powdersn0w before."
- print " - If so, try to clear the device's NVRAM: go to Useful Utilities -> Clear NVRAM"
- fi
- ;;
- "customipsw" ) restore_customipsw;;
- "getversion" ) device_enter_ramdisk getversion;;
- "shutdown" ) device_pair; $idevicediagnostics shutdown;;
- "restart" ) device_pair; $idevicediagnostics restart;;
- "remove4" ) device_ramdisk setnvram $rec;;
- "device_dfuhelper" )
- if [[ $device_proc == 1 ]]; then
- device_dfuhelper norec WTFreal
- else
- device_dfuhelper
- fi
- ;;
- "device"* | "shsh"* ) $mode;;
- * ) :;;
- esac
- }
- for i in "$@"; do
- case $i in
- # general options
- "--debug" ) set -x; debug_mode=1; menu_old=1;;
- "--disable-usbmuxd" ) device_disable_usbmuxd=1;;
- "--enable-sudoloop" ) device_disable_sudoloop=;;
- "--help" ) display_help; exit;;
- "--no-color" ) no_color=1;;
- "--no-finder" ) no_finder=1;;
- "--old-menu" ) menu_old=1;;
- "--use-usbmuxd2" ) use_usbmuxd2=1;;
- # options for 32-bit devices
- "--activation-records") device_actrec=1;;
- "--build-id="* ) device_rd_build="${i#*=}";;
- "--bootargs="* ) device_bootargs="${i#*=}";;
- "--dead-bb" ) device_deadbb=1; device_disable_bbupdate=1;;
- "--disable-actrec" ) device_disable_actrec=1;;
- "--disable-bbupdate") device_disable_bbupdate=1;;
- "--ipsw-hacktivate" ) ipsw_hacktivate=1;;
- "--ipsw-verbose" ) ipsw_verbose=1;;
- "--jailbreak" ) ipsw_jailbreak=1;;
- "--gasgauge-patch" | "--multipatch") ipsw_gasgauge_patch=1;;
- "--memory" ) ipsw_memory=1;;
- "--pwned-recovery" ) device_pwnrec=1;;
- "--ra1n-timeout="* ) device_ra1n_timeout="${i#*=}";;
- "--skip-first" ) ipsw_skip_first=1;;
- "--skip-ibss" ) device_skip_ibss=1;;
- # options for 64-bit devices
- "--skip-blob" ) restore_useskipblob=1;;
- "--use-dev" ) restore_usedev=1;;
- "--use-pwndfu" ) restore_usepwndfu64=1;;
- # device_argmode setters
- "--entry-device" ) device_argmode="entry";;
- "--no-device" ) device_argmode="none";;
- # entry parameters
- "--device="* ) device_type="${i#*=}";;
- "--ecid="* ) device_ecid="${i#*=}";;
- # main_argmode setters
- "--dfuhelper" ) main_argmode="device_dfuhelper";;
- "--exit-recovery" ) main_argmode="exitrecovery";;
- "--just-boot" ) main_argmode="device_justboot";;
- "--kdfu" ) main_argmode="kdfu";;
- "--pwn" ) main_argmode="pwned-ibss";;
- "--sshrd" ) main_argmode="device_enter_ramdisk";;
- "--sshrd-menu" ) device_argmode="entry"; main_argmode="device_enter_ramdisk_menu";;
- # please dont use these, unless you know what youre doing
- "--no-internet-check") no_internet_check=1;;
- "--no-version-check" ) no_version_check=1;;
- "--run-as-root" ) run_as_root=1;;
- esac
- done
- if [[ $no_color != 1 ]]; then
- TERM=xterm-256color # fix colors for msys2 terminal
- color_R=$(tput setaf 9)
- color_G=$(tput setaf 10)
- color_B=$(tput setaf 12)
- color_Y=$(tput setaf 208)
- color_N=$(tput sgr0)
- fi
- if [[ $main_argmode == "device_justboot" && -z $device_rd_build ]]; then
- print "* Just Boot usage: --just-boot --build-id=<id>"
- print "* Optional: --device=<type> --bootargs=\"<bootargs>\""
- print "* Example usage: ./restore.sh --just-boot --build-id=12H321"
- error "Just Boot (--just-boot) requires specifying build ID (--build-id=<id>)"
- elif [[ $main_argmode == "device_justboot" && $device_type == "iPod4,1" && $device_rd_build == "11D257" ]]; then
- main_argmode="device_justboot_touch4ios7"
- fi
- trap "clean" EXIT
- trap "exit 1" INT TERM
- othertmp=$(ls "$(dirname "$0")" | grep -c tmp)
- if [[ $othertmp != 0 ]]; then
- noclean=1
- log "Detected existing tmp folder(s)."
- print "* There might be other Legacy iOS Kit instance(s) running, or residual tmp folder(s) not deleted."
- print "* Running multiple instances is not fully supported and can cause unexpected behavior."
- print "* It is recommended to only use a single instance and/or delete all existing \"tmp\" folders in your Legacy iOS Kit folder before continuing."
- select_yesno "Select Y to remove all tmp folders, N to run as is" 1
- if [[ $? == 1 ]]; then
- noclean=
- rm -r "$(dirname "$0")/tmp"*
- clean
- fi
- else
- clean
- fi
- othertmp=$(ls "$(dirname "$0")" | grep -c tmp)
- mkdir -p "$(dirname "$0")/tmp$$"
- pushd "$(dirname "$0")/tmp$$" >/dev/null
- mkdir -p ../saved
- main
- popd >/dev/null
Advertisement