From 987902ad901133e044d6506211c3c730c34dc4e1 Mon Sep 17 00:00:00 2001 From: LukeZGD Date: Tue, 12 Oct 2021 15:02:37 +0800 Subject: [PATCH] Move option selections at the start also add better messages --- resources/device.sh | 11 +++-- resources/downgrade.sh | 108 ++++++++++++++++++++++++++--------------- resources/ipsw.sh | 9 +--- restore.sh | 3 ++ 4 files changed, 81 insertions(+), 50 deletions(-) diff --git a/resources/device.sh b/resources/device.sh index 3076c9a..53f2f96 100755 --- a/resources/device.sh +++ b/resources/device.sh @@ -67,7 +67,8 @@ GetDeviceValues() { if [[ ! $DeviceState ]]; then echo -e "\n${Color_R}[Error] No device detected. Please put the device in normal mode before proceeding. ${Color_N}" - echo "${Color_Y}* Make sure to also trust this computer by selecting \"Trust\" at the pop-up. For Windows/macOS users, double-check if the device is being detected by iTunes/Finder. ${Color_N}" + echo "${Color_Y}* Make sure to also trust this computer by selecting \"Trust\" at the pop-up. ${Color_N}" + echo "${Color_Y}* For Windows/macOS users, double-check if the device is being detected by iTunes/Finder. ${Color_N}" echo "${Color_Y}* Recovery or DFU mode is also applicable. For more details regarding alternative methods, read the \"Troubleshooting\" wiki page in GitHub ${Color_N}" exit 1 fi @@ -156,6 +157,7 @@ GetDeviceValues() { SEP="sep-firmware.$HWModel.RELEASE.im4p" Log "Found $ProductType in $DeviceState mode." + Log "Device ECID: $UniqueChipID" } CheckM8() { @@ -296,7 +298,8 @@ kDFU() { Echo "* To make sure that SSH is successful, try these steps:" Echo "* Reinstall OpenSSH/Dropbear, reboot and rejailbreak, then reinstall them again" echo - Input "Enter the root password of your iOS device when prompted" + Input "Enter the root password of your iOS device when prompted." + Echo "* Note that you will be prompted twice. Do not worry that your input is not visible, it is still being entered." Echo "* The default password is \"alpine\"" $SCP -P 2222 resources/tools/$kloader tmp/pwnediBSS root@127.0.0.1:/tmp if [[ $? == 0 ]]; then @@ -304,7 +307,7 @@ kDFU() { else Log "Cannot connect to device via USB SSH." Echo "* Please try the steps above to make sure that SSH is successful" - Echo "* Alternatively, you may use kDFUApp by tihmstar (from my repo, see README)" + Echo "* Alternatively, you may use kDFUApp by tihmstar (from my repo, see \"Troubleshooting\" wiki page)" Input "Press Enter/Return to continue anyway (or press Ctrl+C to cancel and try again)" read -s Log "Will try again with Wi-Fi SSH..." @@ -321,7 +324,7 @@ kDFU() { fi Log "Entering kDFU mode..." - Echo "* Press POWER or HOME button when screen goes black on the device" + Echo "* Press POWER or HOME button when the device disconnects and its screen goes black" FindDevice "DFU" } diff --git a/resources/downgrade.sh b/resources/downgrade.sh index 46d12f0..898929a 100755 --- a/resources/downgrade.sh +++ b/resources/downgrade.sh @@ -72,26 +72,36 @@ Downgrade() { local IPSWSHA1 local IPSWSHA1L local Jailbreak + local JBName local Verify + Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)." + echo + if [[ $OSVer == "Other" ]]; then if [[ $platform == "linux" ]]; then + Input "Select your IPSW file in the file selection window." IPSW="$(zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select IPSW file")" IPSW="${IPSW%?????}" - Log "Selected IPSW file: $IPSW" + Log "Selected IPSW file: $IPSW.ipsw" + Input "Select your SHSH file in the file selection window." SHSH="$(zenity --file-selection --file-filter='SHSH | *.shsh *.shsh2' --title="Select SHSH file")" Log "Selected SHSH file: $SHSH" else + Input "Enter the names of your IPSW and SHSH files below." Echo "* Move/copy the IPSW and SHSH files to the directory where the script is located" Echo "* When entering the names of IPSW and SHSH, enter the full name including the file extension" - Echo "* Remember to create a backup of the SHSH" + Echo "* Make sure to create a backup of the SHSH" read -p "$(Input 'Enter name of IPSW file:')" IPSW - IPSW="$(basename $IPSW .ipsw)" + IPSW="$(basename "$IPSW" .ipsw)" read -p "$(Input 'Enter name of SHSH file:')" SHSH fi elif [[ $Mode == "Downgrade" && $DeviceProc != 7 ]]; then - read -p "$(Input 'Jailbreak the selected iOS version? (Y/n):')" Jailbreak + Input "Jailbreak Option" + Echo "* When this option is enabled, your device will be jailbroken on restore." + Echo "* This option is enabled by default (Y)." + read -p "$(Input 'Enable this option? (Y/n):')" Jailbreak if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then Jailbreak=1 @@ -99,19 +109,28 @@ Downgrade() { $ProductType == "iPad2,5" || $ProductType == "iPad2,6" || $ProductType == "iPad2,7" || $ProductType == "iPod5,1" ]] || [[ $ProductType == "iPad3"* && $DeviceProc == 5 ]]; then - if [[ $OSVer == "8.4.1" ]]; then - Log "Using daibutsu jailbreak" - JBDaibutsu=1 - fi + [[ $OSVer == "8.4.1" ]] && JBDaibutsu=1 fi + + if [[ $JBDaibutsu == 1 ]]; then + JBName="daibutsu" + elif [[ $OSVer == "8.4.1" ]]; then + JBName="EtasonJB" + elif [[ $OSVer == "6.1.3" ]]; then + JBName="p0sixspwn" + fi + + Log "Jailbreak option enabled. Using $JBName for the jailbreak" fi + echo fi if [[ $Mode == "Downgrade" && $ProductType == "iPhone5,1" && $Jailbreak != 1 ]]; then - Echo "* By default, iOS-OTA-Downgrader now flashes the iOS 8.4.1 baseband to iPhone5,1" - Echo "* Flashing the latest baseband is still available as an option but beware of problems it may cause" - Echo "* There are potential network issues that with the latest baseband when used on iOS 8.4.1" - read -p "$(Input 'Flash the latest baseband? (y/N) (press Enter/Return if unsure):')" Baseband5 + Input "Latest Baseband Option" + Echo "* iOS-OTA-Downgrader flashes the iOS 8.4.1 baseband to iPhone5,1." + Echo "* When this option is enabled, the latest baseband will be flashed instead, but beware of problems it may cause." + Echo "* This option is disabled by default (N)." + read -p "$(Input 'Enable this option? (y/N):')" Baseband5 if [[ $Baseband5 == 'Y' || $Baseband5 == 'y' ]]; then Baseband5=0 else @@ -119,38 +138,29 @@ Downgrade() { Baseband="Mav5-8.02.00.Release.bbfw" BasebandSHA1="db71823841ffab5bb41341576e7adaaeceddef1c" fi + echo fi if [[ $OSVer != "Other" ]]; then - [[ $DeviceProc != 7 ]] && SaveOTABlobs - IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore" IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom" + if [[ $Jailbreak != 1 && $DeviceProc != 7 && $platform == "win" ]]; then IPSWCustom="${IPSWCustom}W" IPSWCustomW=1 elif [[ $Jailbreak != 1 && $DeviceProc != 7 ]]; then - Selection=("futurerestore" "idevicerestore") - Echo "* Select 1 (futurerestore) if unsure" - Echo "* Select 2 (idevicerestore) if you experience issues with futurerestore" - Input "Select restore tool to use:" - select opt in "${Selection[@]}"; do - case $opt in - "idevicerestore" ) IPSWCustom="${IPSWCustom}W"; IPSWCustomW=1; break;; - *) break;; - esac - done + local opt + Input "Restore Tool Option" + Echo "* This option is set to futurerestore (Y) by default." + Echo "* You may select idevicerestore (N) later if you experience issues with futurerestore." + read -p "$(Input 'Enable this option? (Y/n):')" opt + if [[ $opt == 'N' || $opt == 'n' ]]; then + IPSWCustom="${IPSWCustom}W" + IPSWCustomW=1 + fi + echo fi - if [[ ! -e "$IPSW.ipsw" && ! -e "$IPSWCustom.ipsw" ]]; then - Log "iOS $OSVer IPSW cannot be found." - Echo "* If you already downloaded the IPSW, did you put it in the same directory as the script?" - Echo "* Do NOT rename the IPSW as the script will fail to detect it" - Log "Downloading IPSW... (Press Ctrl+C to cancel)" - curl -L $(cat $Firmware/$BuildVer/url) -o tmp/$IPSW.ipsw - mv tmp/$IPSW.ipsw . - fi - if [[ ! -e "$IPSWCustom.ipsw" && $IPSWCustomW == 1 ]]; then Verify=1 elif [[ $Jailbreak == 1 || $DeviceProc == 7 ]]; then @@ -158,7 +168,27 @@ Downgrade() { elif [[ $Jailbreak != 1 && $IPSWCustomW != 1 ]]; then Verify=1 fi - + + if [[ $Jailbreak == 1 || $IPSWCustomW == 1 ]] && + [[ $Verify == 1 && $platform != "win" ]]; then + Input "Memory Option for creating custom IPSW" + Echo "* This option makes creating the custom IPSW faster, but it requires at least 8GB of RAM." + Echo "* If you do not have enough RAM, disable this option and make sure that you have enough storage space." + Echo "* This option is enabled by default (Y)." + read -p "$(Input 'Enable this option? (Y/n):')" JBMemory + echo + fi + + if [[ ! -e "$IPSW.ipsw" && ! -e "$IPSWCustom.ipsw" ]]; then + Log "iOS $OSVer IPSW for $ProductType cannot be found." + Echo "* If you already downloaded the IPSW, move/copy it to the directory where the script is located." + Echo "* Do NOT rename the IPSW as the script will fail to detect it." + Echo "* The script will now proceed to download it for you. If you want to download it yourself, here is the link: $(cat $Firmware/$BuildVer/url)" + Log "Downloading IPSW... (Press Ctrl+C to cancel)" + curl -L $(cat $Firmware/$BuildVer/url) -o tmp/$IPSW.ipsw + mv tmp/$IPSW.ipsw . + fi + if [[ $Verify == 1 ]]; then Log "Verifying IPSW..." IPSWSHA1=$(cat $Firmware/$BuildVer/sha1sum) @@ -176,19 +206,21 @@ Downgrade() { IPSWRestore=$IPSWCustom fi - if [[ $DeviceState == "Normal" && $iBSSBuildVer == $BuildVer ]]; then + if [[ $DeviceState == "Normal" && $iBSSBuildVer == $BuildVer && -e "$IPSW.ipsw" ]]; then Log "Extracting iBSS from IPSW..." mkdir -p saved/$ProductType 2>/dev/null unzip -o -j $IPSW.ipsw Firmware/dfu/$iBSS.dfu -d saved/$ProductType fi + + [[ $DeviceProc != 7 ]] && SaveOTABlobs else IPSWCustom=0 fi - + [[ $DeviceState == "Normal" ]] && kDFU - if [[ $Jailbreak == 1 || $IPSWRestore == $IPSWCustom || $IPSWCustomW == 1 ]]; then - [[ $Jailbreak == 1 || $IPSWCustomW == 1 ]] && IPSW32 + if [[ $Jailbreak == 1 || $IPSWCustomW == 1 ]]; then + IPSW32 IPSWExtract="$IPSWCustom" else IPSWExtract="$IPSW" diff --git a/resources/ipsw.sh b/resources/ipsw.sh index 0c35a16..a23c459 100755 --- a/resources/ipsw.sh +++ b/resources/ipsw.sh @@ -70,14 +70,7 @@ IPSW32() { ExtraArgs+="-bbupdate" if [[ ! -e $IPSWCustom.ipsw ]]; then - if [[ $platform != "win" ]]; then - Echo "* By default, memory option is set to Y." - Echo "* Make sure that you have at least 8GB of RAM for it to work!" - Echo "* If it freezes or fails, this may mean that you do not have enough RAM." - Echo "* You may select N if this happens, but make sure that you have enough storage space." - read -p "$(Input 'Memory option? (press Enter/Return if unsure) (Y/n):')" JBMemory - [[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory" - fi + [[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory" Log "Preparing custom IPSW..." cd resources rm -rf FirmwareBundles diff --git a/restore.sh b/restore.sh index b81b0c7..d2a80d3 100755 --- a/restore.sh +++ b/restore.sh @@ -87,6 +87,7 @@ Main() { Log "Warning - An error occurred in chmod. This might cause problems..." fi + Log "Checking Internet connection..." if [[ ! $(ping -c1 1.1.1.1 2>/dev/null) ]]; then Error "Please check your Internet connection before proceeding." fi @@ -205,6 +206,7 @@ Main() { SelectVersion + echo Log "Option: $Mode" $Mode @@ -238,6 +240,7 @@ SelectVersion() { [[ $Mode == "Downgrade" && $platform != "win" ]] && Selection+=("Other (use SHSH blobs)") Selection+=("(Any other key to exit)") + echo Input "Select iOS version:" select opt in "${Selection[@]}"; do case $opt in