Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- menu_restore_more() {
- local menu_items
- local selected
- local back
- while [[ -z "$mode" && -z "$back" ]]; do
- menu_items=()
- case $device_type in
- iPhone2,1 )
- menu_items+=("6.1.3" "6.1.2" "6.1" "6.0.1" "6.0" "5.1" "5.0.1" "5.0")
- menu_items+=("4.3.4" "4.3.3" "4.3.2" "4.3.1" "4.3" "4.2.1")
- menu_items+=("4.0.2" "4.0.1" "4.0" "3.1.2" "3.1" "3.0.1" "3.0")
- ;;
- iPod2,1 ) menu_items+=("4.0.2" "4.0" "3.1.2" "3.1.1");;
- esac
- menu_items+=("Go Back")
- menu_print_info
- if [[ $1 == "ipsw" ]]; then
- print " > Main Menu > Misc Utilities > Create Custom IPSW"
- else
- print " > Main Menu > Restore/Downgrade"
- fi
- if [[ $device_type == "iPhone2,1" ]]; then
- warn "3.1.x versions listed here might not restore properly"
- if [[ $device_newbr != 0 && $device_mode != "none" ]]; then
- print "* 3.0.x versions are not restorable on new bootrom devices"
- menu_items=("${menu_items[@]::${#menu_items[@]}-3}")
- menu_items+=("Go Back")
- fi
- echo
- fi
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "" ) :;;
- "Go Back" ) back=1;;
- * ) menu_ipsw "$selected" "$1";;
- esac
- done
- }
- ipsw_latest_set() {
- local newpath
- case $device_type in
- iPad3,[456] ) ipsw_prefix="iPad_32bit";;
- iPad4,[123456] ) ipsw_prefix="iPad_64bit";;
- iPad6,[34] ) ipsw_prefix="iPadPro_9.7";;
- iPad6,[78] ) ipsw_prefix="iPadPro_12.9";;
- iPad7,[12] ) ipsw_prefix="iPad_Pro_HFR";;
- iPad7,1[12] ) ipsw_prefix="iPad_10.2";;
- iPhone5,[1234] ) ipsw_prefix="iPhone_4.0_32bit";;
- iPhone10,[36] ) ipsw_prefix="iPhone10,3,iPhone10,6";;
- iPhone11,[246] ) ipsw_prefix="iPhone11,2,iPhone11,4,iPhone11,6";;
- iPod[79],1 ) ipsw_prefix="iPodtouch";;
- iPad4,[789] | iPad5,* ) ipsw_prefix="iPad_64bit_TouchID";;
- iPad6,1[12] | iPad7,[56] ) ipsw_prefix="iPad_64bit_TouchID_ASTC";;
- iPhone6,[12] | iPhone8,4 ) ipsw_prefix="iPhone_4.0_64bit";;
- iPhone7,1 | iPhone8,2 ) ipsw_prefix="iPhone_5.5";;
- iPhone7,2 | iPhone8,1 ) ipsw_prefix="iPhone_4.7";;
- iPhone9,[13] | iPhone10,[14] ) ipsw_prefix="iPhone_4.7_P3";;
- iPhone9,[24] | iPhone10,[25] ) ipsw_prefix="iPhone_5.5_P3";;
- * ) ipsw_prefix="${device_type}";;
- esac
- newpath="$ipsw_prefix"
- newpath+="_${device_latest_vers}_${device_latest_build}"
- ipsw_custom_set $newpath
- ipsw_dfuipsw="../${newpath}_DFUIPSW"
- newpath+="_Restore"
- ipsw_latest_path="$newpath"
- }
- ipsw_hwmodel_set() {
- local hwmodel
- case $device_type in
- iPhone5,[12] ) hwmodel="iphone5";;
- iPhone5,[34] ) hwmodel="iphone5b";;
- iPad3,[456] ) hwmodel="ipad3b";;
- iPhone6,* ) hwmodel="iphone6";;
- iPhone7,* ) hwmodel="iphone7";;
- iPhone8,4 ) hwmodel="iphone8b";;
- iPhone8,* ) hwmodel="iphone8";;
- iPhone9,* ) hwmodel="iphone9";;
- iPad4,[123] ) hwmodel="ipad4";;
- iPad4,[456] ) hwmodel="ipad4b";;
- iPad4,[789] ) hwmodel="ipad4bm";;
- iPad5,[12] ) hwmodel="ipad5";;
- iPad5,[34] ) hwmodel="ipad5b";;
- iPad6,[34] ) hwmodel="ipad6b";;
- iPad6,[78] ) hwmodel="ipad6d";;
- * ) hwmodel="$device_model";;
- esac
- ipsw_hwmodel="$hwmodel"
- }
- menu_ipsw() {
- local menu_items
- local selected
- local back
- local newpath
- local nav
- local start="(*) "
- local can_start
- if [[ $2 == "ipsw" ]]; then
- nav=" > Main Menu > Misc Utilities > Create Custom IPSW > $1"
- start+="Create IPSW"
- elif [[ $2 == "fourthree" ]]; then
- nav=" > Main Menu > FourThree Utility > Step 1: Restore"
- start+="Start Restore"
- elif [[ $1 == "Set Nonce Only" ]]; then
- nav=" > Main Menu > Restore/Downgrade > $1"
- start+="Set Nonce"
- device_target_setnonce=1
- else
- nav=" > Main Menu > Restore/Downgrade > $1"
- start+="Start Restore"
- fi
- while [[ -z "$mode" && -z "$back" ]]; do
- case $1 in
- "iOS 10.3.3" )
- device_target_vers="10.3.3"
- device_target_build="14G60"
- ;;
- "iOS 8.4.1" )
- device_target_vers="8.4.1"
- device_target_build="12H321"
- ;;
- "iOS 6.1.3" )
- device_target_vers="6.1.3"
- device_target_build="10B329"
- ;;
- "iOS 4.1" )
- device_target_vers="4.1"
- device_target_build="8B117"
- ;;
- "Latest iOS"* )
- device_target_vers="$device_latest_vers"
- device_target_build="$device_latest_build"
- case $device_latest_vers in
- [643]* ) ipsw_canhacktivate=1;;
- esac
- ;;
- [6543]* )
- device_target_vers="$1"
- if [[ $device_target_vers != "3.0"* ]]; then
- ipsw_canhacktivate=1
- fi
- if [[ $device_type == "iPhone2,1" && $1 != "4.1" ]]; then
- ipsw_cancustomlogo=1
- fi
- if [[ $device_type == "iPod2,1" && $device_newbr == 0 ]] &&
- [[ $1 == "4.0"* || $1 == "3.1"* ]]; then
- ipsw_cancustomlogo=1
- ipsw_24o=1
- fi
- if [[ $device_type == "iPod2,1" && $device_mode == "none" && $1 != "3.1.3" ]] &&
- [[ $1 == "4.0"* || $1 == "3.1"* ]]; then
- ipsw_cancustomlogo=1
- ipsw_24o=1
- fi
- ;;
- esac
- target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
- target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
- if [[ $device_type != "iPhone"* ]]; then
- ipsw_canhacktivate=
- fi
- if [[ $device_proc == 1 ]]; then
- ipsw_cancustomlogo=1
- fi
- case $1 in
- "6.1.3" ) device_target_build="10B329";;
- "6.1.2" ) device_target_build="10B146";;
- "6.1" ) device_target_build="10B141";;
- "6.0.1" ) device_target_build="10A523";;
- "6.0" ) device_target_build="10A403";;
- "5.1.1" ) device_target_build="9B206";;
- "5.1" ) device_target_build="9B176";;
- "5.0.1" ) device_target_build="9A405";;
- "5.0" ) device_target_build="9A334";;
- "4.3.5" ) device_target_build="8L1";;
- "4.3.4" ) device_target_build="8K2";;
- "4.3.3" ) device_target_build="8J2";;
- "4.3.2" ) device_target_build="8H7";;
- "4.3.1" ) device_target_build="8G4";;
- "4.3" ) device_target_build="8F190";;
- "4.2.1" )
- device_target_build="8C148"
- if [[ $device_type == "iPhone2,1" ]]; then
- device_target_build+="a"
- fi
- ;;
- "4.1" ) device_target_build="8B117";;
- "4.0.2" ) device_target_build="8A400";;
- "4.0.1" ) device_target_build="8A306";;
- "4.0" ) device_target_build="8A293";;
- "3.1.3" ) device_target_build="7E18";;
- "3.1.2" ) device_target_build="7D11";;
- "3.1.1" ) device_target_build="7C145";;
- "3.1" ) device_target_build="7C144";;
- "3.0.1" ) device_target_build="7A400";;
- "3.0" ) device_target_build="7A341";;
- esac
- ipsw_latest_set
- if [[ $device_target_vers == "$device_latest_vers" ]]; then
- newpath="$ipsw_latest_path"
- else
- case $device_type in
- iPad4,[12345] ) newpath="iPad_64bit";;
- iPhone6,[12] ) newpath="iPhone_4.0_64bit";;
- * ) newpath="${device_type}";;
- esac
- newpath+="_${device_target_vers}_${device_target_build}"
- ipsw_custom_set $newpath
- newpath+="_Restore"
- fi
- if [[ $1 == "Other (Use SHSH Blobs)" || $1 == "Set Nonce Only" ]]; then
- device_target_other=1
- if [[ $device_type == "iPhone2,1" ]]; then
- ipsw_canhacktivate=1
- fi
- elif [[ $1 == *"powdersn0w"* ]]; then
- device_target_powder=1
- if [[ $device_proc == 4 ]]; then
- device_base_vers="$device_latest_vers"
- device_base_build="$device_latest_build"
- fi
- elif [[ $1 == *"Tethered"* ]]; then
- device_target_tethered=1
- elif [[ -n $device_target_vers && -e "../$newpath.ipsw" ]]; then
- ipsw_verify "../$newpath" "$device_target_build" #nopause
- if [[ $? == 0 ]]; then
- ipsw_path="../$newpath"
- fi
- fi
- menu_items=("Select Target IPSW")
- menu_print_info
- print "* Only select unmodified IPSW for the selection. Do not select custom IPSWs"
- echo
- if [[ $1 == *"powdersn0w"* ]]; then
- menu_items+=("Select Base IPSW")
- if [[ $device_proc == 4 ]]; then
- menu_items+=("Download Base IPSW")
- fi
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW: $ipsw_path.ipsw"
- print "* Target Version: $device_target_vers-$device_target_build"
- ipsw_print_warnings powder
- ipsw_cancustomlogo2=
- case $device_target_vers in
- [456]* ) ipsw_cancustomlogo2=1;;
- esac
- else
- print "* Select Target IPSW to continue"
- local lo
- local hi
- case $device_type in
- iPhone3,1 ) lo=4.0; hi=7.1.1;;
- iPhone3,2 ) lo=6.0; hi=7.1.1;;
- iPhone3,3 ) lo=4.2.6; hi=7.1.1;;
- iPhone4,1 | iPad2,[123] ) lo=5.0; hi=9.3.5;;
- iPad2,* | iPad3,[123] ) lo=5.1; hi=9.3.5;;
- iPhone5,[12] | iPad3,* | iPod5,1 ) lo=6.0; hi=9.3.5;;
- iPhone5,[34] ) lo=7.0; hi=9.3.5;;
- iPad1,1 ) lo=3.2; hi=5.1;;
- iPod3,1 ) lo=3.1.1; hi=5.1;;
- esac
- print "* Any iOS version from $lo to $hi is supported"
- fi
- echo
- local text2="(iOS $base_vers)"
- if [[ -n $ipsw_base_path ]]; then
- print "* Selected Base IPSW $text2: $ipsw_base_path.ipsw"
- print "* Base Version: $device_base_vers-$device_base_build"
- if [[ $ipsw_base_validate == 0 ]]; then
- print "* Selected Base IPSW is validated"
- else
- warn "Selected Base IPSW failed validation, proceed with caution"
- fi
- if [[ $device_proc != 4 ]]; then
- menu_items+=("Select Base SHSH")
- fi
- echo
- else
- print "* Select Base IPSW $text2 to continue"
- echo
- fi
- if [[ $device_proc == 4 ]]; then
- shsh_path=1
- else
- if [[ -n $shsh_path ]]; then
- print "* Selected Base SHSH $text2: $shsh_path"
- if [[ $shsh_validate == 0 ]]; then
- print "* Selected SHSH file is validated"
- else
- warn "Selected SHSH file failed validation, proceed with caution"
- if (( device_proc < 5 )); then
- warn "Validation might be a false negative for A4 and older devices."
- fi
- echo
- fi
- elif [[ $2 != "ipsw" ]]; then
- print "* Select Base SHSH $text2 to continue"
- echo
- fi
- fi
- if [[ -n $device_bootargs ]]; then
- print "* Custom Bootargs: $device_bootargs"
- else
- print "* You may enter custom bootargs (optional, experimental option)"
- print "* Default Bootargs: $device_bootargs_default"
- fi
- echo
- menu_items+=("Custom Bootargs")
- if [[ -n $ipsw_path && -n $ipsw_base_path ]] && [[ -n $shsh_path || $2 == "ipsw" ]]; then
- can_start=1
- fi
- elif [[ $2 == "fourthree" ]]; then
- menu_items+=("Download Target IPSW" "Select Base IPSW")
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW (iOS 6.1.3): $ipsw_path.ipsw"
- ipsw_print_warnings
- else
- print "* Select Target IPSW (iOS 6.1.3) to continue"
- fi
- echo
- if [[ -n $ipsw_base_path ]]; then
- print "* Selected Base IPSW (iOS 4.3.x): $ipsw_base_path.ipsw"
- print "* Base Version: $device_base_vers-$device_base_build"
- if [[ $ipsw_base_validate == 0 ]]; then
- print "* Selected Base IPSW is validated"
- else
- warn "Selected Base IPSW failed validation, proceed with caution"
- fi
- echo
- else
- print "* Select Base IPSW (iOS 4.3.x) to continue"
- echo
- fi
- if [[ -n $ipsw_path && -n $ipsw_base_path ]]; then
- can_start=1
- fi
- elif [[ $1 == *"Tethered"* ]]; then
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW: $ipsw_path.ipsw"
- print "* Target Version: $device_target_vers-$device_target_build"
- ipsw_print_warnings
- else
- print "* Select Target IPSW to continue"
- fi
- echo
- warn "This is a tethered downgrade. Not recommended unless you know what you are doing."
- print "* For more info, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Restore-Downgrade and read the \"Other (Tethered)\" section"
- if [[ -n $ipsw_path ]]; then
- can_start=1
- fi
- echo
- elif [[ $1 == "Other"* || $1 == "Set Nonce Only" ]]; then
- # menu for other (shsh) restores
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW: $ipsw_path.ipsw"
- print "* Target Version: $device_target_vers-$device_target_build"
- ipsw_print_warnings
- menu_items+=("Select Target SHSH")
- else
- print "* Select Target IPSW to continue"
- fi
- if (( device_proc >= 9 )) && [[ $device_type != "iPhone10"* ]]; then
- print "* It is recommended to use turdus merula instead: https://sep.lol/"
- fi
- echo
- if [[ -n $shsh_path ]]; then
- print "* Selected Target SHSH: $shsh_path"
- if (( device_proc > 6 )); then
- shsh_generator=$(cat "$shsh_path" | grep "<string>0x" | cut -c10-27)
- print "* Generator: $shsh_generator"
- fi
- if [[ $shsh_validate == 0 ]]; then
- print "* Selected SHSH file is validated"
- elif [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
- warn "Validation does not work for 32-bit iOS 10 blobs."
- else
- warn "Selected SHSH file failed validation, proceed with caution"
- if (( device_proc >= 7 )); then
- print "* If this is an OTA/onboard/factory blob, it may be fine to use for restoring"
- elif (( device_proc < 5 )); then
- warn "Validation might be a false negative for A4 and older devices."
- fi
- fi
- if (( device_proc >= 7 )); then
- print "* Note: For OTA/onboard/factory blobs, try enabling the skip-blob flag"
- print "* The skip-blob flag can also help if the restore fails with validated blobs"
- fi
- echo
- elif [[ $2 != "ipsw" ]]; then
- print "* Select Target SHSH to continue"
- echo
- fi
- if [[ -n $ipsw_path ]] && [[ -n $shsh_path || $2 == "ipsw" ]]; then
- can_start=1
- fi
- else
- # menu for ota/latest versions
- menu_items+=("Download Target IPSW")
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW: $ipsw_path.ipsw"
- ipsw_print_warnings
- can_start=1
- elif [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
- can_start=1
- else
- print "* Select $1 IPSW to continue"
- fi
- if [[ $ipsw_canhacktivate == 1 ]] && [[ $device_type == "iPhone2,1" || $device_proc == 1 ]]; then
- print "* Hacktivation is supported for this restore"
- fi
- echo
- fi
- if [[ $ipsw_cancustomlogo2 == 1 ]]; then
- print "* You can select your own custom Apple logo image. This is optional and an experimental option"
- print "* Note: The images must be in PNG format, and up to your device resolution"
- print "* Note 2: The custom images might not work, current support is spotty"
- if [[ -n $ipsw_customlogo ]]; then
- print "* Custom Apple logo: $ipsw_customlogo"
- else
- print "* No custom Apple logo selected"
- fi
- menu_items+=("Select Apple Logo")
- echo
- elif [[ $ipsw_cancustomlogo == 1 ]]; then
- print "* You can select your own custom logo and recovery image. This is optional and an experimental option"
- print "* Note: The images must be in PNG format, and up to 320x480 resolution"
- print "* Note 2: The custom images might not work, current support is spotty"
- if [[ -n $ipsw_customlogo ]]; then
- print "* Custom Apple logo: $ipsw_customlogo"
- else
- print "* No custom Apple logo selected"
- fi
- if [[ -n $ipsw_customrecovery ]]; then
- print "* Custom recovery logo: $ipsw_customrecovery"
- else
- print "* No custom recovery logo selected"
- fi
- menu_items+=("Select Apple Logo" "Select Recovery Logo")
- echo
- fi
- if [[ $can_start == 1 ]]; then
- if [[ $device_target_vers == "$device_latest_vers" && $device_mode != "none" && -z $2 ]]; then
- menu_items+=("(*) Start Update")
- fi
- menu_items+=("$start")
- fi
- menu_items+=("Go Back")
- if [[ $device_use_bb != 0 && $device_type != "$device_disable_bbupdate" ]] &&
- [[ $device_proc == 5 || $device_proc == 6 ]]; then
- print "* This restore will use $device_use_vers baseband"
- echo
- elif [[ $device_use_bb2 == 1 ]]; then
- if [[ $device_target_vers == "$device_latest_vers" ]]; then
- print "* This restore will use $device_use_vers baseband if the jailbreak option is disabled"
- echo
- elif [[ $device_proc == 1 || $device_target_vers == "4.1" ]] && [[ $device_type != "iPhone3,"* ]]; then
- print "* This restore will have baseband update disabled if the jailbreak option is enabled"
- echo
- else
- print "* This restore will have baseband update disabled"
- echo
- fi
- elif [[ $device_use_bb2 == 2 ]]; then
- if [[ $device_target_vers == "$device_latest_vers" ]]; then
- print "* This restore will use $device_use_vers baseband"
- echo
- else
- print "* This restore will have baseband update disabled"
- echo
- fi
- fi
- print "$nav"
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "(*) Create IPSW" ) mode="custom-ipsw";;
- "$start" ) mode="downgrade";;
- "(*) Start Update" )
- print "* The \"Start Update\" will perform an update to your device without clearing device data."
- print "* One usage of this is to carry over activation records to the latest iOS version."
- warn "This option should NOT be used if your device is jailbroken."
- warn "This option is not recommended to be used unless you know what you are doing."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- mode="restore-update"
- ;;
- "Select Target IPSW" ) menu_ipsw_browse "$1";;
- "Select Base IPSW" ) menu_ipsw_browse "base";;
- "Select Target SHSH" ) menu_shsh_browse "$1";;
- "Select Base SHSH" ) menu_shsh_browse "base";;
- "Download Target IPSW" ) ipsw_download "../$newpath";;
- "Download Base IPSW" ) ipsw_download "../$ipsw_latest_path" latest;;
- "Select Apple Logo" ) menu_logo_browse "boot";;
- "Select Recovery Logo" ) menu_logo_browse "recovery";;
- "Custom Bootargs" ) read -p "$(input 'Enter custom bootargs: ')" device_bootargs;;
- "Go Back" )
- back=1
- ipsw_24o=
- ipsw_cancustomlogo=
- ipsw_cancustomlogo2=
- ipsw_customlogo=
- ipsw_customrecovery=
- ipsw_path=
- ipsw_base_path=
- shsh_path=
- device_target_vers=
- device_target_build=
- device_base_vers=
- device_base_build=
- device_target_other=
- device_target_powder=
- device_target_tethered=
- device_bootargs=
- ;;
- esac
- done
- }
- menu_ipsw_special() {
- local menu_items
- local selected
- local back
- local newpath
- local nav
- local start="(*) "
- local base_text
- local target_text
- if [[ $2 == "ipsw" ]]; then
- nav=" > Main Menu > Misc Utilities > Create Custom IPSW > $1"
- start+="Create IPSW"
- else
- nav=" > Main Menu > Restore/Downgrade > $1"
- start+="Start Restore"
- fi
- while [[ -z "$mode" && -z "$back" ]]; do
- device_target_vers="$1"
- case $device_type in
- iPad1,1 ) device_type_special="iPad2,1"; device_model_special="k93";;
- iPod3,1 ) device_type_special="iPhone2,1"; device_model_special="n88";;
- iPod4,1 )
- device_type_special="iPhone3,3"
- device_model_special="n92"
- device_target_tethered=1
- ;;
- esac
- case $1 in
- 7.1.2 ) device_target_build="11D257";;
- 6.1.6 ) device_target_build="10B500";;
- 6.1.3 ) device_target_build="10B329";;
- 6.0 ) device_target_build="10A403";;
- esac
- all_flash_special="Firmware/all_flash/all_flash.${device_model_special}ap.production"
- device_base_vers="$device_latest_vers"
- device_base_build="$device_latest_build"
- target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
- target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
- base_text="$device_type-$device_base_vers"
- target_text="$device_type_special-$device_target_vers"
- ipsw_latest_set
- menu_print_info
- print "* Only select unmodified IPSW for the selection. Do not select custom IPSWs"
- echo
- if [[ -n $ipsw_path ]]; then
- print "* Selected Target IPSW ($target_text): $ipsw_path.ipsw"
- ipsw_print_warnings
- else
- print "* Select Target IPSW ($target_text) to continue"
- fi
- echo
- if [[ -n $ipsw_base_path ]]; then
- print "* Selected Base IPSW ($base_text): $ipsw_base_path.ipsw"
- if [[ $ipsw_base_validate == 0 ]]; then
- print "* Selected Base IPSW is validated"
- else
- warn "Selected Base IPSW failed validation, proceed with caution"
- fi
- else
- print "* Select Base IPSW ($base_text) to continue"
- fi
- echo
- case $1 in
- 7.* )
- case $device_type in
- iPad1,1 ) print "* iOS 7 on iPad 1 is based on ipad-1-ios-7 by amy-and-nicole and pwnerblu: https://github.com/amy-and-nicole/ipad-1-ios-7";;
- iPod4,1 ) warn "This is a tethered upgrade and has many broken device features. Not recommended unless you know what you are doing.";;
- esac
- ;;
- 6.* ) print "* iOS 6 on touch 3/iPad 1 uses SundanceInH2A by NyanSatan: https://github.com/NyanSatan/SundanceInH2A";;
- esac
- menu_items=("Select Target IPSW" "Select Base IPSW" "Download Target IPSW" "Download Base IPSW")
- if [[ -n $ipsw_path && -n $ipsw_base_path ]]; then
- menu_items+=("$start")
- fi
- menu_items+=("Go Back")
- print "$nav"
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "(*) Create IPSW" ) mode="custom-ipsw";;
- "$start" ) mode="downgrade";;
- "Select Target IPSW" ) menu_ipsw_browse "special";;
- "Select Base IPSW" ) menu_ipsw_browse "base";;
- "Download Target IPSW" ) ipsw_download "../${device_type_special}_${device_target_vers}_${device_target_build}_Restore" special;;
- "Download Base IPSW" ) ipsw_download "../$ipsw_latest_path" latest;;
- "Go Back" )
- back=1
- ipsw_path=
- ipsw_base_path=
- device_type_special=
- device_model_special=
- device_target_tethered=
- ;;
- esac
- done
- }
- ipsw_print_warnings() {
- if [[ $ipsw_validate == 0 ]]; then
- print "* Selected Target IPSW is validated"
- elif [[ $ipsw_isbeta == 1 ]]; then
- warn "Selected Target IPSW is a beta version, proceed with caution"
- else
- warn "Selected Target IPSW failed validation, proceed with caution"
- fi
- if [[ $device_target_vers == "9.3"* && $device_actrec == 1 ]]; then
- warn "Activation records stitching does not work for iOS 9.3+ versions, use iOS 9.2.1 or lower instead when possible."
- fi
- if [[ $1 == "powder" ]]; then
- case $device_target_build in
- 8[ABC]* ) warn "iOS 4.2.1 and lower are hit or miss. It may not restore/boot properly";;
- 8* ) [[ $device_type == "iPhone3,"* ]] && warn "Not all devices support iOS 4 versions. It may not restore/boot properly";;
- 7[CDE]* ) warn "Not all devices support iOS 3 versions. It may not restore/boot properly";;
- esac
- return
- fi
- case $device_type in
- iPhone3,1 | iPod4,1 )
- if [[ $device_target_vers == "4.2.1" ]]; then
- warn "iOS 4.2.1 for $device_type might fail to boot after the restore/jailbreak."
- print "* It is recommended to select another version instead."
- elif [[ $device_target_build == "8B118" ]]; then
- warn "iOS 4.1 (8B118) for iPod4,1 might fail to boot after the restore/jailbreak."
- print "* It is recommended to select 8B117 or another version instead."
- fi
- ;;
- iPhone2,1 )
- if [[ $device_target_vers == "3.0"* && $device_newbr != 0 ]]; then
- warn "3.0.x versions are for old bootrom devices only. It will fail to restore/boot if your device is not compatible."
- print "* It is recommended to select 3.1 or newer instead."
- fi
- ;;
- esac
- }
- ipsw_version_set() {
- local newpath="$1"
- local vers
- local build
- log "Getting version from IPSW"
- file_extract_from_archive "$newpath.ipsw" Restore.plist
- if [[ $platform == "macos" ]]; then
- rm -f BuildVer Version
- plutil -extract 'ProductVersion' xml1 Restore.plist -o Version
- vers=$(cat Version | sed -ne '/<string>/,/<\/string>/p' | sed -e "s/<string>//" | sed "s/<\/string>//" | sed '2d')
- plutil -extract 'ProductBuildVersion' xml1 Restore.plist -o BuildVer
- build=$(cat BuildVer | sed -ne '/<string>/,/<\/string>/p' | sed -e "s/<string>//" | sed "s/<\/string>//" | sed '2d')
- else
- vers=$(cat Restore.plist | grep -i ProductVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
- build=$(cat Restore.plist | grep -i ProductBuildVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
- fi
- if [[ $2 == "base" ]]; then
- device_base_vers="$vers"
- device_base_build="$build"
- else
- device_target_vers="$vers"
- device_target_build="$build"
- target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
- target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
- fi
- }
- ipsw_custom_set() {
- if [[ $ipsw_fourthree == 1 ]]; then
- ipsw_custom="../${device_type}_${device_target_vers}_${device_target_build}_FourThree"
- return
- fi
- ipsw_custom="../${device_type}"
- ipsw_custom+="_${device_target_vers}_${device_target_build}_Custom"
- if [[ -n $1 ]]; then
- ipsw_custom="../$1_Custom"
- fi
- if [[ $device_actrec == 1 ]]; then
- ipsw_custom+="A"
- fi
- if [[ $device_deadbb == 1 ]]; then
- ipsw_custom+="D"
- elif [[ $device_type == "$device_disable_bbupdate" ]]; then
- ipsw_custom+="B"
- fi
- if [[ $ipsw_gasgauge_patch == 1 ]]; then
- ipsw_custom+="G"
- fi
- if [[ $ipsw_hacktivate == 1 ]]; then
- ipsw_custom+="H"
- fi
- if [[ $ipsw_jailbreak == 1 ]]; then
- ipsw_custom+="J"
- fi
- if [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
- ipsw_custom2="$ipsw_custom"
- fi
- if [[ -n $ipsw_customlogo || -n $ipsw_customrecovery ]]; then
- ipsw_custom+="L"
- if [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
- ipsw_customlogo2=1
- fi
- fi
- if [[ $ipsw_24o == 1 ]]; then
- ipsw_custom+="O"
- fi
- if [[ $device_target_powder == 1 ]]; then
- ipsw_custom+="P"
- if [[ $device_base_vers == "7.0"* ]]; then
- ipsw_custom+="0"
- fi
- fi
- if [[ $device_target_tethered == 1 ]]; then
- ipsw_custom+="T"
- fi
- if [[ $ipsw_verbose == 1 ]]; then
- ipsw_custom+="V"
- fi
- if [[ $device_target_powder == 1 && $device_target_vers == "4.3"* ]] || [[ $device_actrec == 1 ]] ||
- [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
- ipsw_custom+="-$device_ecid"
- fi
- }
- menu_logo_browse() {
- local newpath
- input "Select your $1 image file in the file selection window."
- menu_zenity_check
- newpath="$($zenity --file-selection --file-filter='PNG | *.png' --title="Select $1 image file")"
- [[ ! -s "$newpath" ]] && read -p "$(input "Enter path to $1 image file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
- [[ ! -s "$newpath" ]] && return
- log "Selected $1 image file: $newpath"
- case $1 in
- "boot" ) ipsw_customlogo="$newpath";;
- "recovery" ) ipsw_customrecovery="$newpath";;
- esac
- }
- ipsw_print_1415warn() {
- warn "Please read: You will need to follow a guide regarding activation files before and after the restore."
- print "* You will encounter issues activating if you do not follow this."
- print "* Link to guide: https://gist.github.com/pixdoet/2b58cce317a3bc7158dfe10c53e3dd32"
- warn "You will also have several issues after the restore itself. Broken features include:"
- print "* SMS/iMessage, VPN, Face ID, Touch ID resets, sideloading (use TrollStore instead), and potentially other features"
- }
- ipsw_print_16warn() {
- warn "Please read: You will have some issues after the restore itself. Broken features include:"
- print "* SMS/iMessage, Face ID, and potentially other features."
- print "* There is a fix for Messages available. Go to FutureRestore Support Discord server for more details."
- }
- menu_ipsw_browse() {
- local versionc
- local newpath
- local text="Target"
- local picker
- local scan
- ipsw_latest_set
- local menu_items=($(ls ../$device_type_lower*restore.ipsw $HOME/Downloads/$device_type_lower*restore.ipsw 2>/dev/null))
- menu_items+=($(ls ../$device_type*Restore.ipsw $HOME/Downloads/$device_type*Restore.ipsw 2>/dev/null))
- [[ $ipsw_prefix != "$device_type" ]] && menu_items+=($(ls ../${ipsw_prefix}_1*Restore.ipsw $HOME/Downloads/${ipsw_prefix}_1*Restore.ipsw 2>/dev/null))
- if [[ $1 == "base" ]]; then
- text="Base"
- scan="${device_type_lower}_${check_vers}*restore.ipsw"
- menu_items=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
- scan="${device_type}_${check_vers}*Restore.ipsw"
- menu_items+=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
- elif [[ $1 == "special" ]]; then
- scan="${device_type_special}_${device_target_vers}_${device_target_build}_Restore.ipsw"
- menu_items=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
- fi
- case $1 in
- "iOS 10.3.3" ) versionc="10.3.3";;
- "iOS 8.4.1" ) versionc="8.4.1";;
- "iOS 6.1.3" ) versionc="6.1.3";;
- "iOS 4.1" ) versionc="4.1";;
- "Latest iOS"* ) versionc="$device_latest_vers";;
- [6543].* ) versionc="$1";;
- "custom" ) text="Custom";;
- esac
- if [[ $1 == "custom" ]]; then
- menu_items=()
- elif [[ $versionc == "$device_latest_vers" ]]; then
- menu_items+=($(ls ../${ipsw_prefix}_${device_latest_vers}_${device_latest_build}_Restore.ipsw 2>/dev/null))
- elif [[ -n $versionc ]]; then
- menu_items=($(ls ../${device_type}_${versionc}*Restore.ipsw 2>/dev/null))
- fi
- menu_items+=("Open File Picker" "Enter Path" "Go Back")
- if [[ "${menu_items[0]}" == *".ipsw" ]]; then
- print "* Select $text IPSW Menu"
- while true; do
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Open File Picker" ) picker=1; break;;
- "Enter Path" ) break;;
- *.ipsw ) newpath="$selected"; break;;
- "Go Back" ) return;;
- esac
- done
- else
- picker=1
- fi
- if [[ $picker == 1 ]]; then
- input "Select your $text IPSW file in the file selection window."
- menu_zenity_check
- if [[ $1 == "custom" ]]; then
- newpath="$($zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select $text IPSW file")"
- else
- newpath="$($zenity --file-selection --file-filter='IPSW | *Restore.ipsw' --title="Select $text IPSW file")"
- fi
- fi
- if [[ ! -s "$newpath" ]]; then
- print "* Enter the full path to the IPSW file to be used."
- print "* You may also drag and drop the IPSW file to the Terminal window."
- read -p "$(input "Path to $text IPSW file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
- fi
- [[ ! -s "$newpath" ]] && return
- newpath="${newpath%?????}"
- log "Selected IPSW file: $newpath.ipsw"
- ipsw_version_set "$newpath" "$1"
- if [[ $device_target_vers == "$device_latest_vers" && $platform == "macos" ]] && (( device_proc >= 7 )); then
- log "Restoring to latest iOS for 64-bit devices is not supported on macOS, use iTunes/Finder instead for that"
- pause
- return
- fi
- if [[ $device_target_vers == "$device_latest_vers" ]] &&
- [[ $device_target_other == 1 || $device_target_tethered == 1 ]]; then
- log "For restoring to latest iOS, select the \"Latest iOS\" option instead of \"Other\""
- pause
- return
- elif [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_tethered != 1 &&
- $device_target_other != 1 && $device_target_powder != 1 ]]; then
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* iOS 10 versions that are not 10.3.4 are not supported for 32-bit devices."
- print "* The only exception is for restoring with 32-bit iOS 10 blobs."
- pause
- return
- fi
- if [[ $1 == "special" ]]; then
- if [[ $(cat Restore.plist | grep -c $device_type_special) == 0 ]]; then
- log "Selected IPSW is not for device $device_type_special."
- pause
- return
- fi
- elif [[ $(cat Restore.plist | grep -c $device_type) == 0 ]]; then
- log "Selected IPSW is not for your device $device_type."
- pause
- return
- elif [[ $device_proc == 8 && $device_latest_vers == "12"* ]] || [[ $device_type == "iPad4,6" ]]; then
- # SEP/BB check for iPhone 6/6+, iPad mini 2 China, iPod touch 6
- case $device_target_build in
- 1[1234]* | 15[ABCD]* )
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* Latest SEP/BB is not compatible."
- pause
- return
- ;;
- esac
- elif [[ $device_proc == 7 ]]; then
- # SEP/BB check for iPhone 5S, iPad Air 1/mini 2
- case $device_target_build in
- 1[123]* | 14A* | 15[ABCD]* )
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* Latest SEP/BB is not compatible."
- pause
- return
- ;;
- esac
- elif [[ $device_latest_vers == "15"* ]]; then
- # SEP/BB check for iPhone 6S/6S+/SE 2016/7/7+, iPad Air 2/mini 4, iPod touch 7
- case $device_target_build in
- 1[234567]* )
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* Latest SEP/BB is not compatible."
- if (( device_proc >= 9 )); then
- print "* Use turdus merula instead: https://sep.lol/"
- fi
- pause
- return
- ;;
- esac
- elif [[ $device_checkm8ipad == 1 ]]; then
- case $device_target_build in
- 1[89]* )
- ipsw_print_1415warn
- print "* It is recommended to use turdus merula instead: https://sep.lol/"
- pause
- ;;
- 20[GH]* ) # 16.6-16.7.x only in 16.x
- ipsw_print_16warn
- print "* It is recommended to use turdus merula instead: https://sep.lol/"
- pause
- ;;
- #22[GH]* ) :;; # fr doesnt actually work on ipados/ios 18 so this is commented out for now
- * )
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* Latest SEP/BB is not compatible."
- print "* Use turdus merula instead: https://sep.lol/"
- pause
- return
- ;;
- esac
- elif [[ $device_latest_vers == "16"* ]]; then
- case $device_target_build in
- 18[CDEFGH]* | 19* )
- ipsw_print_1415warn
- pause
- ;;
- 20[GH]* ) # 16.6-16.7.x only in 16.x
- ipsw_print_16warn
- pause
- ;;
- * )
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- print "* Latest SEP/BB is not compatible."
- pause
- return
- ;;
- esac
- fi
- case $1 in
- "onboard" )
- if [[ $device_target_vers == "10"* ]]; then
- log "Saving iOS 10 blobs is not supported for 32-bit devices."
- pause
- return
- fi
- ;;
- "base" )
- local check_vers="$check_vers"
- local base_vers="$base_vers"
- if [[ $ipsw_fourthree == 1 ]]; then
- check_vers="4.3"
- base_vers="4.3.x"
- fi
- if [[ $device_base_vers != "$check_vers"* ]]; then
- log "Selected IPSW is not for iOS $base_vers."
- if [[ $device_proc == 4 ]]; then
- print "* You need to select iOS $base_vers IPSW for the base to use powdersn0w."
- elif [[ $ipsw_fourthree == 1 ]]; then
- print "* You need to select iOS $base_vers IPSW for the base to use FourThree."
- else
- print "* You need iOS $base_vers IPSW and SHSH blobs for your device to use powdersn0w."
- fi
- pause
- return
- elif [[ $device_target_build == "$device_base_build" ]]; then
- log "The base version and the target version cannot be the same."
- device_target_vers=
- device_target_build=
- device_base_vers=
- device_base_build=
- ipsw_path=
- ipsw_base_path=
- pause
- return
- fi
- ipsw_verify "$newpath" "$device_base_build"
- if [[ $? != 0 ]]; then
- return
- fi
- ipsw_base_path="$newpath"
- return
- ;;
- *"powdersn0w"* )
- if [[ $device_target_build == "14"* ]]; then
- log "Selected IPSW ($device_target_vers) is not supported as target version."
- case $device_type in
- iPhone5,[12] ) print "* If you want to jailbreak iOS 10 untethered, use p0insettia plus: https://github.com/LukeZGD/p0insettia-plus";;
- esac
- pause
- return
- elif [[ $device_target_build == "11D257" && $device_type == "iPhone3,"* ]] ||
- [[ $device_target_build == "9B206" && $device_proc == 4 && $device_type != "iPhone3,"* ]]; then
- log "Selected IPSW ($device_target_vers) is not supported as target version. You need to select it as the base IPSW."
- device_target_vers=
- device_target_build=
- ipsw_path=
- pause
- return
- elif [[ $device_target_build == "$device_base_build" ]]; then
- log "The base version and the target version cannot be the same."
- device_target_vers=
- device_target_build=
- device_base_vers=
- device_base_build=
- ipsw_path=
- ipsw_base_path=
- pause
- return
- fi
- ;;
- esac
- if [[ -n $versionc && $device_target_vers != "$versionc" ]]; then
- log "Selected IPSW ($device_target_vers) does not match target version ($versionc)."
- pause
- return
- fi
- if [[ $1 == "special" ]]; then
- ipsw_verify "$newpath" "$device_target_build" special
- [[ $? != 0 ]] && return
- elif [[ $1 != "custom" ]]; then
- ipsw_verify "$newpath" "$device_target_build"
- [[ -n $versionc && $? != 0 ]] && return
- fi
- ipsw_path="$newpath"
- }
- menu_shsh_browse() {
- local newpath
- local text="Target"
- local val="$ipsw_path.ipsw"
- local picker
- local menu_items=($(ls ../*${device_ecid}*${device_type}*${device_target_vers}*shsh* ../saved/shsh/*${device_ecid}*${device_type}*${device_target_vers}*shsh* 2>/dev/null))
- if [[ $1 == "base" ]]; then
- text="Base"
- menu_items=($(ls ../*${device_ecid}*${device_type}*${device_base_vers}*shsh* ../saved/shsh/*${device_ecid}*${device_type}*${device_base_vers}*shsh* 2>/dev/null))
- fi
- menu_items+=("Open File Picker" "Enter Path" "Go Back")
- if [[ "${menu_items[0]}" == *"shsh"* ]]; then
- print "* Select $text SHSH Menu"
- while true; do
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Open File Picker" ) picker=1; break;;
- "Enter Path" ) break;;
- *shsh* ) newpath="$selected"; break;;
- "Go Back" ) return;;
- esac
- done
- else
- picker=1
- fi
- if [[ $picker == 1 ]]; then
- input "Select your $text SHSH file in the file selection window."
- menu_zenity_check
- newpath="$($zenity --file-selection --file-filter='SHSH | *.bshsh2 *.shsh *.shsh2' --title="Select $text SHSH file")"
- fi
- if [[ -n "$newpath" && ! -s "$newpath" ]]; then
- warn "The selected SHSH blob file seems to be empty/invalid. It cannot be used for restoring."
- pause
- return
- fi
- if [[ ! -s "$newpath" ]]; then
- print "* Enter the full path to the SHSH file to be used."
- print "* You may also drag and drop the SHSH file to the Terminal window."
- read -p "$(input "Path to $text SHSH file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
- fi
- [[ ! -s "$newpath" ]] && return
- log "Selected SHSH file: $newpath"
- log "Validating..."
- if (( device_proc >= 7 )); then
- file_extract_from_archive "$val" BuildManifest.plist
- shsh_validate=$("$dir/img4tool" -s "$newpath" --verify BuildManifest.plist | tee /dev/tty | grep -c "APTicket is BAD!")
- elif [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
- shsh_validate=1
- shsh_path="$newpath"
- return
- else
- if [[ $1 == "base" ]]; then
- val="$ipsw_base_path.ipsw"
- fi
- "$dir/validate" "$newpath" "$val" -z
- shsh_validate=$?
- fi
- if [[ $shsh_validate != 0 ]]; then
- warn "Validation failed. Did you select the correct IPSW/SHSH?"
- print "* If you selected the correct IPSW and the error is not APTicket and/or LLB, the blob is most likely usable."
- pause
- fi
- shsh_path="$newpath"
- }
- menu_shshdump_browse() {
- local newpath
- input "Select your raw dump file in the file selection window."
- menu_zenity_check
- newpath="$($zenity --file-selection --file-filter='Raw Dump | *.dump *.raw' --title="Select Raw Dump")"
- [[ ! -s "$newpath" ]] && read -p "$(input "Enter path to raw dump file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
- [[ ! -s "$newpath" ]] && return
- log "Selected raw dump file: $newpath"
- shsh_path="$newpath"
- }
- menu_flags() {
- local menu_items
- local selected
- local back
- while [[ -z "$mode" && -z "$back" ]]; do
- menu_items=()
- case $device_type in
- iPhone[45]* | iPad2,[67] | iPad3,[56] ) menu_items+=("Enable disable-bbupdate flag");;
- esac
- if (( device_proc >= 7 )); then
- menu_items+=("Enable skip-blob flag")
- else
- if [[ $device_actrec == 1 ]]; then
- menu_items+=("Disable activation-records flag")
- else
- menu_items+=("Enable activation-records flag")
- fi
- menu_items+=("Enable jailbreak flag" "Enable multipatch flag")
- if (( device_proc >= 5 )); then
- menu_items+=("Enable skip-ibss flag")
- fi
- fi
- case $device_type in
- iPhone3,[13] | iPad1,1 | iPod3,1 ) menu_items+=("Enable skip-first flag");;
- esac
- menu_items+=("Enable no-finder flag" "Go Back")
- menu_print_info
- print " > Main Menu > Misc Utilities > Enable Flags"
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Enable disable-bbupdate flag" )
- warn "This will enable the --disable-bbupdate flag."
- print "* This will disable baseband update for custom IPSWs."
- print "* This will enable usage of dumped baseband and stitch to IPSW."
- print "* This supports the following: iPhone 4S, 5, 5C, iPad 4, mini 1"
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the disable-bbupdate flag?" 0
- if [[ $? != 0 ]]; then
- device_disable_bbupdate="$device_type"
- back=1
- fi
- ;;
- "Enable activation-records flag" )
- warn "This will enable the --activation-records flag."
- print "* This will enable usage of dumped activation records and stitch to IPSW."
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the activation-records flag?" 0
- if [[ $? != 0 ]]; then
- device_actrec=1
- device_disable_actrec=
- back=1
- fi
- ;;
- "Disable activation-records flag" )
- warn "This will disable the --activation-records flag."
- print "* This will disable usage of dumped activation records and stitch to IPSW."
- print "* Do not disable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to disable the activation-records flag?" 0
- if [[ $? != 0 ]]; then
- device_actrec=
- device_disable_actrec=1
- back=1
- fi
- ;;
- "Enable skip-ibss flag" )
- warn "This will enable the --skip-ibss flag."
- print "* This will assume that a pwned iBSS has already been sent to the device."
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the skip-ibss flag?" 0
- if [[ $? != 0 ]]; then
- device_skip_ibss=1
- back=1
- fi
- ;;
- "Enable jailbreak flag" )
- warn "This will enable the --jailbreak flag."
- print "* This will enable the jailbreak option for the custom IPSW."
- print "* This is mostly useful for 4.1 and lower, where jailbreak option is disabled in some cases."
- print "* The recommended method is to jailbreak after the restore instead."
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the jailbreak flag?" 0
- if [[ $? != 0 ]]; then
- ipsw_jailbreak=1
- back=1
- fi
- ;;
- "Enable multipatch flag" )
- warn "This will enable the --multipatch flag."
- print "* This will enable \"multipatch\" for the custom IPSW."
- print "* This is especially useful for iPhone 4S devices that have issues restoring due to third party battery."
- print "* This issue is called \"gas gauge\" error, also known as error 29 in iTunes."
- print "* By enabling this, firmware components for 6.1.3 or lower will be used for restoring to get past the error."
- print "* This also attempts to get past \"invalid ticket\" error and other restore errors."
- local opt
- select_yesno "Do you want to enable the multipatch flag?" 0
- if [[ $? != 0 ]]; then
- ipsw_gasgauge_patch=1
- back=1
- fi
- ;;
- "Enable skip-first flag" )
- warn "This will enable the --skip-first flag."
- print "* This will skip first restore and flash part 2 IPSW only for powdersn0w 4.2.x and lower."
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the skip-ibss flag?" 0
- if [[ $? != 0 ]]; then
- ipsw_skip_first=1
- back=1
- fi
- ;;
- "Enable skip-blob flag" )
- warn "This will enable the --skip-blob flag."
- print "* This will enable the skip blob flag of futurerestore."
- print "* This can be used to skip blob verification for OTA/onboard/factory SHSH blobs."
- print "* Do not enable this if you do not know what you are doing."
- local opt
- select_yesno "Do you want to enable the skip-blob flag?" 0
- if [[ $? != 0 ]]; then
- restore_useskipblob=1
- back=1
- fi
- ;;
- "Enable no-finder flag" )
- warn "This will enable the --no-finder flag."
- print "* This will disable Finder device detection and keep it disabled after the script exits."
- print "* To re-enable it, run the script without this flag enabled then exit."
- local opt
- select_yesno "Do you want to enable the no-finder flag?" 0
- if [[ $? != 0 ]]; then
- no_finder=1
- back=1
- fi
- ;;
- "Go Back" ) back=1;;
- esac
- done
- }
- menu_miscutilities() {
- local menu_items
- local selected
- local back
- menu_print_info
- while [[ -z "$mode" && -z "$back" ]]; do
- menu_items=()
- if [[ $device_mode != "none" ]]; then
- if [[ $device_mode == "Normal" ]]; then
- case $device_type in
- iPad2,[123] ) menu_items+=("FourThree Utility");;
- esac
- if [[ -n $device_serial ]]; then
- menu_items+=("Export Device Info")
- if (( device_vers_maj < 5 )); then
- warn "Device is on lower than iOS 5. Battery info is not available"
- else
- menu_items+=("Export Battery Info")
- fi
- if (( device_vers_maj < 4 )) || (( device_vers_maj == 4 && device_vers_min < 2 )); then
- warn "Device is on lower than iOS 4.2.x. Shutdown/Restart device options are not available"
- else
- menu_items+=("Shutdown Device" "Restart Device" )
- fi
- menu_items+=("Enter Recovery Mode" "Attempt Activation")
- else
- warn "Some options are currently unavailable. Pair your device to access them."
- menu_items+=("Pair Device")
- fi
- menu_items+=("Activation Records")
- fi
- if [[ $device_proc != 1 ]] && (( device_proc < 7 )); then
- if [[ $device_mode != "Normal" ]]; then
- menu_items+=("Get iOS Version" "Activation Records")
- fi
- case $device_type in
- iPhone[45]* | iPad2,[67] | iPad3,[56] ) menu_items+=("Dump Baseband");;
- esac
- fi
- fi
- if (( device_proc <= 10 )) && [[ $device_latest_vers != "16"* && $device_checkm8ipad != 1 && $device_argmode == "none" ]]; then
- menu_items+=("SSH Ramdisk")
- fi
- if [[ $device_proc != 1 ]] && (( device_proc < 11 )); then
- menu_items+=("Enable Flags")
- fi
- if (( device_proc < 7 )); then
- menu_items+=("Create Custom IPSW")
- fi
- menu_items+=("(Re-)Install Dependencies" "Go Back")
- print " > Main Menu > Misc Utilities"
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Export Device Info" )
- device_pair
- mkdir -p ../saved/info
- log "Running ideviceinfo"
- local info="../saved/info/device-$device_ecid-$device_type-$(date +%Y-%m-%d-%H%M).txt"
- $ideviceinfo > $info
- if [[ $? != 0 ]]; then
- $ideviceinfo -s > $info
- fi
- log "Device Info exported to: $info"
- ;;
- "Export Battery Info" )
- device_pair
- mkdir -p ../saved/info
- log "Running idevicediagnostics"
- local info="../saved/info/battery-$device_ecid-$device_type-$(date +%Y-%m-%d-%H%M).txt"
- $idevicediagnostics ioregentry AppleSmartBattery > $info
- if [[ $? != 0 ]]; then
- $idevicediagnostics ioregentry AppleARMPMUCharger > $info
- fi
- log "Battery Info exported to: $info"
- ;;
- "Shutdown Device" ) mode="shutdown";;
- "Restart Device" ) mode="restart";;
- "Enter Recovery Mode" ) mode="enterrecovery";;
- "Attempt Activation" ) device_activate;;
- "Dump Baseband" ) mode="baseband";;
- "Activation Records" ) mode="actrec";;
- "Enable Flags" ) menu_flags;;
- "(Re-)Install Dependencies" ) install_depends;;
- "Create Custom IPSW" ) menu_restore ipsw;;
- "Get iOS Version" ) mode="getversion";;
- "SSH Ramdisk" ) mode="device_enter_ramdisk";;
- "FourThree Utility" ) menu_fourthree;;
- "Pair Device" ) device_pair;;
- "Go Back" ) back=1;;
- esac
- done
- }
- menu_usefulutilities() {
- local menu_items
- local selected
- local back
- while [[ -z "$mode" && -z "$back" ]]; do
- menu_items=()
- if [[ $device_proc != 1 ]] && (( device_proc < 7 )); then
- if [[ $device_mode == "Normal" && $device_type != "iPod2,1" ]]; then
- menu_items+=("Enter kDFU Mode")
- fi
- case $device_proc in
- [56] ) menu_items+=("Send Pwned iBSS");;
- * ) menu_items+=("Enter pwnDFU Mode");;
- esac
- menu_items+=("Clear NVRAM")
- if [[ $device_canpowder == 1 ]]; then
- menu_items+=("Disable/Enable Exploit")
- elif [[ $device_type == "iPhone2,1" && $device_newbr != 0 && $device_mode != "Normal" ]]; then
- menu_items+=("Install alloc8 Exploit")
- fi
- if [[ $device_type != "iPod2,1" && $device_mode == "Normal" ]]; then
- menu_items+=("Just Boot")
- fi
- if [[ $device_mode == "Normal" ]]; then
- case $device_type in
- iPhone1,* )
- case $device_vers in
- 3.1.3 | 4.[12]* ) menu_items+=("Hacktivate Device" "Revert Hacktivation");;
- esac
- ;;
- iPad1,1 | iPhone[23],* | iPod4,1 )
- case $device_vers in
- 3.1* | [456]* ) menu_items+=("Hacktivate Device" "Revert Hacktivation");;
- esac
- ;;
- esac
- fi
- fi
- if (( device_proc >= 7 )) && (( device_proc <= 10 )); then
- menu_items+=("Enter pwnDFU Mode")
- fi
- if (( device_proc <= 10 )) && [[ $device_latest_vers != "16"* && $device_checkm8ipad != 1 ]]; then
- menu_items+=("SSH Ramdisk" "Update DateTime")
- fi
- if [[ $device_mode == "Normal" ]]; then
- menu_items+=("Run uicache" "Console")
- fi
- menu_items+=("DFU Mode Helper" "Go Back")
- menu_print_info
- # other utilities menu
- print " > Main Menu > Useful Utilities"
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Hacktivate Device" )
- print "* Note: This is for hacktivating devices that are already restored and jailbroken with Legacy iOS Kit."
- print "* If this is not what you want, you might be looking for the \"Restore/Downgrade\" option instead."
- print "* From there, enable both \"Jailbreak Option\" and \"Hacktivate Option.\""
- echo
- print "* Hacktivate Device: This will patch lockdownd on your device."
- print "* Hacktivation is for iOS versions 3.1 to 6.1.6."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- mode="device_hacktivate"
- ;;
- "Revert Hacktivation" )
- print "* This will use revert hacktivation for this device."
- print "* This option can only be used if the hacktivation is done using Legacy iOS Kit's \"Hacktivate Device\" option."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- mode="device_reverthacktivate"
- ;;
- "Enter kDFU Mode" ) mode="kdfu";;
- "Disable/Enable Exploit" ) menu_remove4;;
- "SSH Ramdisk" ) mode="device_enter_ramdisk";;
- "Clear NVRAM" ) mode="ramdisknvram";;
- "Send Pwned iBSS" | "Enter pwnDFU Mode" ) mode="pwned-ibss";;
- "Install alloc8 Exploit" )
- warn "This will install alloc8 exploit to the device. Only do this if your device is successfully restored already."
- print "* If your device is not successfully restored/downgraded yet, this will not work."
- print "* Also, this is not supposed to be used on iOS 6.1.6 or 4.1."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- mode="device_alloc8"
- ;;
- "Just Boot" ) menu_justboot;;
- "Update DateTime" ) device_update_datetime;;
- "DFU Mode Helper" ) mode="device_dfuhelper";;
- "Run uicache" )
- print "* This will run the uicache command via SSH to help fix missing jailbreak app icons."
- print "* In order for this to work, OpenSSH must be installed on your device."
- print "* If your device is restored/jailbroken with Legacy iOS Kit, OpenSSH is already installed."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- mode="device_uicache"
- ;;
- "Console" )
- print "* This will run idevicesyslog and show live system log of the device."
- print "* To stop and exit, just press Ctrl+C or close the terminal window."
- select_yesno
- if [[ $? != 1 ]]; then
- continue
- fi
- device_pair
- "$dir/idevicesyslog" -q
- ;;
- "Go Back" ) back=1;;
- esac
- done
- }
- device_update_datetime() {
- device_buttons2
- if [[ $device_mode == "Normal" ]]; then
- log "Proceeding on Normal mode."
- device_iproxy
- device_ssh_message
- device_sshpass
- device_datetime_cmd
- kill $iproxy_pid
- else
- mode="getversion"
- fi
- }
- device_pair() {
- if [[ $device_vers_maj == 7 && $platform == "linux" ]]; then
- warn "Pressing \"Trust\" for devices on iOS 7 can have connection issues on Linux (disconnect-reconnect)."
- print "* You may select \"Don't Trust\" on the prompt as a workaround, but that can limit some functionality."
- fi
- log "Attempting idevicepair"
- "$dir/idevicepair" pair
- local opt=$?
- if [[ $opt != 0 ]]; then
- log "Unlock and press \"Trust\" on the device before pressing Enter/Return."
- print "* If you denied the trust dialog, unplug and replug the device."
- pause
- log "Attempting idevicepair"
- "$dir/idevicepair" pair
- opt=$?
- fi
- if [[ $opt == 0 ]]; then
- device_get_paired_info
- else
- warn "Unable to pair with device."
- fi
- }
- device_ssh() {
- print "* Note: This is for connecting via SSH to devices that are already jailbroken and have OpenSSH installed."
- print "* If this is not what you want, you might be looking for the \"SSH Ramdisk\" option instead."
- echo
- device_iproxy no-logging
- device_ssh_message
- device_sshpass
- log "Connecting to device SSH..."
- print "* For SSH/SCP access, use the following:"
- print "* Host: sftp://127.0.0.1 | Username: $ssh_user | Password: <your password> (default is alpine) | Port: $ssh_port"
- if [[ $ssh_user == "root" ]]; then
- print "* You may also use mobile as the username for SSH/SCP access."
- fi
- $ssh -p $ssh_port ${ssh_user}@127.0.0.1
- kill $iproxy_pid
- }
- device_jailbreak_confirm() {
- if [[ $device_vers == *"iBoot"* || $device_vers == "Unknown"* ]]; then
- device_vers=
- while [[ -z $device_vers ]]; do
- read -p "$(input 'Enter current iOS version (eg. 6.1.3): ')" device_vers
- done
- elif [[ $device_mode == "Normal" ]]; then
- case $device_vers in
- 5* | 6.0* | 6.1 | 6.1.[12] )
- print "* Your device on iOS $device_vers will be jailbroken using g1lbertJB."
- print "* No data will be lost, but please back up your data just in case."
- print "* Ignore the \"Error Code 1\" and \"Error Code 102\" errors, this is normal and part of the jailbreaking process."
- if [[ $device_proc == 4 ]]; then
- print "* Note: If the process fails somewhere, you can just enter DFU mode and attempt jailbreaking again from there."
- fi
- select_yesno
- if [[ $? != 1 ]]; then
- return
- fi
- mode="device_jailbreak_gilbert"
- return
- ;;
- esac
- fi
- log "Checking if your device and version is supported..."
- log "Please read the message below:"
- if [[ $device_type == "iPhone3,3" ]]; then
- case $device_vers in
- 4.2.9 | 4.2.10 )
- warn "For this version, it will be a semi-tethered jailbreak."
- print "* To boot jailbroken later, go to: Main Menu -> Just Boot"
- pause
- ;;
- esac
- elif [[ $device_proc == 1 ]]; then
- warn "If you jailbreak with this option (ramdisk method), you will not be able to Bootlace or other similar tools."
- print "* If you want to use the mentioned tools, go to \"Restore/Downgrade\" instead, and enable the jailbreak option."
- elif [[ $device_proc == 5 ]]; then
- print "* Note: It would be better to jailbreak using sideload or custom IPSW methods for A5 devices."
- print "* Especially since this method may require the usage of checkm8-a5."
- elif [[ $device_proc == 6 && $platform == "linux" ]]; then
- print "* Note: It would be better to jailbreak using sideload or custom IPSW methods for A6 devices on Linux."
- fi
- if [[ $device_proc == 1 && $device_vers == "4.2.1" ]] ||
- [[ $device_type == "iPod3,1" && $device_vers == "6"* ]] ||
- [[ $device_type == "iPod4,1" && $device_vers == "7"* ]]; then
- warn "Jailbreaking using the ramdisk method is not supported for the $device_type on iOS $device_vers."
- print "* You will need to go to \"Restore/Downgrade\" instead."
- pause
- return
- fi
- if [[ $device_vers == "7"* ]]; then
- warn "Jailbreaking using the ramdisk method is disabled for iOS 7.x."
- print "* It is recommended to use Aquila instead, or dump blobs and restore with the jailbreak option enabled."
- warn "You will encounter issues when jailbreaking 7.x with ramdisk method, particularly baseband issues."
- [[ $ipsw_jailbreak != 1 ]] && warn "You can bypass this by enabling the jailbreak flag, but only do this if you know what you are doing."
- echo
- fi
- if [[ $device_proc == 5 || $device_proc == 6 ]]; then
- case $device_vers in
- 6.1.[3456] )
- print "* For this version, Aquila on Windows/Mac can also be used instead of this option."
- print "* https://ios.cfw.guide/installing-aquila/"
- print "* Sideloading aquila-app is also an option, especially if on Linux."
- print "* https://github.com/LukeZGD/aquila-app"
- ;;
- esac
- if [[ $platform == "linux" ]]; then
- case $device_vers in
- [689]* | 10* ) print "* Note: If you need to sideload, you can use Legacy iOS Kit's \"Sideload IPA\" option.";;
- esac
- fi
- fi
- print "* For more details, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Jailbreaking"
- case $device_vers in
- 7.0* )
- print "* For this version, Aquila on Windows/Mac can be used instead of this option."
- print "* https://ios.cfw.guide/installing-aquila/"
- print "* Sideloading EverPwnage is also an option, especially if on Linux."
- print "* https://github.com/LukeZGD/EverPwnage"
- pause
- [[ $ipsw_jailbreak != 1 ]] && return
- ;;
- 7.1* )
- print "* For this version, use Lyncis to jailbreak your device."
- print "* https://ios.cfw.guide/using-lyncis/"
- pause
- [[ $ipsw_jailbreak != 1 ]] && return
- ;;
- 9.3.[56] )
- print "* For this version, use Carbon to jailbreak your device."
- print "* https://ios.cfw.guide/using-carbon/"
- pause
- return
- ;;
- [89].* )
- print "* For this version, you can use Carbon to jailbreak your device."
- print "* https://ios.cfw.guide/using-carbon/"
- print "* You may still continue if you really want to do the ramdisk method instead."
- ;;
- 10.* )
- print "* For this version, use socket to jailbreak your device."
- print "* https://github.com/staturnzz/socket"
- pause
- return
- ;;
- [7654]* | 3.2* | 3.1.3 )
- if [[ $device_type == "iPhone2,1" && $device_vers == "3.1.3" ]]; then
- warn "To jailbreak iOS 3.x for the 3GS, make sure your device is restored with Legacy iOS Kit's \"Restore/Downgrade\" first."
- print "* If you have not done this, do not continue."
- fi
- ;;
- 3.[10]* )
- if [[ $device_type == "iPhone2,1" ]]; then
- warn "To jailbreak iOS 3.x for the 3GS, make sure your device is restored with Legacy iOS Kit's \"Restore/Downgrade\" first."
- print "* If you have not done this, do not continue."
- else
- warn "This version ($device_vers) is not supported for jailbreaking with ramdisk method."
- print "* Supported versions are: 3.1.3 to 9.3.4"
- pause
- return
- fi
- ;;
- * )
- warn "This version ($device_vers) is not supported for jailbreaking with ramdisk method."
- print "* Supported versions are: 3.1.3 to 9.3.4"
- pause
- return
- ;;
- esac
- echo
- print "* By selecting Jailbreak Device, your device will be jailbroken using Ramdisk Method."
- print "* Before continuing, make sure that your device does not have a jailbreak yet."
- print "* No data will be lost, but please back up your data just in case."
- select_yesno
- if [[ $? != 1 ]]; then
- return
- fi
- mode="device_jailbreak"
- }
- device_jailbreak() {
- device_ramdisk jailbreak
- }
- device_jailbreak_gilbert() {
- pushd ../resources/jailbreak/g1lbertJB >/dev/null
- log "Copying freeze.tar to Cydia.tar"
- cp ../freeze.tar.gz .
- gzip -d freeze.tar.gz
- mv freeze.tar payload/common/Cydia.tar
- log "Running g1lbertJB..."
- "../../$dir/gilbertjb"
- rm -rf payload/common/Cydia.tar private var
- popd >/dev/null
- }
- device_ssh_message() {
- log "Please read the message below:"
- print "* Follow these instructions to connect to the device."
- if [[ $device_vers_maj == 10 ]] && (( device_proc < 7 )); then
- print "1. Jailbreak with socket: https://github.com/staturnzz/socket"
- print " - And install \"Dropbear\" from my repo: https://lukezgd.github.io/repo"
- else
- print "1. Install \"OpenSSH\" in Cydia or Zebra."
- fi
- print "2. You will be prompted to enter the root/mobile password of your iOS device."
- print " - The default password is: alpine"
- print " - Your password input may not be visible, but it is still being entered."
- print "* You can also just press Enter/Return to enter the default password."
- }
- device_dump() {
- local arg="$1"
- local dump="../saved/$device_type/$arg-$device_ecid.tar"
- local dmps
- local dmp2
- case $arg in
- "baseband" ) dmps="/usr/local/standalone";;
- "activation" )
- dmp2="private/var/root/Library/Lockdown"
- case $device_vers in
- [34567]* ) dmps="/$dmp2";;
- 8* | 9.[012]* ) dmps="/private/var/mobile/Library/mad";;
- * )
- dmps="/private/var/containers/Data/System/*/Library/activation_records"
- dmp2+="/activation_records"
- ;;
- esac
- ;;
- esac
- log "Dumping files for $arg: $dmps"
- if [[ -s $dump ]]; then
- log "Found existing dumped $arg: $dump"
- if [[ $arg == "activation" && $(tar -tf $dump | grep -c "_record.plist") == 0 ]]; then
- log "Activation record not found in existing activation dump. Deleting"
- rm $dump
- elif [[ $arg == "baseband" && $(tar -tf $dump | grep -c "bbticket.der") == 0 ]]; then
- log "bbticket not found in existing baseband dump. Deleting"
- rm $dump
- else
- return
- fi
- fi
- if [[ $device_mode == "Normal" ]] && (( device_proc < 7 )); then
- device_buttons2
- elif [[ $device_mode == "none" ]]; then
- error "No existing $arg dump found while in no device mode. Cannot continue."
- elif [[ $device_mode != "Normal" ]]; then
- log "Recovery/DFU mode device detected, entering pwnDFU mode to continue for SSH ramdisk."
- if [[ $platform == "linux" || $device_proc == 5 ]]; then
- print "* Note: If you can jailbreak and enter kDFU mode, exit now and proceed to do that instead."
- fi
- device_enter_mode pwnDFU
- fi
- if [[ $device_mode == "Normal" ]]; then
- device_iproxy
- if [[ -z $SSHPASS ]]; then
- device_ssh_message
- device_sshpass
- fi
- if [[ $arg == "activation" ]]; then
- log "Creating $arg.tar"
- $ssh -p $ssh_port ${ssh_user}@127.0.0.1 "mkdir -p /tmp/$dmp2; find $dmps; cp -R $dmps/* /tmp/$dmp2"
- #$ssh -p $ssh_port ${ssh_user}@127.0.0.1 "cd /tmp/$dmp2/activation_records; mv *_record.plist activation_record.plist"
- $ssh -p $ssh_port ${ssh_user}@127.0.0.1 "cd /tmp; tar -cvf $arg.tar $dmp2"
- log "Copying $arg.tar"
- $scp -P $ssh_port ${ssh_user}@127.0.0.1:/tmp/$arg.tar .
- mv $arg.tar $arg-$device_ecid.tar
- if [[ $(tar -tf activation-$device_ecid.tar | grep -c "_record.plist") != 0 ]]; then
- cp activation-$device_ecid.tar $dump
- else
- warn "Activation record not found in tar. Will not save activation dump."
- fi
- else
- device_dumpbb
- if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
- cp baseband-$device_ecid.tar $dump
- else
- warn "bbticket not found in tar. Will not save baseband dump."
- fi
- fi
- kill $iproxy_pid
- else
- device_enter_ramdisk $arg
- device_dumprd
- $ssh -p $ssh_port [email protected] "nvram auto-boot=1; reboot_bak"
- log "Done, device should reboot now"
- if [[ $mode != "baseband" && $mode != "actrec" ]]; then
- log "Put your device back in kDFU/pwnDFU mode to proceed, then run the script again."
- exit
- fi
- fi
- if [[ ! -e $dump ]]; then
- error "Failed to dump $arg from device. Please run the script again" \
- "* Make sure to have OpenSSH installed."
- fi
- log "Dumping $arg done: $dump"
- }
- device_dumpbb() {
- local bb2="Mav5"
- local root="/"
- local root2="/"
- local tmp="/tmp"
- case $device_type in
- iPhone4,1 ) bb2="Trek";;
- iPhone5,[34] ) bb2="Mav7Mav8";;
- esac
- if [[ $1 == "rd" ]]; then
- root="/mnt1/"
- root2=
- tmp="/mnt2/tmp"
- fi
- log "Creating baseband.tar"
- case $device_vers in
- 5* ) $scp -P $ssh_port [email protected]:${root}usr/standalone/firmware/$bb2-personalized.zip .;;
- 6* ) $scp -P $ssh_port [email protected]:${root}usr/local/standalone/firmware/Baseband/$bb2/$bb2-personalized.zip .;;
- esac
- case $device_vers in
- [56]* )
- mkdir -p usr/local/standalone/firmware/Baseband/$bb2
- file_extract $bb2-personalized.zip usr/local/standalone/firmware/Baseband/$bb2
- cp $bb2-personalized.zip usr/local/standalone/firmware/Baseband/$bb2
- ;;
- * )
- $ssh -p $ssh_port [email protected] "cd $root; tar -cvf $tmp/baseband.tar ${root2}usr/local/standalone/firmware"
- $scp -P $ssh_port [email protected]:$tmp/baseband.tar .
- if [[ ! -s baseband.tar ]]; then
- error "Dumping baseband tar failed. Please run the script again" \
- "* If your device is on iOS 9 or newer, make sure to set the version of the SSH ramdisk correctly."
- fi
- tar -xvf baseband.tar -C .
- rm baseband.tar
- pushd usr/local/standalone/firmware/Baseband/$bb2 >/dev/null
- zip -r0 $bb2-personalized.zip *
- file_extract $bb2-personalized.zip
- popd >/dev/null
- ;;
- esac
- if [[ $device_type == "iPhone4,1" ]]; then
- mkdir -p usr/standalone/firmware
- cp usr/local/standalone/firmware/Baseband/$bb2/$bb2-personalized.zip usr/standalone/firmware
- fi
- tar -cvf baseband-$device_ecid.tar usr
- }
- device_dumprd() {
- local dump="../saved/$device_type"
- local dmps
- local dmp2
- local vers
- local tmp="/mnt2/tmp"
- device_ramdisk_iosvers
- vers=$device_vers
- if [[ -z $vers ]]; then
- warn "Something wrong happened. Failed to get iOS version."
- print "* Please reboot the device into normal operating mode, then perform a clean \"slide to power off\", then try again."
- $ssh -p $ssh_port [email protected] "reboot_bak"
- return
- fi
- log "Mounting filesystems"
- $ssh -p $ssh_port [email protected] "mount.sh"
- sleep 1
- case $device_type in
- iPhone[45]* | iPad2,[67] | iPad3,[56] )
- log "Dumping both baseband and activation tars"
- print "* Reminder to backup dump tars if needed"
- device_dumpbb rd
- if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
- cp baseband-$device_ecid.tar $dump
- else
- warn "bbticket not found in tar. Will not save baseband dump."
- fi
- ;;
- esac
- dmp2="root/Library/Lockdown"
- case $vers in
- [34567]* ) dmps="$dmp2";;
- 8* | 9.[012]* ) dmps="mobile/Library/mad";;
- * )
- dmps="containers/Data/System/*/Library/activation_records"
- dmp2+="/activation_records"
- ;;
- esac
- log "Creating activation.tar"
- $ssh -p $ssh_port [email protected] "mkdir -p $tmp/private/var/$dmp2; cp -R /mnt2/$dmps/* $tmp/private/var/$dmp2"
- #$ssh -p $ssh_port [email protected] "cd $tmp/$dmp2/activation_records; mv *_record.plist activation_record.plist"
- $ssh -p $ssh_port [email protected] "cd $tmp; tar -cvf $tmp/activation.tar private/var/$dmp2"
- log "Copying activation.tar"
- print "* Reminder to backup dump tars if needed"
- $scp -P $ssh_port [email protected]:$tmp/activation.tar .
- if [[ ! -s activation.tar ]]; then
- error "Dumping activation record tar failed. Please run the script again" \
- "* If your device is on iOS 9 or newer, make sure to set the version of the SSH ramdisk correctly."
- fi
- mv activation.tar activation-$device_ecid.tar
- if [[ $(tar -tf activation-$device_ecid.tar | grep -c "_record.plist") != 0 ]]; then
- cp activation-$device_ecid.tar $dump
- else
- warn "Activation record not found in tar. Will not save activation dump."
- fi
- $ssh -p $ssh_port [email protected] "rm -f $tmp/*.tar"
- }
- device_activate() {
- log "Attempting to activate device with ideviceactivation"
- if [[ $device_type == "iPhone"* ]] && (( device_proc <= 4 )); then
- print "* For iPhone 4 and older devices, make sure to have a valid SIM card."
- if (( device_vers_maj <= 6 )); then
- print "* For hacktivation, go to \"Restore/Downgrade\" or \"Hacktivate Device\" instead."
- fi
- fi
- $ideviceactivation activate
- if [[ $device_name == "iPod"* ]] && (( device_vers_maj <= 3 )); then
- $ideviceactivation itunes
- fi
- print "* If it returns an error, just try again."
- device_unactivated=$($ideviceactivation state | grep -c "Unactivated")
- pause
- }
- device_hacktivate() {
- local type="$device_type"
- local build="$device_build"
- if [[ $device_proc == 4 && $device_type != "iPhone2,1" ]]; then
- type="iPhone2,1"
- case $device_vers in
- 4.2.1 ) build="8C148a";;
- 5.1.1 ) build="9B206";;
- 6.1 ) build="10B141";;
- esac
- log "Checking ideviceactivation status..."
- $ideviceactivation activate
- fi
- local patch="../resources/firmware/FirmwareBundles/Down_${type}_${device_vers}_${build}.bundle/lockdownd.patch"
- device_iproxy
- device_sshpass
- if [[ $device_type == "iPhone3,3" && $device_vers == "4.2"* ]]; then
- echo '<plist><dict><key>com.apple.mobile.lockdown_cache-ActivationState</key><string>FactoryActivated</string></dict></plist>' > data_ark.plist
- log "Copying data_ark.plist to device"
- $scp -P $ssh_port data_ark.plist [email protected]:/var/root/Library/Lockdown/data_ark.plist
- $ssh -p $ssh_port [email protected] "reboot"
- log "Done. Your device should reboot now"
- return
- fi
- log "Checking lockdownd"
- local lock="$($ssh -p $ssh_port [email protected] "ls /usr/libexec/lockdownd.orig 2>/dev/null")"
- if [[ -n $lock ]]; then
- warn "Device is already hacktivated. Cannot continue."
- print "* If you want to revert, you may want to select \"Revert Hacktivation\" instead."
- return
- fi
- log "Getting lockdownd"
- $scp -P $ssh_port [email protected]:/usr/libexec/lockdownd .
- log "Patching lockdownd"
- $bspatch lockdownd lockdownd.patched "$patch"
- log "Renaming original lockdownd"
- $ssh -p $ssh_port [email protected] "[[ ! -e /usr/libexec/lockdownd.orig ]] && mv /usr/libexec/lockdownd /usr/libexec/lockdownd.orig"
- log "Copying patched lockdownd to device"
- $scp -P $ssh_port lockdownd.patched [email protected]:/usr/libexec/lockdownd
- $ssh -p $ssh_port [email protected] "chmod +x /usr/libexec/lockdownd; reboot"
- log "Done. Your device should reboot now"
- }
- device_reverthacktivate() {
- device_iproxy
- print "* The default root password is: alpine"
- device_sshpass
- log "Reverting lockdownd"
- $ssh -p $ssh_port [email protected] "[[ -e /usr/libexec/lockdownd.orig ]] && rm /usr/libexec/lockdownd && mv /usr/libexec/lockdownd.orig /usr/libexec/lockdownd"
- $ssh -p $ssh_port [email protected] "chmod +x /usr/libexec/lockdownd; reboot"
- log "Done. Your device should reboot now"
- }
- restore_customipsw_confirm() {
- print "* You are about to restore with a custom IPSW."
- print "* This option is only for restoring with IPSWs NOT made with Legacy iOS Kit, like whited00r or GeekGrade."
- if [[ $device_newbr == 1 ]]; then
- warn "Your device is a new bootrom model and some custom IPSWs might not be compatible."
- [[ $device_type == "iPhone2,1" ]] && print "* For iPhone 3GS, after restoring you will need to go to Useful Utilities -> Install alloc8 Exploit"
- else
- warn "Do NOT use this option for powdersn0w or jailbreak IPSWs made with Legacy iOS Kit!"
- fi
- if [[ $platform == "macos" ]] && [[ $device_type == "iPod2,1" || $device_proc == 1 ]]; then
- echo
- warn "Restoring to 2.x might not work on newer macOS versions."
- print "* Try installing usbmuxd from MacPorts, and run 'sudo usbmuxd -pf' in another Terminal window"
- print "* Another option is to just do 2.x restores on Linux instead."
- print "* For more info, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Troubleshooting#restoring-to-iphoneosios-2x-on-macos"
- fi
- if [[ $device_type == "iPhone1,"* ]]; then
- echo
- print "* Note that you might need to restore twice, due to NOR flash."
- print "* For iPhone 2G/3G, the second restore may fail due to baseband."
- print "* You can exit recovery mode after by going to: Main Menu -> Exit Recovery Mode"
- fi
- select_yesno
- if [[ $? != 1 ]]; then
- return
- fi
- mode="customipsw"
- }
- restore_customipsw() {
- menu_ipsw_browse "custom"
- if [[ -z $ipsw_path ]]; then
- error "No IPSW selected, cannot continue."
- fi
- if [[ $device_proc == 1 ]]; then
- if [[ $device_target_vers == "3.1.3" ]]; then
- device_enter_mode DFU
- else
- device_enter_mode WTFreal
- fi
- else
- device_enter_mode pwnDFU
- fi
- ipsw_custom="$ipsw_path"
- restore_latest custom
- }
- device_dfuipsw_confirm() {
- local msg1="restore"
- local msg2="This"
- if [[ $1 == "ipsw" ]]; then
- msg1="create"
- msg2+=" IPSW"
- fi
- print "* You are about to $msg1 a DFU IPSW."
- print "* $msg2 will force the device to enter DFU mode, which is useful for devices with broken buttons."
- if [[ $1 != "ipsw" ]]; then
- print "* All device data will be wiped! Only proceed if you have backed up your data."
- print "* Expect the restore to fail and the device to be stuck in DFU mode."
- fi
- select_yesno
- if [[ $? != 1 ]]; then
- return
- fi
- mode="device_dfuipsw$1"
- }
- device_dfuipswipsw() {
- device_dfuipsw ipsw
- }
- device_dfuipsw() {
- # the only change done to the "dfu ipsw" is just applelogo copied and renamed to llb
- # replacing llb with an invalid img3/im4p to make the restore fail, the device will then fallback to true dfu mode
- # https://theapplewiki.com/wiki/DFU_Mode#Enter_True_Hardware_DFU_Mode_Automatically
- # this function theoretically works on 64-bit devices, but restoring the dfu ipsw requires entering dfu for pwned restore
- # which defeats the point of doing a dfu ipsw in the first place, so dfu ipsw is available for 32-bit devices only
- local ExtraArgs="-e"
- if [[ $device_proc == 1 ]]; then
- ExtraArgs+="c"
- device_latest_vers="3.1.3"
- device_latest_build="7E18"
- fi
- device_target_vers="$device_latest_vers"
- device_target_build="$device_latest_build"
- ipsw_latest_set
- ipsw_path="../$ipsw_latest_path"
- if [[ -s "$ipsw_path.ipsw" && ! -e "$ipsw_dfuipsw.ipsw" ]]; then
- ipsw_verify "$ipsw_path" "$device_target_build"
- elif [[ ! -e "$ipsw_path.ipsw" ]]; then
- ipsw_download "$ipsw_path"
- fi
- if [[ -s "$ipsw_dfuipsw.ipsw" ]]; then
- log "Found existing DFU IPSW. Skipping IPSW creation."
- else
- cp $ipsw_path.ipsw temp.ipsw
- local llb="${device_model}ap"
- local all="Firmware/all_flash"
- local applelogo
- if (( device_proc >= 6 )); then
- ipsw_hwmodel_set
- case $device_type in
- iPhone9,[13] ) llb="d10";;
- iPhone9,[24] ) llb="d11";;
- iPhone[78]* | iPad6,1* ) llb="$device_model";;
- * ) llb="$ipsw_hwmodel"
- esac
- case $device_type in
- iPhone5,[1234] ) applelogo="applelogo@2x~iphone.s5l8950x.img3";;
- iPad3,[456] ) applelogo="applelogo@2x~ipad.s5l8955x.img3";;
- iPhone* ) applelogo="applelogo@2x~iphone.im4p";;
- iPad* ) applelogo="applelogo@2x~ipad.im4p";;
- esac
- else
- all="$all_flash"
- device_fw_key_check
- applelogo=$(echo $device_fw_key | $jq -j '.keys[] | select(.image == "AppleLogo") | .filename')
- fi
- llb="LLB.$llb.RELEASE"
- if (( device_proc >= 7 )); then
- llb+=".im4p"
- else
- llb+=".img3"
- fi
- mkdir -p $all
- file_extract_from_archive temp.ipsw $all/$applelogo
- mv $applelogo $all/$llb
- zip -r0 temp.ipsw $all/*
- mv temp.ipsw $ipsw_dfuipsw.ipsw
- fi
- if [[ $1 == "ipsw" ]]; then
- return
- fi
- ipsw_path="$ipsw_dfuipsw"
- device_enter_mode Recovery
- ipsw_extract
- log "Running idevicerestore with command: $idevicerestore $ExtraArgs \"$ipsw_path.ipsw\""
- $idevicerestore $ExtraArgs "$ipsw_path.ipsw"
- log "Device should now be stuck in DFU mode"
- print "* You may now restore the device. Run the script again and select Restore/Downgrade"
- }
- device_enter_build() {
- while true; do
- device_rd_build=
- read -p "$(input 'Enter build version (eg. 10B329): ')" device_rd_build
- if [[ -z $device_rd_build ]]; then
- return
- fi
- local last_char=$(echo "$device_rd_build" | rev | cut -c1)
- device_rd_build=$(echo "$device_rd_build" | tr '[:lower:]' '[:upper:]') # to uppercase
- # If last char was a lowercase letter, make it lowercase again
- if echo "$last_char" | grep -Eq '^[a-z]$'; then
- device_rd_build=$(echo "$device_rd_build" | rev | cut -c2- | rev)
- device_rd_build=${device_rd_build}${last_char}
- fi
- # Match pattern: digits + uppercase letters + digits + optional lowercase letter
- echo "$device_rd_build" | grep -Eq '^[0-9]+[A-Z]+[0-9]+[a-z]?$' && break
- log "Build version input is not valid. Please try again"
- done
- }
- menu_justboot() {
- local menu_items
- local selected
- local back
- local vers
- local recent="../saved/$device_type/justboot_${device_ecid}"
- # Store original device info to prevent it from being overwritten
- local original_device_type="$device_type"
- local original_device_ecid="$device_ecid"
- local original_device_name="$device_name"
- while [[ -z "$mode" && -z "$back" ]]; do
- menu_items=()
- # Add Connected Device option first if it exists in boot history
- if [[ -s "$recent" ]]; then
- # Use stored device name to avoid overwriting global variables
- menu_items+=("Connected Device [$original_device_name]")
- fi
- # Add other options
- menu_items+=("Enter Build Version" "Select IPSW")
- # Check for boot history files for current device type
- local history_count=$(find "../saved/$device_type" -name "justboot_*" -type f 2>/dev/null | wc -l)
- # Also check for any boot history files regardless of device type
- local total_history_count=$(find "../saved" -name "justboot_*" -type f 2>/dev/null | wc -l)
- if [[ $history_count -gt 0 ]]; then
- menu_items+=("Boot History")
- elif [[ $total_history_count -gt 0 ]]; then
- menu_items+=("Boot History (All Devices)")
- fi
- menu_items+=("Custom Bootargs")
- if [[ $device_type == "iPod4,1" ]]; then
- menu_items+=("(*) iOS 7.1.2")
- fi
- if [[ -n $vers ]]; then
- menu_items+=("(*) Just Boot")
- fi
- menu_items+=("Go Back")
- menu_print_info
- print " > Main Menu > Just Boot"
- print "* You are about to do a tethered boot."
- print "* To know more about build version, go here: https://theapplewiki.com/wiki/Firmware"
- echo
- if [[ -n $ipsw_justboot_path ]]; then
- print "* Selected IPSW: $ipsw_justboot_path.ipsw"
- print "* IPSW Version: $device_target_vers-$device_target_build"
- elif [[ -n $vers ]]; then
- print "* Build Version entered: $vers"
- else
- print "* Enter build version or select IPSW to continue"
- fi
- echo
- if [[ -n $device_bootargs ]]; then
- print "* Custom Bootargs: $device_bootargs"
- else
- print "* You may enter custom bootargs (optional, experimental option)"
- print "* Default Bootargs: pio-error=0 -v"
- fi
- echo
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Enter Build Version" )
- print "* Enter the build version of your device's current iOS version to boot."
- device_enter_build
- case $device_rd_build in
- *[bcdefgkmpquv] )
- log "iOS beta detected. Entering build version is not supported. Select the IPSW instead."
- pause
- continue
- ;;
- esac
- ipsw_justboot_path=
- vers="$device_rd_build"
- ;;
- "Select IPSW" )
- menu_ipsw_browse
- ipsw_justboot_path="$ipsw_path"
- vers="$device_target_build"
- device_rd_build="$vers"
- ;;
- "Connected Device ["* )
- vers="$(cat $recent)"
- device_rd_build="$vers"
- log "Selected connected device build version: $vers"
- ;;
- "Boot History" | "Boot History (All Devices)" )
- vers=
- menu_justboot_history
- if [[ -n $vers ]]; then
- device_rd_build="$vers"
- fi
- # Restore original device info after history menu
- device_type="$original_device_type"
- device_ecid="$original_device_ecid"
- device_name="$original_device_name"
- ;;
- "(*) Just Boot" )
- echo "$vers" > $recent
- mode="device_justboot"
- if [[ $device_type == "iPod4,1" && $vers == "11"* ]]; then
- mode="device_justboot_touch4ios7"
- fi
- ;;
- "(*) iOS 7.1.2" )
- echo "11D257" > $recent
- mode="device_justboot_touch4ios7"
- ;;
- "Custom Bootargs" ) read -p "$(input 'Enter custom bootargs: ')" device_bootargs;;
- "Go Back" ) back=1;;
- esac
- done
- }
- menu_justboot_history() {
- local menu_items=()
- local selected
- local back
- local history_files
- local saved_dir="../saved"
- history_files=($(find "$saved_dir" -name "justboot_*" -type f 2>/dev/null -exec ls -t {} +))
- if [[ ${#history_files[@]} -eq 0 ]]; then
- warn "No boot history found"
- pause
- return
- fi
- # Add all devices in chronological order (newest first)
- for file in "${history_files[@]}"; do
- local device_type_from_file=$(basename "$(dirname "$file")")
- local ecid=$(basename "$file" | sed 's/justboot_//')
- local build_version=$(cat "$file" 2>/dev/null | tr -d '\n')
- # Get device name
- local device_name=""
- local temp_device_type="$device_type_from_file"
- device_type="$temp_device_type"
- device_get_name
- device_name="$device_name"
- # Get iOS version - prioritize firmwares.json as it's more reliable
- local ios_version=""
- # First try firmwares.json (most reliable)
- local firmwares_file=""
- for path in "$saved_dir/firmwares.json" "saved/firmwares.json" "../saved/firmwares.json"; do
- if [[ -s "$path" ]]; then
- firmwares_file="$path"
- break
- fi
- done
- # Download firmwares.json if not found
- if [[ -z "$firmwares_file" ]]; then
- log "Downloading firmwares.json for iOS version lookup..."
- file_download https://api.ipsw.me/v2.1/firmwares.json/condensed firmwares.json
- mv firmwares.json "$saved_dir"
- firmwares_file="$saved_dir/firmwares.json"
- fi
- if [[ -n "$firmwares_file" ]]; then
- ios_version=$(cat "$firmwares_file" | $jq -r --arg build "$build_version" '
- [.. | objects | select(.buildid == $build) | .version] |
- if length > 0 then .[0] else empty end' 2>/dev/null)
- fi
- # Fallback to ver file if firmwares.json didn't work
- if [[ -z "$ios_version" ]]; then
- local ver_file="$saved_dir/$device_type_from_file/ver_$build_version"
- if [[ -s "$ver_file" ]]; then
- ios_version=$(cat "$ver_file" 2>/dev/null | tr -d '\n')
- if [[ "$ios_version" == *".dmg" ]]; then
- local beta_version=$(echo "$ios_version" | sed 's/ios_\([0-9]*\)_beta.*/\1/')
- if [[ "$beta_version" != "$ios_version" && -n "$beta_version" ]]; then
- ios_version="${beta_version}.0 Beta"
- else
- ios_version="Beta"
- fi
- elif [[ "$ios_version" == "?" ]]; then
- ios_version=""
- fi
- fi
- fi
- if [[ -z "$ios_version" ]]; then
- ios_version="Build $build_version"
- fi
- if [[ -n "$build_version" ]]; then
- # Format device name
- local display_name="$device_name"
- if [[ ${#display_name} -gt 18 ]]; then
- display_name="${display_name:0:15}..."
- fi
- # Format iOS version
- local display_ios="$ios_version"
- if [[ ${#display_ios} -gt 12 ]]; then
- display_ios="${display_ios:0:9}..."
- fi
- local menu_item="$(printf "%-20s | %-15s | %s" "$display_name" "$display_ios" "$build_version")"
- menu_items+=("$menu_item")
- fi
- done
- menu_items+=("Go Back")
- while [[ -z "$vers" && -z "$back" ]]; do
- menu_print_info
- print " > Main Menu > Just Boot > Boot History"
- print "* Select a build version from your boot history:"
- echo
- input "Select an option:"
- select_option "${menu_items[@]}"
- selected="${menu_items[$?]}"
- case $selected in
- "Go Back" )
- back=1
- ;;
- * )
- vers=$(echo "$selected" | awk -F'|' '{print $3}' | tr -d ' ')
- if [[ -n "$vers" ]]; then
- log "Selected build version: $vers"
- else
- warn "Could not extract build version from selection"
- fi
- ;;
- esac
- done
- }
- device_justboot() {
- if [[ -z $device_bootargs ]]; then
- device_bootargs="pio-error=0 -v"
- fi
- if [[ $main_argmode == "device_justboot" ]]; then
- cat "$device_rd_build" > "../saved/$device_type/justboot_${device_ecid}"
- fi
- if [[ $device_rd_build == "14"* ]]; then
- device_enter_mode DFU
- kuroutadori_init
- kuroutadori_litera1n -T
- return
- fi
- device_ramdisk justboot
- }
- device_justboot_touch4ios7() {
- local patches="../resources/patch/touch4-ios7"
- local saves="../saved/touch4-ios7"
- if [[ -d "../saved/$device_type/touch4-ios7" ]]; then
- mv "../saved/$device_type/touch4-ios7" $saves
- fi
- if [[ ! -s $saves/$device_ecid ]]; then
- error "Cannot find device file for $device_ecid in saved. Need to restore to iOS 7.1.2 first."
- fi
- source $saves/$device_ecid
- [[ -z $device_target_build ]] && device_target_build="11D257"
- log "device_target_build=$device_target_build"
- device_enter_mode pwnDFU
- device_rd_build=
- patch_ibss
- log "Sending iBSS..."
- $irecovery -f pwnediBSS.dfu
- sleep 1
- log "Sending iBEC..."
- $irecovery -f $saves/pwnediBEC.dfu
- device_find_mode Recovery
- log "devicetree"
- $irecovery -f $patches/DeviceTree.n81ap.img3
- $irecovery -c devicetree
- log "kernelcache"
- $irecovery -f $saves/$device_target_build/kernelcache
- $irecovery -c bootx
- log "Device should now boot."
- }
- device_enter_ramdisk() {
- if (( device_proc > 7 )); then
- :
- elif [[ $device_proc == 7 ]]; then
- input "Version Select Option"
- print "* The version of the SSH Ramdisk is set to iOS 12 by default. This is the recommended option."
- print "* There is also an option to use iOS 8 ramdisk. This can be used to fix devices on iOS 7 not booting after using iOS 12 ramdisk."
- print "* If not sure, just press Enter/Return. This will select the default version."
- select_yesno "Select Y to use iOS 12, select N to use iOS 8" 1
- if [[ $? != 1 ]]; then
- device_ramdisk_ios8=1
- fi
- elif (( device_proc >= 5 && device_vers_maj >= 9 )); then
- log "Device is on iOS 9+, using 9.0.2 (13A452) ramdisk"
- device_rd_build="13A452"
- elif (( device_proc >= 5 )) && [[ $device_mode == "Normal" ]]; then
- :
- elif (( device_proc >= 5 )) && [[ -z $device_rd_build ]]; then
- print "* To mount /var (/mnt2) for iOS 9-10, I recommend using version 9.0.2 (13A452)."
- print "* Do not use iOS 9+ ramdisks if your device is on iOS 8 or lower, and vice versa."
- print "* If not sure, just leave it blank and press Enter/Return. This will select the default version."
- device_enter_build
- fi
- if [[ $1 == "menu" ]]; then
- [[ $debug_mode != 1 ]] && clear
- device_iproxy no-logging
- device_sshpass alpine
- menu_ramdisk
- return
- fi
- if (( device_proc >= 7 )); then
- device_ramdisk64 $1
- else
- device_ramdisk $1
- fi
- }
- device_enter_ramdisk_menu() {
- device_enter_ramdisk menu
- }
- device_ideviceinstaller() {
- device_pair
- log "Installing selected IPA(s) to device using ideviceinstaller..."
- IFS='|' read -r -a ipa_files <<< "$ipa_path"
- for i in "${ipa_files[@]}"; do
- log "Installing: $i"
- $ideviceinstaller install "$i"
- done
- }
- device_appinst() {
- device_iproxy no-logging
- device_ssh_message
- device_sshpass
- log "Checking for appinst..."
- $ssh -p $ssh_port root@127.0.0.1 "appinst >/dev/null"
- if [[ $? != 6 ]]; then
- warn "appinst not detected. Please install appinst and OpenSSH first before using this option."
- kill $iproxy_pid
- return
- fi
- log "Installing selected IPA(s) to device using appinst..."
- IFS='|' read -r -a ipa_files <<< "$ipa_path"
- for i in "${ipa_files[@]}"; do
- local app="$(basename "$i")"
- log "Transferring: $app"
- $scp -P $ssh_port "$i" root@127.0.0.1:/tmp
- log "Installing: $app"
- $ssh -p $ssh_port root@127.0.0.1 "appinst '/tmp/$app'; rm '/tmp/$app'"
- done
- kill $iproxy_pid
- }
- device_altserver() {
- local altserver="../saved/AltServer-$platform"
- local sha1="4bca48e9cda0517cc965250a797f97d5e8cc2de6"
- local anisette="../saved/anisette-server-$platform"
- local arch="$platform_arch"
- if [[ $arch == "arm64" ]]; then
- arch="aarch64"
- sha1="535926e5a14dc8f59f3f99197ca4122c7af8dfaf"
- fi
- altserver+="_$arch"
- anisette+="_$arch"
- if [[ $($sha1sum $altserver 2>/dev/null | awk '{print $1}') != "$sha1" ]]; then
- rm -f $altserver
- fi
- if [[ ! -e $altserver ]]; then
- file_download https://github.com/NyaMisty/AltServer-Linux/releases/download/v0.0.5/AltServer-$arch AltServer-$arch
- mv AltServer-$arch $altserver
- fi
- log "Checking for latest anisette-server"
- download_from_url "https://api.github.com/repos/LukeZGD/Provision/releases/latest" latest
- local latest="$(cat latest | $jq -r ".tag_name")"
- local current="$(cat ../saved/anisette-server_version 2>/dev/null || echo "none")"
- log "Latest version: $latest, current version: $current"
- if [[ $current != "$latest" ]]; then
- rm -f $anisette
- fi
- if [[ ! -e $anisette ]]; then
- file_download https://github.com/LukeZGD/Provision/releases/download/$latest/anisette-server-$arch anisette-server-$arch
- mv anisette-server-$arch $anisette
- echo "$latest" > ../saved/anisette-server_version
- fi
- chmod +x $altserver $anisette
- log "Running Anisette"
- $anisette &
- anisette_pid=$!
- log "Anisette PID: $anisette_pid"
- local ready=0
- log "Waiting for Anisette"
- while [[ $ready != 1 ]]; do
- [[ $($curl 127.0.0.1:6969 2>/dev/null) ]] && ready=1
- sleep 1
- done
- export ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969
- altserver="env ALTSERVER_ANISETTE_SERVER=$ALTSERVER_ANISETTE_SERVER $altserver"
- device_pair
- log "Enter Apple ID details to continue."
- print "* Your Apple ID and password will only be sent to Apple servers."
- local apple_id
- local apple_pass
- while [[ -z $apple_id ]]; do
- read -p "$(input 'Apple ID: ')" apple_id
- done
- print "* Your password input may not be visible, but it is still being entered."
- while [[ -z $apple_pass ]]; do
- read -s -p "$(input 'Password: ')" apple_pass
- done
- echo
- log "Running AltServer-Linux with given Apple ID details..."
- pushd ../saved >/dev/null
- $altserver -u $device_udid -a "$apple_id" -p "$apple_pass" "$ipa_path"
- popd >/dev/null
- }
- device_dumpapp() {
- device_iproxy
- device_ssh_message
- echo
- warn "The dump apps feature is not actively maintained/supported and may have issues."
- print "* If you encounter any issue, try going here instead: https://www.reddit.com/r/LegacyJailbreak/wiki/guides/crackingapps"
- device_sshpass
- local dumper_binary="ipainstaller"
- local selected2
- local selected3="ipainstaller" # Default for everyone else
- if (( device_vers_maj >= 5 && device_vers_maj <= 11 )) || (( device_vers_maj == 12 && device_vers_min < 1 )); then
- available_dumpers=("ipainstaller" "Clutch" "Go Back")
- echo
- print "* You should choose ipainstaller over Clutch for dumping most apps."
- print "* However, Clutch may dump some apps better, albeit with lower success rates."
- input "Choose one of the listed app dumper to use."
- select_option "${available_dumpers[@]}"
- selected3="${available_dumpers[$?]}"
- case $selected3 in
- "Clutch" )
- case $device_vers_maj in
- 5 ) dumper_binary="clutch13";; # iOS 5
- [67] ) dumper_binary="clutch204";; # iOS 6 - 7
- * ) dumper_binary="clutch";; # iOS 8 - 12.0.x
- esac
- ;;
- "Go Back" ) kill $iproxy_pid; return;;
- * ) :;;
- esac
- fi
- if [[ $dumper_binary == "ipainstaller" ]] && (( device_vers_maj <= 10 )); then
- dumper_binary="ipainstaller_legacy"
- fi
- local dumper="../resources/appdump/$dumper_binary"
- log "Sending $selected3 to device"
- if [[ $device_vers_maj == 10 ]]; then
- cat $dumper | $ssh -p $ssh_port root@127.0.0.1 "cat > /tmp/$dumper_binary" &>scp.log &
- $ssh -p $ssh_port root@127.0.0.1 "chmod +x /tmp/$dumper_binary"
- sleep 3
- cat scp.log
- check="$(cat scp.log | grep -c "Connection reset")"
- else
- $scp -P $ssh_port $dumper root@127.0.0.1:/tmp
- local check=$?
- fi
- device_pair
- local available_apps_base="$($ideviceinstaller list --user)"
- local available_apps_json="["
- while IFS= read -r line; do
- [[ $line == CFBundleIdentifier* ]] && continue
- IFS=', ' read -r CFBundleIdentifier CFBundleShortVersionString CFBundleDisplayName <<< "$line"
- CFBundleShortVersionString="${CFBundleShortVersionString//\"/}"
- CFBundleDisplayName="${CFBundleDisplayName//\"/}"
- available_apps_json+="{\"CFBundleIdentifier\":\"$CFBundleIdentifier\","
- available_apps_json+="\"CFBundleShortVersionString\":\"$CFBundleShortVersionString\","
- available_apps_json+="\"CFBundleDisplayName\":\"$CFBundleDisplayName\"},"
- done <<< "$available_apps_base"
- available_apps_json="${available_apps_json%,}]"
- local available_apps=($(echo "$available_apps_json" | $jq -r 'to_entries[] | .value.CFBundleIdentifier' | tr '\n' ' '))
- local all_apps=("${available_apps[@]}")
- available_apps+=("Go Back")
- local app_index=0
- if [[ $check == 0 ]]; then
- mkdir -p ../saved/applications
- while true; do
- if [[ $1 == "all" ]]; then
- selected2="${all_apps[$app_index]}"
- if [[ -z $selected2 ]]; then
- break
- fi
- else
- echo
- print "* Select an app listed below to dump as IPA."
- select_option "${available_apps[@]}"
- app_index=$?
- selected2="${available_apps[$app_index]}"
- case $selected2 in
- "Go Back" ) break;;
- esac
- fi
- log "Dumping $selected2 with $selected3"
- print "* This process may take up to 5 minutes depending on the hardware and app size."
- print "* If the dumping gets stuck, you can press Ctrl+C to cancel, then retry."
- case $selected3 in
- "ipainstaller" )
- $ssh -p $ssh_port root@127.0.0.1 "rm -f /tmp/$selected2.ipa" # Ensure target output path is empty
- $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary -b $selected2 -o /tmp/$selected2.ipa"
- check=$?
- ;;
- "Clutch" )
- local ipa
- if [[ $device_vers_maj == 5 ]]; then
- $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary $(echo "$available_apps_json" | $jq --argjson i $app_index -r 'to_entries[$i] | .value.CFBundleDisplayName')" &>ssh.log
- ipa="$(cat ssh.log | grep "/var/root/Documents/Cracked/"| tr -d "\t")"
- else
- $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary -d $selected2" &>ssh.log
- ipa="$(cat ssh.log | grep "/private/var/mobile/Documents/Dumped/" | cut -d ' ' -f2)"
- fi
- $ssh -p $ssh_port root@127.0.0.1 "mv \"$ipa\" /tmp/$selected2.ipa"
- check=$?
- cat ssh.log
- ;;
- esac
- if [[ $check == 0 ]]; then
- local ipa_name="$(echo "$available_apps_json" | $jq --argjson i $app_index -r 'to_entries[$i].value | if (.CFBundleDisplayName == "") then .CFBundleIdentifier else .CFBundleDisplayName end + " " + .CFBundleShortVersionString').ipa"
- $scp -P $ssh_port root@127.0.0.1:/tmp/$selected2.ipa "../saved/applications"
- $ssh -p $ssh_port root@127.0.0.1 "rm /tmp/$selected2.ipa"
- mv "../saved/applications/$selected2.ipa" "../saved/applications/$ipa_name"
- log "Dumped successfully: saved/applications/$ipa_name"
- else
- warn "Failed to dump $selected2"
- pause
- fi
- if [[ $1 == "all" ]]; then
- ((app_index++))
- fi
- done
- else
- warn "Failed to connect to device via USB SSH."
- if [[ $device_vers_maj == 10 ]]; then
- print "* Try to re-install both OpenSSH and Dropbear, reboot, re-jailbreak, and try again."
- elif (( device_vers_maj <= 8 )); then
- print "* Try to re-install OpenSSH, reboot, and try again."
- else
- print "* Try to re-install OpenSSH, reboot, re-jailbreak, and try again."
- fi
- error "Failed to connect to device via SSH, cannot continue."
- fi
- kill $iproxy_pid
- }
- device_fourthree_step2() {
- if [[ $device_mode != "Normal" ]]; then
- error "Device is not in normal mode. Place the device in normal mode to proceed." \
- "* The device must also be restored already with Step 1: Restore."
- fi
- print "* Make sure that the device is already restored with Step 1: Restore before proceeding."
- pause
- device_iproxy
- device_sshpass alpine
- device_fourthree_check 2
- if [[ $? == 2 ]]; then
- warn "Step 2 has already been completed. Cannot continue."
- return
- fi
- print "* How much GB do you want to allocate/leave to the 6.1.3 data partition?"
- print "* The rest of the space will be allocated to the 4.3.x system."
- print "* If unsure, set it to 3 (this means 3 GB for 6.1.3, the rest for 4.3.x)."
- local size
- until [[ -n $size ]] && [ "$size" -eq "$size" ]; do
- read -p "$(input 'iOS 6.1.3 Data Partition Size (in GB): ')" size
- done
- log "iOS 6.1.3 Data Partition Size: $size GB"
- size=$((size*1024*1024*1024))
- log "Sending package files"
- $scp -P $ssh_port $jelbrek/dualbootstuff.tar root@127.0.0.1:/tmp
- log "Installing packages"
- $ssh -p $ssh_port root@127.0.0.1 "tar -xvf /tmp/dualbootstuff.tar -C /; dpkg -i /tmp/dualbootstuff/*.deb"
- log "Running TwistedMind2"
- $ssh -p $ssh_port root@127.0.0.1 "rm /TwistedMind2*; TwistedMind2 -d1 $size -s2 879124480 -d2 max"
- $scp -P $ssh_port root@127.0.0.1:$tm2 TwistedMind2
- kill $iproxy_pid
- log "Rebooting to SSH ramdisk for the next procedure"
- device_ramdisk TwistedMind2
- log "Done, proceed to Step 3 after the device boots"
- }
- device_fourthree_step3() {
- if [[ $device_mode != "Normal" ]]; then
- error "Device is not in normal mode. Place the device in normal mode to proceed." \
- "* The device must also be set up already with Step 2: Partition."
- fi
- print "* Make sure that the device is set up with Step 2: Partition before proceeding."
- pause
- source ../saved/$device_type/fourthree_$device_ecid
- log "4.3.x version: $device_base_vers-$device_base_build"
- local saved_path="../saved/$device_type/$device_base_build"
- device_iproxy
- device_sshpass alpine
- device_fourthree_check 3
- if [[ $? == 0 ]]; then
- warn "Step 3 has already been completed. Cannot continue."
- return
- fi
- log "Creating filesystems"
- $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt1 /mnt2"
- $ssh -p $ssh_port root@127.0.0.1 "/sbin/newfs_hfs -s -v System -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s3"
- $ssh -p $ssh_port root@127.0.0.1 "/sbin/newfs_hfs -s -v Data -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s4"
- log "Sending root filesystem, this will take a while."
- $scp -P $ssh_port $saved_path/RootFS.dmg root@127.0.0.1:/var
- log "Restoring root filesystem"
- $ssh -p $ssh_port root@127.0.0.1 "echo 'y' | asr restore --source /var/RootFS.dmg --target /dev/disk0s3 --erase"
- log "Checking root filesystem"
- $ssh -p $ssh_port root@127.0.0.1 "rm /var/RootFS.dmg; fsck_hfs -f /dev/disk0s3"
- log "Restoring data partition"
- $ssh -p $ssh_port root@127.0.0.1 "mount_hfs /dev/disk0s3 /mnt1; mount_hfs /dev/disk0s4 /mnt2; mv /mnt1/private/var/* /mnt2"
- log "Fixing fstab"
- $ssh -p $ssh_port root@127.0.0.1 "echo '/dev/disk0s3 / hfs rw 0 1' | tee /mnt1/private/etc/fstab; echo '/dev/disk0s4 /private/var hfs rw 0 2' | tee -a /mnt1/private/etc/fstab"
- if [[ $device_type != "iPad2,1" ]]; then
- log "Getting lockdownd"
- $scp -P $ssh_port root@127.0.0.1:/mnt1/usr/libexec/lockdownd .
- local patch="../resources/firmware/FirmwareBundles/Down_iPhone2,1_${device_base_vers}_${device_base_build}.bundle/lockdownd.patch"
- log "Patching lockdownd"
- $bspatch lockdownd lockdownd.patched "$patch"
- log "Renaming original lockdownd"
- $ssh -p $ssh_port root@127.0.0.1 "mv /mnt1/usr/libexec/lockdownd /mnt1/usr/libexec/lockdownd.orig"
- log "Copying patched lockdownd to device"
- $scp -P $ssh_port lockdownd.patched root@127.0.0.1:/mnt1/usr/libexec/lockdownd
- $ssh -p $ssh_port root@127.0.0.1 "chmod +x /mnt1/usr/libexec/lockdownd"
- fi
- log "Fixing system keybag"
- $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt2/keybags; ttbthingy; fixkeybag -v2; cp /tmp/systembag.kb /mnt2/keybags"
- log "Remounting data partition"
- $ssh -p $ssh_port root@127.0.0.1 "umount /mnt2; mount_hfs /dev/disk0s4 /mnt1/private/var"
- # idk if copying activation records actually works, probably not
- log "Copying activation records"
- local dmp="private/var/root/Library/Lockdown"
- $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt1/$dmp; cp -Rv /$dmp/* /mnt1/$dmp"
- log "Installing jailbreak"
- cp $jelbrek/freeze.tar.gz .
- gzip -d freeze.tar.gz
- cat freeze.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xvf - -C /mnt1"
- if [[ $ipsw_openssh == 1 ]]; then
- log "Installing OpenSSH"
- cat $jelbrek/sshdeb.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xvf - -C /mnt1"
- cp $jelbrek/openssh.tar.gz $jelbrek/openssl.tar.gz .
- gzip -d openssh.tar.gz
- gzip -d openssl.tar.gz
- cat openssh.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xf - -C /mnt1"
- cat openssl.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xf - -C /mnt1"
- fi
- log "Unmounting filesystems"
- $ssh -p $ssh_port root@127.0.0.1 "umount /mnt1/private/var; umount /mnt1"
- log "Sending Kernelcache and LLB"
- $scp -P $ssh_port $saved_path/Kernelcache root@127.0.0.1:/System/Library/Caches/com.apple.kernelcaches/kernelcachb
- $scp -P $ssh_port $saved_path/LLB root@127.0.0.1:/LLB
- device_fourthree_app install
- log "Done!"
- }
- device_fourthree_app() {
- if [[ $1 != "install" ]]; then
- device_iproxy
- print "* The default root password is: alpine"
- device_sshpass
- fi
- device_fourthree_check
- log "Installing FourThree app"
- $scp -P $ssh_port $jelbrek/fourthree.tar root@127.0.0.1:/tmp
- $ssh -p $ssh_port root@127.0.0.1 "tar -h -xvf /tmp/fourthree.tar -C /; cd /Applications/FourThree.app; chmod 6755 boot.sh FourThree kloader_ios5 /usr/bin/runasroot"
- device_uicache $1
- }
- device_fourthree_boot() {
- device_iproxy
- print "* The default root password is: alpine"
- device_sshpass
- device_fourthree_check
- log "Running FourThree Boot"
- $ssh -p $ssh_port root@127.0.0.1 "/Applications/FourThree.app/FourThree"
- }
- device_fourthree_check() {
- local opt=$1
- local check
- log "Checking if Step 1 is complete"
- check="$($ssh -p $ssh_port [email protected] "ls /dev/disk0s2s1")"
- if [[ $check != "/dev/disk0s2s1" ]]; then
- error "Cannot find /dev/disk0s2s1. Something went wrong with Step 1" \
- "* Redo the FourThree process from Step 1"
- fi
- if [[ $opt == 1 ]]; then
- return 1
- fi
- log "Checking if Step 2 is complete"
- check="$($ssh -p $ssh_port [email protected] "ls /dev/disk0s3 2>/dev/null")"
- if [[ $check != "/dev/disk0s3" ]]; then
- if [[ $opt == 2 ]]; then
- log "Step 2 is not complete. Proceeding"
- return 1
- fi
- error "Cannot find /dev/disk0s3. Something went wrong with Step 2" \
- "* Redo the FourThree process from Step 2"
- fi
- if [[ $opt == 2 ]]; then
- return 2
- fi
- log "Checking if Step 3 is complete"
- local kcb="/System/Library/Caches/com.apple.kernelcaches/kernelcachb"
- if [[ $kc != "$kcb" || $llb != "/LLB" ]]; then
- if [[ $opt == 3 ]]; then
- log "Step 3 is not complete. Proceeding"
- return 2
- fi
- error "Cannot find Kernelcache/LLB. Something went wrong with Step 3" \
- "* Redo the FourThree process from Step 3"
- fi
- return 0
- }
- device_uicache() {
- if [[ $1 != "install" ]]; then
- device_iproxy
- print "* The default root password is: alpine"
- device_sshpass
- fi
- log "Running uicache"
- $ssh -p $ssh_port mobile@127.0.0.1 "uicache"
- }
- device_backup_create() {
- device_backup="../saved/backups/${device_ecid}_${device_type}/$(date +%Y-%m-%d-%H%M)"
- device_pair
- mkdir -p $device_backup
- pushd "$(dirname $device_backup)"
- dir="../../$dir"
- export LD_LIBRARY_PATH="$dir/lib"
- "$dir/idevicebackup2" backup --full "$(basename $device_backup)"
- popd
- }
- device_backup_restore() {
- device_backup="../saved/backups/${device_ecid}_${device_type}/$device_backup"
- device_pair
- pushd "$(dirname $device_backup)"
- dir="../../$dir"
- export LD_LIBRARY_PATH="$dir/lib"
- "$dir/idevicebackup2" restore --system --settings "$(basename $device_backup)"
- popd
- }
- device_erase() {
- print "* You have selected the option to Erase All Content and Settings."
- print "* As the option says, it will erase all data on the device and reset it to factory settings."
- print "* By the end of the operation, the device will be back on the setup screen."
- print "* If you want to proceed, please type the following: Yes, do as I say"
- read -p "$(input 'Do you want to proceed? ')" opt
- if [[ $opt != "Yes, do as I say" ]]; then
- error "Not proceeding."
- fi
- log "Proceeding."
- "$dir/idevicebackup2" erase
- }
- device_trollrestore() {
- local trollrestore="../saved/TrollRestore"
- local venv="${trollrestore}_venv"
- device_pair
- if [[ ! -d $trollrestore ]]; then
- log "Downloading TrollRestore"
- file_download https://github.com/JJTech0130/TrollRestore/releases/download/1.0/TrollRestore_Linux.zip TrollRestore_Linux.zip 0673de2ebb9d17351231d6d6a615bb0933e43b0a
- mkdir -p $trollrestore
- file_extract TrollRestore_Linux.zip $trollrestore
- fi
- if [[ ! -d $venv || ! -s $venv/bin/python3 ]]; then
- log "Creating venv"
- python3 -m venv $venv
- fi
- if [[ ! -d $venv || ! -s $venv/bin/python3 ]]; then
- error "Creation of venv seems to have failed. Please run the script again" \
- "* If you do not have Python 3 installed, install it since TrollRestore requires it."
- fi
- log "Installing dependencies using pip..."
- sed -i.bak '1s/.*/pymobiledevice3<=6.2.0/' $trollrestore/requirements.txt
- $venv/bin/pip install -r $trollrestore/requirements.txt
- log "Running TrollRestore..."
- print "* When it prompts to enter app name, type Tips and press Enter/Return"
- "$(cd .. && pwd)/saved/TrollRestore_venv/bin/python3" $trollrestore/trollstore.py
- }
- main() {
- if [[ $debug_mode != 1 ]]; then
- clear
- fi
- print " *** Legacy iOS Kit ***"
- print " - Script by LukeZGD -"
- echo
- version_get
- if [[ $EUID == 0 && $run_as_root != 1 ]]; then
- error "Running the script as root is not allowed."
- fi
- if [[ ! -d "../resources" ]]; then
- error "The resources folder cannot be found. Replace resources folder and try again." \
- "* If resources folder is present try removing spaces from path/folder name"
- fi
Advertisement