2021-05-29 13:26:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
FRBaseband() {
|
|
|
|
local BasebandSHA1L
|
|
|
|
|
2021-10-26 05:41:09 +02:00
|
|
|
if [[ $DeviceProc == 7 ]] || [[ $Baseband5 != 0 && $OSVer == "8.4.1" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
mkdir -p saved/baseband 2>/dev/null
|
2021-06-06 14:32:29 +02:00
|
|
|
cp -f $IPSWRestore/Firmware/$Baseband saved/baseband
|
2021-10-26 05:41:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -e saved/baseband/$Baseband ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Downloading baseband..."
|
|
|
|
$partialzip $BasebandURL Firmware/$Baseband $Baseband
|
|
|
|
$partialzip $BasebandURL BuildManifest.plist BuildManifest.plist
|
2021-06-19 09:31:20 +02:00
|
|
|
mkdir -p saved/$ProductType saved/baseband 2>/dev/null
|
2021-05-29 13:26:08 +02:00
|
|
|
mv $Baseband saved/baseband
|
|
|
|
mv BuildManifest.plist saved/$ProductType
|
|
|
|
BuildManifest="saved/$ProductType/BuildManifest.plist"
|
2021-11-08 02:48:18 +01:00
|
|
|
elif [[ $Baseband5 == 0 ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
BuildManifest="saved/$ProductType/BuildManifest.plist"
|
|
|
|
fi
|
2021-11-07 15:57:20 +01:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
BasebandSHA1L=$(shasum saved/baseband/$Baseband | awk '{print $1}')
|
|
|
|
if [[ ! -e $(ls saved/baseband/$Baseband) || $BasebandSHA1L != $BasebandSHA1 ]]; then
|
|
|
|
rm -f saved/baseband/$Baseband saved/$ProductType/BuildManifest.plist
|
2021-11-07 15:57:20 +01:00
|
|
|
if [[ $DeviceProc == 7 ]]; then
|
|
|
|
Error "Downloading/verifying baseband failed. Please run the script again"
|
|
|
|
else
|
|
|
|
Log "Downloading/verifying baseband failed, will proceed with --latest-baseband flag"
|
|
|
|
return 1
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
Downgrade() {
|
2021-11-06 15:10:04 +01:00
|
|
|
local ExtraArgs=("--use-pwndfu")
|
2021-05-29 13:26:08 +02:00
|
|
|
local IPSWExtract
|
|
|
|
local IPSWSHA1
|
|
|
|
local IPSWSHA1L
|
|
|
|
local Jailbreak
|
2021-10-12 09:02:37 +02:00
|
|
|
local JBName
|
2021-10-21 13:42:50 +02:00
|
|
|
local Verify=1
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-10-12 09:02:37 +02:00
|
|
|
Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)."
|
|
|
|
echo
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $OSVer == "Other" ]]; then
|
2021-11-01 06:34:41 +01:00
|
|
|
Input "Select your IPSW file in the file selection window."
|
|
|
|
IPSW="$($zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select IPSW file")"
|
|
|
|
[[ ! -s "$IPSW" ]] && Error "No IPSW selected, or IPSW file not found."
|
|
|
|
IPSW="${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")"
|
|
|
|
[[ ! -s "$SHSH" ]] && Error "No SHSH selected, or SHSH file not found."
|
|
|
|
Log "Selected SHSH file: $SHSH"
|
|
|
|
|
2021-10-31 02:59:23 +01:00
|
|
|
unzip -o -j "$IPSW.ipsw" Restore.plist -d tmp
|
|
|
|
BuildVer=$(cat tmp/Restore.plist | grep -i ProductBuildVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
|
|
|
|
Log "Getting firmware keys for $ProductType-$BuildVer"
|
|
|
|
mkdir resources/firmware/$ProductType/$BuildVer 2>/dev/null
|
|
|
|
curl -L https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/raw/master/$ProductType/$BuildVer/index.html -o tmp/index.html
|
|
|
|
mv tmp/index.html resources/firmware/$ProductType/$BuildVer
|
2021-09-01 01:57:25 +02:00
|
|
|
|
2021-10-26 05:33:18 +02:00
|
|
|
elif [[ $ProductType == "iPad2,5" || $ProductType == "iPad2,6" || $ProductType == "iPad2,7" ]]; then
|
|
|
|
Echo "* Jailbreak Option is disabled on iPad mini 1 devices."
|
|
|
|
Echo "* If you want to jailbreak your device, you need to sideload EtasonJB, HomeDepot, or daibutsu manually."
|
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
|
|
|
|
|
|
|
elif [[ $DeviceProc != 7 ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
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
|
2021-06-13 13:48:06 +02:00
|
|
|
|
2021-06-20 11:45:53 +02:00
|
|
|
if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then
|
2021-06-13 13:48:06 +02:00
|
|
|
Jailbreak=1
|
2021-10-26 05:33:18 +02:00
|
|
|
if [[ $ProductType == "iPhone4,1" || $ProductType == "iPad2,4" || $ProductType == "iPod5,1" ]] ||
|
2021-09-06 10:50:29 +02:00
|
|
|
[[ $ProductType == "iPad3"* && $DeviceProc == 5 ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
[[ $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"
|
2021-06-13 13:48:06 +02:00
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
|
|
|
|
Log "Jailbreak option enabled. Using $JBName for the jailbreak"
|
2021-11-08 02:48:18 +01:00
|
|
|
else
|
|
|
|
Log "Jailbreak option disabled by user."
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
echo
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
if [[ $ProductType == "iPhone5,1" ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
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
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $Baseband5 == 'Y' || $Baseband5 == 'y' ]]; then
|
|
|
|
Baseband5=0
|
2021-11-08 02:48:18 +01:00
|
|
|
Log "Latest baseband enabled by user."
|
2021-05-29 13:26:08 +02:00
|
|
|
else
|
2021-10-26 05:41:09 +02:00
|
|
|
Baseband841
|
2021-11-08 02:48:18 +01:00
|
|
|
Log "Latest baseband disabled. Using iOS 8.4.1 baseband"
|
2021-10-26 05:41:09 +02:00
|
|
|
fi
|
|
|
|
echo
|
2021-11-08 02:48:18 +01:00
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
elif [[ $DeviceProc != 7 && $ProductType != "iPad2,2" ]]; then
|
2021-10-26 05:41:09 +02:00
|
|
|
Input "Latest Baseband Option"
|
|
|
|
Echo "* iOS-OTA-Downgrader flashes the latest baseband to 32-bit devices."
|
|
|
|
Echo "* When this option is disabled, iOS 8.4.1 baseband will be flashed instead, but beware of problems it may cause."
|
|
|
|
Echo "* This option is enabled by default (Y)."
|
|
|
|
read -p "$(Input 'Enable this option? (Y/n):')" Baseband5
|
2021-11-07 15:57:20 +01:00
|
|
|
if [[ $Baseband5 == 'N' || $Baseband5 == 'n' ]]; then
|
2021-10-26 05:41:09 +02:00
|
|
|
Baseband841
|
2021-11-08 02:48:18 +01:00
|
|
|
Log "Latest baseband disabled by user. Using iOS 8.4.1 baseband"
|
2021-10-26 05:41:09 +02:00
|
|
|
else
|
|
|
|
Baseband5=0
|
2021-11-08 02:48:18 +01:00
|
|
|
Log "Latest baseband enabled."
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
echo
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $OSVer != "Other" ]]; then
|
|
|
|
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
|
|
|
|
IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
|
2021-10-12 09:02:37 +02:00
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
if [[ $Jailbreak == 1 ]]; then
|
2021-10-21 13:42:50 +02:00
|
|
|
[[ -e "$IPSWCustom.ipsw" ]] && Verify=
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
if [[ $Jailbreak == 1 && $Verify == 1 ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
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
|
2021-11-08 02:48:18 +01:00
|
|
|
if [[ $JBMemory == 'N' || $JBMemory == 'n' ]]; then
|
|
|
|
Log "Memory option disabled by user."
|
|
|
|
else
|
|
|
|
Log "Memory option enabled."
|
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
SaveOTABlobs
|
2021-10-21 13:42:50 +02:00
|
|
|
|
|
|
|
if [[ ! -e "$IPSW.ipsw" && $Verify == 1 ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
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
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $Verify == 1 ]]; then
|
|
|
|
Log "Verifying IPSW..."
|
|
|
|
IPSWSHA1=$(cat $Firmware/$BuildVer/sha1sum)
|
2021-08-21 10:53:54 +02:00
|
|
|
Log "Expected SHA1sum: $IPSWSHA1"
|
2021-05-29 13:26:08 +02:00
|
|
|
IPSWSHA1L=$(shasum $IPSW.ipsw | awk '{print $1}')
|
2021-08-21 10:53:54 +02:00
|
|
|
Log "Actual SHA1sum: $IPSWSHA1L"
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then
|
2021-09-29 11:26:04 +02:00
|
|
|
Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \
|
|
|
|
"SHA1sum mismatch. Expected $IPSWSHA1, got $IPSWSHA1L"
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-09-29 11:26:04 +02:00
|
|
|
Log "IPSW SHA1sum matches."
|
2021-06-20 11:45:53 +02:00
|
|
|
elif [[ -e "$IPSWCustom.ipsw" ]]; then
|
2021-09-06 10:50:29 +02:00
|
|
|
Log "Found existing Custom IPSW. Skipping IPSW verification."
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Setting restore IPSW to: $IPSWCustom.ipsw"
|
|
|
|
IPSWRestore=$IPSWCustom
|
|
|
|
fi
|
|
|
|
|
2021-10-12 09:02:37 +02:00
|
|
|
if [[ $DeviceState == "Normal" && $iBSSBuildVer == $BuildVer && -e "$IPSW.ipsw" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
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
|
2021-09-01 02:11:07 +02:00
|
|
|
else
|
|
|
|
IPSWCustom=0
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-10-12 09:02:37 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ $DeviceState == "Normal" ]] && kDFU
|
2021-09-01 02:11:07 +02:00
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
if [[ $Jailbreak == 1 ]]; then
|
2021-10-12 09:02:37 +02:00
|
|
|
IPSW32
|
2021-09-01 02:11:07 +02:00
|
|
|
IPSWExtract="$IPSWCustom"
|
2021-05-29 13:26:08 +02:00
|
|
|
else
|
2021-09-01 02:11:07 +02:00
|
|
|
IPSWExtract="$IPSW"
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-09-01 02:11:07 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Extracting IPSW: $IPSWExtract.ipsw"
|
2021-10-21 13:42:50 +02:00
|
|
|
unzip -oq "$IPSWExtract.ipsw" -d "$IPSWExtract"/
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ ! $IPSWRestore ]]; then
|
|
|
|
Log "Setting restore IPSW to: $IPSW.ipsw"
|
|
|
|
IPSWRestore="$IPSW"
|
|
|
|
fi
|
2021-10-25 08:57:24 +02:00
|
|
|
|
2021-11-06 15:10:04 +01:00
|
|
|
Log "Proceeding to futurerestore..."
|
|
|
|
[[ $platform == "linux" ]] && Echo "* Enter root password of your PC when prompted"
|
|
|
|
cd resources
|
|
|
|
$SimpleHTTPServer &
|
|
|
|
ServerPID=$!
|
|
|
|
cd ..
|
|
|
|
|
2021-11-02 09:21:06 +01:00
|
|
|
if [[ $DeviceProc == 7 ]]; then
|
2021-11-06 15:10:04 +01:00
|
|
|
# Send dummy file for device detection
|
2021-11-02 09:21:06 +01:00
|
|
|
$irecovery -f README.md
|
2021-10-26 05:32:59 +02:00
|
|
|
sleep 2
|
2021-11-06 15:10:04 +01:00
|
|
|
ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest")
|
|
|
|
else
|
|
|
|
ExtraArgs+=("--no-ibss")
|
2021-10-26 05:32:59 +02:00
|
|
|
fi
|
|
|
|
|
2021-11-06 15:10:04 +01:00
|
|
|
if [[ $Baseband == 0 ]]; then
|
|
|
|
Log "Device $ProductType has no baseband"
|
2021-11-07 15:57:20 +01:00
|
|
|
ExtraArgs+=("--no-baseband")
|
2021-11-06 15:10:04 +01:00
|
|
|
else
|
|
|
|
FRBaseband
|
2021-11-07 15:57:20 +01:00
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
ExtraArgs+=("--latest-baseband")
|
|
|
|
else
|
|
|
|
ExtraArgs+=("-b" "saved/baseband/$Baseband" "-p" "$BuildManifest")
|
|
|
|
fi
|
2021-11-06 15:10:04 +01:00
|
|
|
fi
|
2021-11-07 15:57:20 +01:00
|
|
|
$futurerestore -t "$SHSH" "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
|
2021-11-02 09:21:06 +01:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
echo
|
|
|
|
Log "Restoring done!"
|
|
|
|
Log "Downgrade script done!"
|
|
|
|
}
|