2019-11-22 11:48:41 +01:00
|
|
|
#!/bin/bash
|
2021-06-01 03:49:00 +02:00
|
|
|
trap "Clean" EXIT
|
|
|
|
trap "Clean; exit 1" INT TERM
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-06-01 03:02:27 +02:00
|
|
|
cd "$(dirname $0)"
|
2021-05-29 13:26:08 +02:00
|
|
|
. ./resources/blobs.sh
|
|
|
|
. ./resources/depends.sh
|
|
|
|
. ./resources/device.sh
|
|
|
|
. ./resources/downgrade.sh
|
|
|
|
. ./resources/ipsw.sh
|
|
|
|
|
2021-06-01 03:49:00 +02:00
|
|
|
if [[ $1 != "NoColor" && $2 != "NoColor" ]]; then
|
2021-09-29 17:19:18 +02:00
|
|
|
TERM=xterm-256color
|
2020-09-01 04:25:27 +02:00
|
|
|
Color_R=$(tput setaf 9)
|
|
|
|
Color_G=$(tput setaf 10)
|
|
|
|
Color_B=$(tput setaf 12)
|
|
|
|
Color_Y=$(tput setaf 11)
|
|
|
|
Color_N=$(tput sgr0)
|
|
|
|
fi
|
2019-11-22 11:48:41 +01:00
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Clean() {
|
2021-05-29 13:26:08 +02:00
|
|
|
rm -rf iP*/ shsh/ tmp/ *.im4p *.bbfw ${UniqueChipID}_${ProductType}_*.shsh2 \
|
|
|
|
${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh BuildManifest.plist
|
|
|
|
kill $iproxyPID 2>/dev/null
|
|
|
|
if [[ $ServerRunning == 1 ]]; then
|
|
|
|
Log "Stopping local server..."
|
|
|
|
if [[ $platform == "macos" ]]; then
|
|
|
|
ps aux | awk '/python/ {print "kill -9 "$2" 2>/dev/null"}' | bash
|
|
|
|
elif [[ $platform == "linux" ]]; then
|
|
|
|
Echo "* Enter root password of your PC when prompted"
|
|
|
|
ps aux | awk '/python/ {print "sudo kill -9 "$2" 2>/dev/null"}' | bash
|
|
|
|
fi
|
|
|
|
fi
|
2020-03-09 02:30:19 +01:00
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Echo() {
|
2020-09-01 04:25:27 +02:00
|
|
|
echo "${Color_B}$1 ${Color_N}"
|
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Error() {
|
2020-09-01 04:25:27 +02:00
|
|
|
echo -e "\n${Color_R}[Error] $1 ${Color_N}"
|
|
|
|
[[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}"
|
2020-07-30 17:09:34 +02:00
|
|
|
echo
|
2021-09-29 07:33:34 +02:00
|
|
|
if [[ $platform == "win" ]]; then
|
|
|
|
Input "Press Enter/Return to exit."
|
|
|
|
read -s
|
|
|
|
fi
|
2021-03-05 05:49:07 +01:00
|
|
|
exit 1
|
2020-03-09 02:30:19 +01:00
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Input() {
|
2020-09-01 04:25:27 +02:00
|
|
|
echo "${Color_Y}[Input] $1 ${Color_N}"
|
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Log() {
|
2020-09-01 04:25:27 +02:00
|
|
|
echo "${Color_G}[Log] $1 ${Color_N}"
|
2020-04-01 04:49:55 +02:00
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
Main() {
|
2021-05-29 13:26:08 +02:00
|
|
|
local SkipMainMenu
|
|
|
|
|
2020-07-23 02:47:36 +02:00
|
|
|
clear
|
2020-09-01 04:25:27 +02:00
|
|
|
Echo "******* iOS-OTA-Downgrader *******"
|
|
|
|
Echo " Downgrader script by LukeZGD "
|
2020-07-23 02:47:36 +02:00
|
|
|
echo
|
2020-07-27 15:42:41 +02:00
|
|
|
|
2021-10-02 06:46:35 +02:00
|
|
|
if [[ $EUID == 0 ]]; then
|
|
|
|
Error "Running the script as root is not allowed."
|
|
|
|
fi
|
|
|
|
|
2021-07-10 02:25:21 +02:00
|
|
|
if [[ ! -d ./resources ]]; then
|
|
|
|
Error "resources folder cannot be found. Replace resources folder and try again." \
|
|
|
|
"If resources folder is present try removing spaces from path/folder name"
|
|
|
|
fi
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
SetToolPaths
|
2021-07-10 02:25:21 +02:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
Error "Setting tool paths failed. Your copy of iOS-OTA-Downgrader seems to be incomplete."
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
if [[ ! $platform ]]; then
|
|
|
|
Error "Platform unknown/not supported."
|
|
|
|
fi
|
|
|
|
|
|
|
|
chmod +x ./resources/*.sh ./resources/tools/*
|
2021-07-10 02:25:21 +02:00
|
|
|
if [[ $? != 0 ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Warning - An error occurred in chmod. This might cause problems..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $(ping -c1 1.1.1.1 2>/dev/null) ]]; then
|
|
|
|
Error "Please check your Internet connection before proceeding."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $platform == "macos" && $(uname -m) != "x86_64" ]]; then
|
2021-07-12 16:36:51 +02:00
|
|
|
Log "Apple Silicon Mac detected. Support may be limited, proceed at your own risk."
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $(uname -m) != "x86_64" ]]; then
|
|
|
|
Error "Only 64-bit (x86_64) distributions are supported."
|
2021-05-03 05:09:21 +02:00
|
|
|
fi
|
2020-09-16 16:13:48 +02:00
|
|
|
|
2021-06-20 11:45:53 +02:00
|
|
|
if [[ $1 == "Install" || ! $bspatch || ! $git || ! $ideviceinfo || ! $irecoverychk || ! $python ||
|
|
|
|
! -d ./resources/libimobiledevice_$platform ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
Clean
|
|
|
|
InstallDepends
|
2020-09-10 11:20:46 +02:00
|
|
|
fi
|
|
|
|
|
2021-09-06 10:50:29 +02:00
|
|
|
SaveExternal LukeZGD iOS-OTA-Downgrader-Keys
|
|
|
|
SaveExternal LukeZGD ipwndfu
|
2020-09-10 11:20:46 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
GetDeviceValues
|
2020-09-10 11:20:46 +02:00
|
|
|
|
2020-07-27 15:42:41 +02:00
|
|
|
Clean
|
|
|
|
mkdir tmp
|
2020-07-23 02:47:36 +02:00
|
|
|
|
2021-09-30 05:49:41 +02:00
|
|
|
if [[ $DeviceProc == 7 && $platform == "win" ]]; then
|
2021-09-30 07:05:27 +02:00
|
|
|
local Message="If you want to restore your A7 device on Windows, put the device in pwnDFU mode."
|
2021-09-30 05:49:41 +02:00
|
|
|
if [[ $DeviceState == "Normal" ]]; then
|
|
|
|
Error "$Message"
|
|
|
|
elif [[ $DeviceState == "Recovery" ]]; then
|
|
|
|
Log "A7 device detected in recovery mode."
|
|
|
|
Log "$Message"
|
|
|
|
RecoveryExit
|
|
|
|
elif [[ $DeviceState == "DFU" ]]; then
|
|
|
|
Log "A7 device detected in DFU mode."
|
|
|
|
Echo "* Make sure that your device is already in pwnDFU mode with signature checks disabled."
|
2021-09-30 07:05:27 +02:00
|
|
|
Echo "* If your device is not in pwnDFU mode, the restore will not proceed!"
|
2021-09-30 05:49:41 +02:00
|
|
|
Echo "* Entering pwnDFU mode is not supported on Windows. You need to use a Mac/Linux machine or another iOS device to do so."
|
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
2021-09-29 07:33:34 +02:00
|
|
|
fi
|
2021-09-30 05:49:41 +02:00
|
|
|
|
|
|
|
elif [[ $DeviceProc == 7 ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $DeviceState == "Normal" ]]; then
|
|
|
|
Echo "* The device needs to be in recovery/DFU mode before proceeding."
|
|
|
|
read -p "$(Input 'Send device to recovery mode? (y/N):')" Selection
|
|
|
|
[[ $Selection == 'Y' || $Selection == 'y' ]] && Recovery || exit
|
|
|
|
elif [[ $DeviceState == "Recovery" ]]; then
|
|
|
|
Recovery
|
|
|
|
elif [[ $DeviceState == "DFU" ]]; then
|
|
|
|
CheckM8
|
|
|
|
fi
|
2020-08-22 03:52:58 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $DeviceState == "DFU" ]]; then
|
|
|
|
Mode="Downgrade"
|
2021-04-19 10:04:30 +02:00
|
|
|
Echo "* Advanced Options Menu"
|
2020-09-01 04:25:27 +02:00
|
|
|
Input "This device is in:"
|
2021-05-29 13:26:08 +02:00
|
|
|
Selection=("kDFU mode")
|
2021-09-30 07:05:27 +02:00
|
|
|
if [[ $platform != "win" ]]; then
|
|
|
|
[[ $DeviceProc == 5 ]] && Selection+=("pwnDFU mode (A5)")
|
|
|
|
[[ $DeviceProc == 6 ]] && Selection+=("DFU mode (A6)")
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
Selection+=("Any other key to exit")
|
|
|
|
select opt in "${Selection[@]}"; do
|
|
|
|
case $opt in
|
|
|
|
"kDFU mode" ) break;;
|
|
|
|
"DFU mode (A6)" ) CheckM8; break;;
|
|
|
|
"pwnDFU mode (A5)" )
|
|
|
|
Echo "* Make sure that your device is in pwnDFU mode using an Arduino+USB Host Shield!";
|
2021-09-30 07:05:27 +02:00
|
|
|
Echo "* This option will not work if your device is not in pwnDFU mode.";
|
2021-05-29 13:26:08 +02:00
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)";
|
|
|
|
read -s;
|
|
|
|
kDFU iBSS; break;;
|
2021-05-30 05:03:39 +02:00
|
|
|
* ) exit 0;;
|
2021-05-29 13:26:08 +02:00
|
|
|
esac
|
2020-08-12 16:05:51 +02:00
|
|
|
done
|
2020-08-22 03:52:58 +02:00
|
|
|
Log "Downgrading $ProductType in kDFU/pwnDFU mode..."
|
2021-05-29 13:26:08 +02:00
|
|
|
Mode="Downgrade"
|
|
|
|
SkipMainMenu=1
|
|
|
|
|
|
|
|
elif [[ $DeviceState == "Recovery" ]]; then
|
2021-09-30 07:05:27 +02:00
|
|
|
if [[ $DeviceProc == 6 && $platform != "win" ]]; then
|
2020-09-07 09:55:38 +02:00
|
|
|
Recovery
|
|
|
|
else
|
2021-09-30 07:05:27 +02:00
|
|
|
Log "32-bit A${DeviceProc} device detected in recovery mode."
|
2021-05-29 13:26:08 +02:00
|
|
|
Echo "* Please put the device in normal mode and jailbroken before proceeding."
|
2021-09-30 07:05:27 +02:00
|
|
|
Echo "* For usage of advanced DFU options, put the device in kDFU or pwnDFU mode"
|
2021-09-30 05:49:41 +02:00
|
|
|
RecoveryExit
|
2020-09-07 09:55:38 +02:00
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Downgrading $ProductType in pwnDFU mode..."
|
|
|
|
Mode="Downgrade"
|
|
|
|
SkipMainMenu=1
|
2020-03-05 12:48:41 +01:00
|
|
|
fi
|
2020-03-10 03:55:04 +01:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ ! -z $1 ]] && SkipMainMenu=1
|
|
|
|
|
|
|
|
if [[ $SkipMainMenu == 1 && $1 != "NoColor" ]]; then
|
|
|
|
[[ ! -z $1 ]] && Mode="$1"
|
2020-07-23 04:08:46 +02:00
|
|
|
else
|
|
|
|
Selection=("Downgrade device")
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ $DeviceProc != 7 ]] && Selection+=("Save OTA blobs" "Just put device in kDFU mode")
|
|
|
|
|
2020-07-23 04:08:46 +02:00
|
|
|
Selection+=("(Re-)Install Dependencies" "(Any other key to exit)")
|
2020-09-01 04:25:27 +02:00
|
|
|
Echo "*** Main Menu ***"
|
|
|
|
Input "Select an option:"
|
2020-07-23 04:08:46 +02:00
|
|
|
select opt in "${Selection[@]}"; do
|
2021-05-29 13:26:08 +02:00
|
|
|
case $opt in
|
|
|
|
"Downgrade device" ) Mode="Downgrade"; break;;
|
|
|
|
"Save OTA blobs" ) Mode="SaveOTABlobs"; break;;
|
|
|
|
"Just put device in kDFU mode" ) Mode="kDFU"; break;;
|
|
|
|
"(Re-)Install Dependencies" ) InstallDepends;;
|
2021-05-30 05:03:39 +02:00
|
|
|
* ) exit 0;;
|
2021-05-29 13:26:08 +02:00
|
|
|
esac
|
2020-07-23 04:08:46 +02:00
|
|
|
done
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2020-03-31 07:46:59 +02:00
|
|
|
SelectVersion
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
Log "Option: $Mode"
|
2021-09-13 14:02:22 +02:00
|
|
|
$Mode
|
2021-09-29 07:33:34 +02:00
|
|
|
|
|
|
|
if [[ $platform == "win" ]]; then
|
|
|
|
Input "Press Enter/Return to exit."
|
|
|
|
read -s
|
|
|
|
fi
|
2021-05-30 05:03:39 +02:00
|
|
|
exit 0
|
2020-03-05 12:48:41 +01:00
|
|
|
}
|
|
|
|
|
2021-05-01 08:21:29 +02:00
|
|
|
SelectVersion() {
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $Mode == "kDFU" ]]; then
|
|
|
|
return
|
|
|
|
elif [[ $ProductType == "iPad4"* || $ProductType == "iPhone6"* ]]; then
|
|
|
|
OSVer="10.3.3"
|
|
|
|
BuildVer="14G60"
|
|
|
|
return
|
2020-07-23 02:47:36 +02:00
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
if [[ $ProductType == "iPhone5,3" || $ProductType == "iPhone5,4" ]]; then
|
2021-01-10 08:27:00 +01:00
|
|
|
Selection=()
|
|
|
|
else
|
|
|
|
Selection=("iOS 8.4.1")
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
if [[ $ProductType == "iPad2,1" || $ProductType == "iPad2,2" ||
|
|
|
|
$ProductType == "iPad2,3" || $ProductType == "iPhone4,1" ]]; then
|
2020-09-16 08:50:12 +02:00
|
|
|
Selection+=("iOS 6.1.3")
|
2020-03-05 12:48:41 +01:00
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-09-29 07:33:34 +02:00
|
|
|
[[ $Mode == "Downgrade" && $platform != "win" ]] && Selection+=("Other (use SHSH blobs)")
|
2020-07-27 13:27:46 +02:00
|
|
|
Selection+=("(Any other key to exit)")
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2020-09-01 04:25:27 +02:00
|
|
|
Input "Select iOS version:"
|
2020-04-01 04:16:29 +02:00
|
|
|
select opt in "${Selection[@]}"; do
|
2021-05-29 13:26:08 +02:00
|
|
|
case $opt in
|
|
|
|
"iOS 8.4.1" ) OSVer="8.4.1"; BuildVer="12H321"; break;;
|
|
|
|
"iOS 6.1.3" ) OSVer="6.1.3"; BuildVer="10B329"; break;;
|
|
|
|
"Other (use SHSH blobs)" ) OSVer="Other"; break;;
|
2021-05-30 05:03:39 +02:00
|
|
|
*) exit 0;;
|
2021-05-29 13:26:08 +02:00
|
|
|
esac
|
2020-07-23 02:47:36 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-07-23 04:08:46 +02:00
|
|
|
Main $1
|