IPSWFind, IPSWVerify, and other fixes

- IPSWFind and IPSWVerify to be used for the downgrade function and custom IPSW menu option
- depends: ipwndfu="$(which python2) ipwndfu" for macOS 12.3 and newer
- fix futurerestore error detect ($?)
- a bit of cleanup
This commit is contained in:
LukeZGD 2022-04-20 10:39:57 +08:00
parent 0aba782eab
commit db7af88f5b
4 changed files with 48 additions and 40 deletions

View File

@ -63,8 +63,10 @@ SetToolPaths() {
irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery" irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
rmsigchks="sudo $rmsigchks" rmsigchks="sudo $rmsigchks"
elif [[ $platform == "macos" ]]; then elif [[ $platform == "macos" ]]; then
# for macOS 12.3 and newer
if (( ${platformver:0:2} > 11 )) && [[ -z $python ]]; then if (( ${platformver:0:2} > 11 )) && [[ -z $python ]]; then
python="/usr/bin/python3" python="/usr/bin/python3"
ipwndfu="$(which python2) ipwndfu"
rmsigchks="$(which python2) rmsigchks.py" rmsigchks="$(which python2) rmsigchks.py"
SimpleHTTPServer="$python -m http.server 8888" SimpleHTTPServer="$python -m http.server 8888"
fi fi

View File

@ -35,10 +35,7 @@ FRBaseband() {
Downgrade() { Downgrade() {
local ExtraArgs=("--use-pwndfu") local ExtraArgs=("--use-pwndfu")
local IPSWExtract local IPSWExtract
local IPSWSHA1 Verify=1
local IPSWSHA1L
local Jailbreak
local Verify=1
Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)." Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)."
echo echo
@ -73,7 +70,7 @@ Downgrade() {
if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then
JailbreakSet JailbreakSet
Log "Jailbreak option enabled. Using $JBName for the jailbreak" Log "Jailbreak option enabled."
else else
Log "Jailbreak option disabled by user." Log "Jailbreak option disabled by user."
fi fi
@ -81,38 +78,14 @@ Downgrade() {
fi fi
if [[ $OSVer != "Other" ]]; then if [[ $OSVer != "Other" ]]; then
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
[[ -z $IPSWCustom ]] && IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom" [[ -z $IPSWCustom ]] && IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
if [[ $Jailbreak == 1 ]]; then
[[ -e "$IPSWCustom.ipsw" ]] && Verify=
fi
MemoryOption MemoryOption
SaveOTABlobs SaveOTABlobs
IPSWFind
if [[ ! -e "$IPSW.ipsw" && $Verify == 1 ]]; 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 if [[ $Verify == 1 ]]; then
Log "Verifying IPSW..." IPSWVerify
IPSWSHA1=$(cat $Firmware/$BuildVer/sha1sum)
Log "Expected SHA1sum: $IPSWSHA1"
IPSWSHA1L=$(shasum $IPSW.ipsw | awk '{print $1}')
Log "Actual SHA1sum: $IPSWSHA1L"
if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then
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"
fi
Log "IPSW SHA1sum matches."
elif [[ -e "$IPSWCustom.ipsw" ]]; then elif [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Found existing Custom IPSW. Skipping IPSW verification." Log "Found existing Custom IPSW. Skipping IPSW verification."
Log "Setting restore IPSW to: $IPSWCustom.ipsw" Log "Setting restore IPSW to: $IPSWCustom.ipsw"
@ -172,17 +145,16 @@ Downgrade() {
ExtraArgs+=("-b" "saved/baseband/$Baseband" "-p" "$BuildManifest") ExtraArgs+=("-b" "saved/baseband/$Baseband" "-p" "$BuildManifest")
fi fi
fi fi
Log "Running futurerestore with command: $futurerestore -t \"$SHSH\" ${ExtraArgs[*]} \"$IPSWRestore.ipsw\"" Log "Running futurerestore with command: $futurerestore -t \"$SHSH\" ${ExtraArgs[*]} \"$IPSWRestore.ipsw\""
$futurerestore -t "$SHSH" "${ExtraArgs[@]}" "$IPSWRestore.ipsw" $futurerestore -t "$SHSH" "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
local opt=$? if [[ $? != 0 ]]; then
echo
if [[ $opt != 0 ]]; then
Log "An error seems to have occurred in futurerestore." Log "An error seems to have occurred in futurerestore."
Echo "* Please read the \"Troubleshooting\" wiki page in GitHub before opening any issue!" Echo "* Please read the \"Troubleshooting\" wiki page in GitHub before opening any issue!"
Echo "* Your problem may have already been addressed within the page." Echo "* Your problem may have already been addressed within the wiki page."
Echo "* If opening an issue in GitHub, please provide a FULL log. Otherwise, your issue may be dismissed." Echo "* If opening an issue in GitHub, please provide a FULL log. Otherwise, your issue may be dismissed."
else else
echo
Log "Restoring done!" Log "Restoring done!"
fi fi
Log "Downgrade script done!" Log "Downgrade script done!"

View File

@ -3,6 +3,8 @@
JailbreakSet() { JailbreakSet() {
Jailbreak=1 Jailbreak=1
IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom" IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
[[ -e "$IPSWCustom.ipsw" ]] && Verify=
if [[ $ProductType == "iPhone4,1" || $ProductType == "iPhone5,2" ]] && [[ $OSVer == "8.4.1" ]]; then if [[ $ProductType == "iPhone4,1" || $ProductType == "iPhone5,2" ]] && [[ $OSVer == "8.4.1" ]]; then
Input "Jailbreak Tool Option" Input "Jailbreak Tool Option"
Echo "* This option is set to daibutsu by default (1)." Echo "* This option is set to daibutsu by default (1)."
@ -29,6 +31,7 @@ JailbreakSet() {
elif [[ $OSVer == "6.1.3" ]]; then elif [[ $OSVer == "6.1.3" ]]; then
JBName="p0sixspwn" JBName="p0sixspwn"
fi fi
Log "Using $JBName for the jailbreak"
} }
MemoryOption() { MemoryOption() {
@ -47,6 +50,32 @@ MemoryOption() {
fi fi
} }
IPSWFind() {
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
if [[ ! -e "$IPSW.ipsw" && $Verify == 1 ]]; 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
}
IPSWVerify() {
Log "Verifying IPSW..."
IPSWSHA1=$(cat $Firmware/$BuildVer/sha1sum)
Log "Expected SHA1sum: $IPSWSHA1"
IPSWSHA1L=$(shasum $IPSW.ipsw | awk '{print $1}')
Log "Actual SHA1sum: $IPSWSHA1L"
if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then
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"
fi
Log "IPSW SHA1sum matches."
}
IPSW32() { IPSW32() {
local Bundle="Down_${ProductType}_${OSVer}_${BuildVer}.bundle" local Bundle="Down_${ProductType}_${OSVer}_${BuildVer}.bundle"
local ExtraArgs local ExtraArgs

View File

@ -48,7 +48,7 @@ Main() {
clear clear
Echo "******* iOS-OTA-Downgrader *******" Echo "******* iOS-OTA-Downgrader *******"
Echo " Downgrader script by LukeZGD " Echo " - Downgrader script by LukeZGD - "
echo echo
if [[ $EUID == 0 ]]; then if [[ $EUID == 0 ]]; then
@ -131,12 +131,18 @@ Main() {
SelectVersion SelectVersion
if [[ $Mode == "IPSW32" ]]; then if [[ $Mode == "IPSW32" ]]; then
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
Verify=1 Verify=1
echo echo
JailbreakSet JailbreakSet
Log "Using $JBName for the jailbreak"
MemoryOption MemoryOption
IPSWFind
if [[ $Verify == 1 ]]; then
IPSWVerify
elif [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Found existing Custom IPSW, stopping here."
Echo "* If you want to re-create the custom IPSW, move/delete the existing one first."
exit 0
fi
IPSW32 IPSW32
Log "Custom IPSW has been created: $IPSWCustom.ipsw" Log "Custom IPSW has been created: $IPSWCustom.ipsw"
Echo "* This custom IPSW has a jailbreak built in ($JBName)" Echo "* This custom IPSW has a jailbreak built in ($JBName)"
@ -169,7 +175,6 @@ Main() {
echo "${Color_Y}* For more details, read the \"Troubleshooting\" wiki page in GitHub ${Color_N}" echo "${Color_Y}* For more details, read the \"Troubleshooting\" wiki page in GitHub ${Color_N}"
exit 1 exit 1
fi fi
Mode="Downgrade"
echo echo
Echo "* DFU Advanced Menu" Echo "* DFU Advanced Menu"
Echo "* This menu is for ADVANCED USERS ONLY." Echo "* This menu is for ADVANCED USERS ONLY."