2021-05-29 13:26:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-08-27 17:26:09 +02:00
|
|
|
DisableBBUpdate="iPad2,3" # Disable baseband update for this device. You can also change this to your device if needed
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
FindDevice() {
|
2021-07-12 16:36:51 +02:00
|
|
|
local DeviceIn
|
|
|
|
local i=0
|
|
|
|
local Timeout=999
|
2021-05-29 13:26:08 +02:00
|
|
|
local USB
|
2022-05-28 12:21:26 +02:00
|
|
|
if [[ $1 == "DFU" ]]; then
|
|
|
|
USB=1227
|
|
|
|
elif [[ $1 == "Recovery" ]]; then
|
|
|
|
USB=1281
|
2022-05-28 12:56:10 +02:00
|
|
|
elif [[ $1 == "Restore" ]]; then
|
|
|
|
USB=1297
|
2022-05-28 12:21:26 +02:00
|
|
|
fi
|
2022-09-05 09:59:11 +02:00
|
|
|
[[ -n $2 ]] && Timeout=10
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
Log "Finding device in $1 mode..."
|
2021-11-17 07:37:02 +01:00
|
|
|
while (( i < Timeout )); do
|
2021-09-29 07:33:34 +02:00
|
|
|
if [[ $platform == "linux" ]]; then
|
|
|
|
DeviceIn=$(lsusb | grep -c "05ac:$USB")
|
2022-05-28 12:56:10 +02:00
|
|
|
elif [[ $1 == "Restore" ]]; then
|
|
|
|
ideviceinfo2=$($ideviceinfo -s)
|
|
|
|
[[ $? == 0 ]] && DeviceIn=1
|
2021-09-29 07:33:34 +02:00
|
|
|
else
|
|
|
|
[[ $($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-) == "$1" ]] && DeviceIn=1
|
|
|
|
fi
|
2021-07-12 16:36:51 +02:00
|
|
|
if [[ $DeviceIn == 1 ]]; then
|
|
|
|
Log "Found device in $1 mode."
|
|
|
|
DeviceState="$1"
|
|
|
|
break
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
sleep 1
|
2021-07-12 16:36:51 +02:00
|
|
|
((i++))
|
2021-05-29 13:26:08 +02:00
|
|
|
done
|
2021-07-12 16:36:51 +02:00
|
|
|
|
|
|
|
if [[ $DeviceIn != 1 ]]; then
|
|
|
|
[[ $2 == "error" ]] && Error "Failed to find device in $1 mode. (Timed out)"
|
|
|
|
return 1
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GetDeviceValues() {
|
|
|
|
local ideviceinfo2
|
2021-11-06 15:10:04 +01:00
|
|
|
local version
|
2021-09-06 10:50:29 +02:00
|
|
|
DeviceState=
|
2022-07-29 04:58:15 +02:00
|
|
|
|
|
|
|
if [[ $NoDevice == 1 ]]; then
|
2021-11-07 14:29:31 +01:00
|
|
|
Log "NoDevice argument detected. Skipping device detection"
|
|
|
|
DeviceState="NoDevice"
|
2022-07-29 04:58:15 +02:00
|
|
|
else
|
|
|
|
Log "Finding device in Normal mode..."
|
|
|
|
ideviceinfo2=$($ideviceinfo -s)
|
|
|
|
opt=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $opt != 0 && $NoDevice != 1 ]]; then
|
|
|
|
Log "Finding device in DFU/recovery mode..."
|
|
|
|
DeviceState="$($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-)"
|
2021-11-17 07:37:02 +01:00
|
|
|
elif [[ -n $ideviceinfo2 ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
DeviceState="Normal"
|
|
|
|
fi
|
2021-09-13 14:02:22 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $DeviceState == "DFU" || $DeviceState == "Recovery" ]]; then
|
|
|
|
local ProdCut=7
|
2021-09-29 07:33:34 +02:00
|
|
|
ProductType=$($irecovery -qv 2>&1 | grep "Connected to iP" | cut -c 14-)
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ $(echo $ProductType | cut -c 3) == 'h' ]] && ProdCut=9
|
|
|
|
ProductType=$(echo $ProductType | cut -c -$ProdCut)
|
2022-07-22 11:43:40 +02:00
|
|
|
UniqueChipID=$((16#$($irecovery -q | grep "ECID" | cut -c 9-)))
|
2021-05-29 13:26:08 +02:00
|
|
|
ProductVer="Unknown"
|
2021-11-07 14:29:31 +01:00
|
|
|
elif [[ $DeviceState == "Normal" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
ProductType=$(echo "$ideviceinfo2" | grep "ProductType" | cut -c 14-)
|
|
|
|
[[ ! $ProductType ]] && ProductType=$($ideviceinfo | grep "ProductType" | cut -c 14-)
|
|
|
|
ProductVer=$(echo "$ideviceinfo2" | grep "ProductVer" | cut -c 17-)
|
|
|
|
UniqueChipID=$(echo "$ideviceinfo2" | grep "UniqueChipID" | cut -c 15-)
|
|
|
|
UniqueDeviceID=$(echo "$ideviceinfo2" | grep "UniqueDeviceID" | cut -c 17-)
|
2021-11-06 15:10:04 +01:00
|
|
|
version="(iOS $ProductVer) "
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-11-07 14:29:31 +01:00
|
|
|
|
2022-07-22 11:43:40 +02:00
|
|
|
if [[ $EntryDevice == 1 ]]; then
|
|
|
|
ProductType=
|
|
|
|
UniqueChipID=
|
|
|
|
fi
|
|
|
|
|
2022-09-18 10:16:36 +02:00
|
|
|
if [[ -n $DeviceState ]]; then
|
|
|
|
if [[ ! $ProductType ]]; then
|
|
|
|
read -p "$(Input 'Enter ProductType (eg. iPad2,1):')" ProductType
|
|
|
|
fi
|
|
|
|
if [[ ! $UniqueChipID || $UniqueChipID == 0 ]]; then
|
|
|
|
read -p "$(Input 'Enter UniqueChipID (ECID, must be decimal):')" UniqueChipID
|
|
|
|
fi
|
|
|
|
else
|
2022-12-19 03:10:18 +01:00
|
|
|
echo -e "\n${Color_R}[Error] No device detected. Please connect the iOS device to proceed."
|
|
|
|
echo "${Color_Y}* Make sure to also trust this computer by selecting \"Trust\" at the pop-up."
|
|
|
|
[[ $platform != "linux" ]] && echo "* Double-check if the device is being detected by iTunes/Finder."
|
|
|
|
[[ $platform == "macos" ]] && echo "* Also try installing libimobiledevice and libirecovery from Homebrew/MacPorts before retrying."
|
|
|
|
[[ $platform == "linux" ]] && echo "* Also try running \"sudo systemctl restart usbmuxd\" before retrying."
|
|
|
|
echo "* Recovery and DFU mode are also applicable."
|
|
|
|
echo "* For more details, read the \"Troubleshooting\" wiki page in GitHub."
|
|
|
|
Echo "* Troubleshooting link: https://github.com/LukeZGD/iOS-OTA-Downgrader/wiki/Troubleshooting"
|
2022-06-05 03:14:07 +02:00
|
|
|
ExitWin 1
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
Firmware=resources/firmware/$ProductType
|
|
|
|
Baseband=0
|
2021-11-18 11:33:15 +01:00
|
|
|
LatestVer="9.3.6"
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestBuildVer="13G37"
|
2022-11-26 14:38:37 +01:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $ProductType == "iPad2,2" ]]; then
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestVer="9.3.5"
|
|
|
|
LatestBuildVer="13G36"
|
2021-05-29 13:26:08 +02:00
|
|
|
Baseband="ICE3_04.12.09_BOOT_02.13.Release.bbfw"
|
|
|
|
BasebandSHA1="e6f54acc5d5652d39a0ef9af5589681df39e0aca"
|
|
|
|
|
2022-09-24 04:26:08 +02:00
|
|
|
elif [[ $ProductType == "iPad2,3" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
Baseband="Phoenix-3.6.03.Release.bbfw"
|
|
|
|
BasebandSHA1="8d4efb2214344ea8e7c9305392068ab0a7168ba4"
|
2022-09-24 04:26:08 +02:00
|
|
|
|
|
|
|
elif [[ $ProductType == "iPhone3,3" ]]; then
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestBuildVer="11D257"
|
2022-09-24 04:26:08 +02:00
|
|
|
Baseband="Phoenix-3.0.04.Release.bbfw"
|
|
|
|
BasebandSHA1="a507ee2fe061dfbf8bee7e512df52ade8777e113"
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
elif [[ $ProductType == "iPad2,6" || $ProductType == "iPad2,7" ]]; then
|
|
|
|
Baseband="Mav5-11.80.00.Release.bbfw"
|
|
|
|
BasebandSHA1="aa52cf75b82fc686f94772e216008345b6a2a750"
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPad3,2" || $ProductType == "iPad3,3" ]]; then
|
|
|
|
Baseband="Mav4-6.7.00.Release.bbfw"
|
|
|
|
BasebandSHA1="a5d6978ecead8d9c056250ad4622db4d6c71d15e"
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPhone4,1" ]]; then
|
|
|
|
Baseband="Trek-6.7.00.Release.bbfw"
|
|
|
|
BasebandSHA1="22a35425a3cdf8fa1458b5116cfb199448eecf49"
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPad3,5" || $ProductType == "iPad3,6" ||
|
|
|
|
$ProductType == "iPhone5,1" || $ProductType == "iPhone5,2" ]]; then
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestVer="10.3.4"
|
|
|
|
LatestBuildVer="14G61"
|
2021-05-29 13:26:08 +02:00
|
|
|
Baseband="Mav5-11.80.00.Release.bbfw"
|
|
|
|
BasebandSHA1="8951cf09f16029c5c0533e951eb4c06609d0ba7f"
|
2022-05-28 12:21:26 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $ProductType == "iPad4,2" || $ProductType == "iPad4,3" || $ProductType == "iPad4,5" ||
|
2022-05-28 12:21:26 +02:00
|
|
|
$ProductType == "iPhone5"* || $ProductType == "iPhone6"* ]]; then
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestBuildVer="14G60"
|
2021-05-29 13:26:08 +02:00
|
|
|
Baseband="Mav7Mav8-7.60.00.Release.bbfw"
|
|
|
|
BasebandSHA1="f397724367f6bed459cf8f3d523553c13e8ae12c"
|
2022-05-28 12:21:26 +02:00
|
|
|
if [[ $ProductType == "iPhone5"* ]]; then
|
|
|
|
Log "iPhone 5C detected. Your device does not support OTA downgrades."
|
|
|
|
Echo "* Functions will be limited to entering kDFU and restoring with blobs."
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPhone3"* ]]; then
|
2022-12-17 06:41:00 +01:00
|
|
|
LatestBuildVer="11D257"
|
2022-05-28 12:21:26 +02:00
|
|
|
Baseband="ICE3_04.12.09_BOOT_02.13.Release.bbfw"
|
|
|
|
BasebandSHA1="007365a5655ac2f9fbd1e5b6dba8f4be0513e364"
|
|
|
|
|
2022-12-17 06:41:00 +01:00
|
|
|
elif [[ $ProductType == "iPad2"* || $ProductType == "iPad3,1" || $ProductType == "iPod5,1" ]]; then
|
|
|
|
LatestVer="9.3.5"
|
|
|
|
LatestBuildVer="13G36"
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPad3,4" ]]; then
|
|
|
|
LatestVer="10.3.3"
|
|
|
|
LatestBuildVer="14G60"
|
|
|
|
|
|
|
|
elif [[ $ProductType == "iPad4,1" || $ProductType == "iPad4,4" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
BasebandURL=0
|
2022-05-28 12:21:26 +02:00
|
|
|
else
|
|
|
|
Error "Your device $ProductType ${version}is not supported."
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2022-12-17 06:41:00 +01:00
|
|
|
[[ $BasebandURL != 0 ]] && BasebandURL=$(cat $Firmware/$LatestBuildVer/url 2>/dev/null)
|
|
|
|
|
2022-05-28 12:21:26 +02:00
|
|
|
if [[ $ProductType == "iPhone3"* ]]; then
|
|
|
|
DeviceProc=4
|
2022-09-20 14:29:49 +02:00
|
|
|
if [[ $ProductType != "iPhone3,2" ]]; then
|
2022-09-20 14:28:20 +02:00
|
|
|
Log "$ProductType detected. iPhone4Down functions enabled."
|
2022-07-20 12:21:30 +02:00
|
|
|
Echo "* This script uses powdersn0w by dora2ios"
|
2022-07-07 08:21:53 +02:00
|
|
|
else
|
2022-07-20 12:21:30 +02:00
|
|
|
Log "$ProductType detected. Your device is not supported by powdersn0w (yet)"
|
2022-05-28 12:56:10 +02:00
|
|
|
Echo "* Functions will be limited to entering kDFU and restoring with blobs."
|
|
|
|
fi
|
2022-05-28 12:21:26 +02:00
|
|
|
elif [[ $ProductType == "iPad2"* || $ProductType == "iPad3,1" || $ProductType == "iPad3,2" ||
|
2021-05-29 13:26:08 +02:00
|
|
|
$ProductType == "iPad3,3" || $ProductType == "iPhone4,1" || $ProductType == "iPod5,1" ]]; then
|
|
|
|
DeviceProc=5
|
2021-06-19 09:31:20 +02:00
|
|
|
elif [[ $ProductType == "iPhone5"* || $ProductType == "iPad3"* ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
DeviceProc=6
|
|
|
|
elif [[ $ProductType == "iPhone6"* || $ProductType == "iPad4"* ]]; then
|
|
|
|
DeviceProc=7
|
|
|
|
fi
|
|
|
|
|
|
|
|
HWModel=$(cat $Firmware/hwmodel)
|
|
|
|
|
|
|
|
if [[ ! $BasebandURL || ! $HWModel ]]; then
|
2021-05-30 05:03:39 +02:00
|
|
|
Error "Missing BasebandURL and/or HWModel values. Is the firmware folder missing?" \
|
2021-10-05 05:10:32 +02:00
|
|
|
"Reinstall dependencies and try again. For more details, read the \"Troubleshooting\" wiki page in GitHub"
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $ProductType == "iPod5,1" ]]; then
|
|
|
|
iBSS="${HWModel}ap"
|
|
|
|
iBSSBuildVer="10B329"
|
2022-05-28 12:21:26 +02:00
|
|
|
elif [[ $ProductType == "iPad3,1" || $ProductType == "iPhone3"* ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
iBSS="${HWModel}ap"
|
|
|
|
iBSSBuildVer="11D257"
|
|
|
|
elif [[ $ProductType == "iPhone6"* ]]; then
|
|
|
|
iBSS="iphone6"
|
|
|
|
IPSWType="iPhone_4.0_64bit"
|
|
|
|
elif [[ $ProductType == "iPad4"* ]]; then
|
|
|
|
iBSS="ipad4"
|
|
|
|
IPSWType="iPad_64bit"
|
|
|
|
else
|
|
|
|
iBSS="$HWModel"
|
|
|
|
iBSSBuildVer="12H321"
|
|
|
|
fi
|
|
|
|
[[ ! $IPSWType ]] && IPSWType="$ProductType"
|
2022-05-30 16:17:56 +02:00
|
|
|
iBEC="iBEC.$iBSS.RELEASE"
|
|
|
|
iBECb="iBEC.${iBSS}b.RELEASE"
|
|
|
|
iBSSb="iBSS.${iBSS}b.RELEASE"
|
2021-05-29 13:26:08 +02:00
|
|
|
iBSS="iBSS.$iBSS.RELEASE"
|
|
|
|
SEP="sep-firmware.$HWModel.RELEASE.im4p"
|
|
|
|
|
2021-11-06 15:10:04 +01:00
|
|
|
Log "$ProductType ${version}connected in $DeviceState mode."
|
|
|
|
Log "ECID: $UniqueChipID"
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|
|
|
|
|
2022-05-28 12:21:26 +02:00
|
|
|
EnterPwnDFU() {
|
2021-05-29 13:26:08 +02:00
|
|
|
local pwnDFUTool
|
2021-06-08 05:04:40 +02:00
|
|
|
local pwnDFUDevice
|
2021-08-20 03:58:17 +02:00
|
|
|
local pwnD=1
|
2022-09-02 06:19:04 +02:00
|
|
|
local Selection=()
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2022-09-30 03:34:32 +02:00
|
|
|
if [[ $DeviceProc == 4 && $platform != "macos" ]]; then
|
2022-06-08 17:04:56 +02:00
|
|
|
pwnDFUTool="$pwnedDFU"
|
2022-07-20 12:21:30 +02:00
|
|
|
if [[ $platform == "win" ]]; then
|
|
|
|
Log "iPhone 4 device detected in DFU mode."
|
|
|
|
Echo "* Make sure that your device is already in pwnDFU mode."
|
|
|
|
Echo "* If your device is not in pwnDFU mode, the restore will not proceed!"
|
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
|
|
|
return
|
|
|
|
fi
|
2022-09-30 03:34:32 +02:00
|
|
|
elif [[ $platform == "macos" ]]; then
|
|
|
|
Selection+=("ipwnder_lite" "iPwnder32")
|
2022-02-14 09:08:57 +01:00
|
|
|
Input "PwnDFU Tool Option"
|
|
|
|
Echo "* This option selects what tool to use to put your device in pwnDFU mode."
|
2022-09-30 03:34:32 +02:00
|
|
|
Echo "* If unsure, select 1. If 1 does not work, try selecting the other option."
|
2022-05-28 12:21:26 +02:00
|
|
|
Echo "* This option is set to ${Selection[0]} by default (1)."
|
2022-02-14 09:08:57 +01:00
|
|
|
Input "Select your option:"
|
2021-06-27 10:13:51 +02:00
|
|
|
select opt in "${Selection[@]}"; do
|
2021-06-27 10:20:23 +02:00
|
|
|
case $opt in
|
2022-03-05 12:57:23 +01:00
|
|
|
"ipwnder_lite" ) pwnDFUTool="$ipwnder_lite"; break;;
|
2022-05-28 12:21:26 +02:00
|
|
|
"iPwnder32" ) pwnDFUTool="$ipwnder32"; break;;
|
2021-06-27 10:20:23 +02:00
|
|
|
esac
|
2021-06-27 10:13:51 +02:00
|
|
|
done
|
|
|
|
else
|
2022-11-02 01:08:29 +01:00
|
|
|
Echo "* Make sure to have python2 installed first before using ipwndfu."
|
2021-06-27 10:13:51 +02:00
|
|
|
pwnDFUTool="ipwndfu"
|
2022-07-07 08:21:53 +02:00
|
|
|
SaveExternal ipwndfu
|
2021-06-27 10:13:51 +02:00
|
|
|
fi
|
|
|
|
|
2022-07-04 04:45:05 +02:00
|
|
|
Log "Entering pwnDFU mode with: $pwnDFUTool"
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $pwnDFUTool == "ipwndfu" ]]; then
|
|
|
|
cd resources/ipwndfu
|
|
|
|
$ipwndfu -p
|
2022-05-28 12:21:26 +02:00
|
|
|
pwnDFUDevice=$?
|
|
|
|
if [[ $DeviceProc == 7 ]]; then
|
2021-06-21 13:53:02 +02:00
|
|
|
Log "Running rmsigchks.py..."
|
|
|
|
$rmsigchks
|
2021-07-20 03:13:10 +02:00
|
|
|
pwnDFUDevice=$?
|
2022-07-07 08:21:53 +02:00
|
|
|
cd ../..
|
2021-06-21 13:53:02 +02:00
|
|
|
else
|
2022-07-07 08:21:53 +02:00
|
|
|
cd ../..
|
|
|
|
SendPwnediBSS
|
2021-06-21 13:53:02 +02:00
|
|
|
fi
|
2022-02-14 09:08:57 +01:00
|
|
|
else
|
2022-09-30 03:34:32 +02:00
|
|
|
$pwnDFUTool -p
|
2021-09-02 07:33:04 +02:00
|
|
|
pwnDFUDevice=$?
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2022-07-04 04:45:05 +02:00
|
|
|
if [[ $DeviceProc == 4 || $DeviceProc == 7 ]]; then
|
|
|
|
pwnD=$($irecovery -q | grep -c "PWND")
|
|
|
|
SendiBSS=1
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2022-09-20 14:28:20 +02:00
|
|
|
if [[ $DeviceProc == 4 ]]; then
|
2022-08-20 06:45:07 +02:00
|
|
|
if [[ $pwnD != 1 ]]; then
|
|
|
|
Error "Failed to enter pwnDFU mode. Please run the script again. Note that kDFU mode will NOT work!" \
|
2022-07-04 04:45:05 +02:00
|
|
|
"Exit DFU mode first by holding the TOP and HOME buttons for about 15 seconds."
|
|
|
|
else
|
|
|
|
Log "Device in pwnDFU mode detected."
|
|
|
|
fi
|
2022-06-08 17:04:56 +02:00
|
|
|
elif [[ $pwnDFUDevice != 0 && $pwnD != 1 ]]; then
|
2022-12-19 03:10:18 +01:00
|
|
|
echo -e "\n${Color_R}[Error] Failed to enter pwnDFU mode. Please run the script again"
|
|
|
|
echo "${Color_Y}* If the screen is black, exit DFU mode first by holding the TOP and HOME buttons for about 15 seconds."
|
|
|
|
echo "* This step may fail a lot, especially on Linux, and unfortunately there is nothing I can do about the low success rates."
|
|
|
|
echo "* The only option is to make sure you are using an Intel or Apple Silicon device, and to try multiple times."
|
|
|
|
echo "* For more details, read the \"Troubleshooting\" wiki page in GitHub"
|
|
|
|
Echo "* Troubleshooting link: https://github.com/LukeZGD/iOS-OTA-Downgrader/wiki/Troubleshooting"
|
2022-06-05 03:14:07 +02:00
|
|
|
ExitWin 1
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $pwnDFUDevice == 0 ]]; then
|
|
|
|
Log "Device in pwnDFU mode detected."
|
2021-08-20 03:58:17 +02:00
|
|
|
else
|
2022-10-15 12:50:03 +02:00
|
|
|
Log "WARNING - Failed to detect device in pwnDFU mode."
|
2021-08-20 03:58:17 +02:00
|
|
|
Echo "* If the device entered pwnDFU mode successfully, you may continue"
|
|
|
|
Echo "* If entering pwnDFU failed, you may have to force restart your device and start over"
|
2022-07-07 08:21:53 +02:00
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
Recovery() {
|
|
|
|
local RecoveryDFU
|
|
|
|
|
|
|
|
if [[ $DeviceState != "Recovery" ]]; then
|
|
|
|
Log "Entering recovery mode..."
|
|
|
|
$ideviceenterrecovery $UniqueDeviceID >/dev/null
|
|
|
|
FindDevice "Recovery"
|
|
|
|
fi
|
2022-12-17 06:41:00 +01:00
|
|
|
[[ $1 == "only" ]] && return
|
|
|
|
|
2021-06-27 10:13:51 +02:00
|
|
|
Echo "* Get ready to enter DFU mode."
|
2021-05-29 13:26:08 +02:00
|
|
|
read -p "$(Input 'Select Y to continue, N to exit recovery (Y/n)')" RecoveryDFU
|
|
|
|
if [[ $RecoveryDFU == 'N' || $RecoveryDFU == 'n' ]]; then
|
|
|
|
Log "Exiting recovery mode."
|
|
|
|
$irecovery -n
|
2022-07-07 08:21:53 +02:00
|
|
|
ExitWin 0
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
2022-05-28 12:21:26 +02:00
|
|
|
Echo "* Hold TOP and HOME buttons for 10 seconds."
|
|
|
|
for i in {10..01}; do
|
2021-05-29 13:26:08 +02:00
|
|
|
echo -n "$i "
|
|
|
|
sleep 1
|
|
|
|
done
|
2021-11-25 08:24:50 +01:00
|
|
|
echo -e "\n$(Echo '* Release TOP button and hold HOME button for 8 seconds.')"
|
2021-05-29 13:26:08 +02:00
|
|
|
for i in {08..01}; do
|
|
|
|
echo -n "$i "
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
|
2021-07-12 16:36:51 +02:00
|
|
|
FindDevice "DFU" error
|
2022-05-28 12:21:26 +02:00
|
|
|
EnterPwnDFU
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|
|
|
|
|
2021-09-30 05:49:41 +02:00
|
|
|
RecoveryExit() {
|
|
|
|
read -p "$(Input 'Attempt to exit recovery mode? (Y/n)')" Selection
|
|
|
|
if [[ $Selection != 'N' && $Selection != 'n' ]]; then
|
|
|
|
Log "Exiting recovery mode."
|
|
|
|
$irecovery -n
|
|
|
|
fi
|
2022-07-07 08:21:53 +02:00
|
|
|
ExitWin 0
|
2021-09-30 05:49:41 +02:00
|
|
|
}
|
|
|
|
|
2022-06-08 18:14:01 +02:00
|
|
|
PatchiBSS() {
|
2022-05-28 12:21:26 +02:00
|
|
|
if [[ $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
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ ! -e saved/$ProductType/$iBSS.dfu ]]; then
|
|
|
|
Log "Downloading iBSS..."
|
2021-11-17 07:37:02 +01:00
|
|
|
$partialzip "$(cat $Firmware/$iBSSBuildVer/url)" Firmware/dfu/$iBSS.dfu $iBSS.dfu
|
2021-05-29 13:26:08 +02:00
|
|
|
mkdir -p saved/$ProductType 2>/dev/null
|
2022-10-11 03:41:07 +02:00
|
|
|
mv $iBSS.dfu saved/$ProductType/
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2022-06-08 18:14:01 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ ! -e saved/$ProductType/$iBSS.dfu ]]; then
|
|
|
|
Error "Failed to save iBSS. Please run the script again"
|
|
|
|
fi
|
2022-06-08 18:14:01 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Patching iBSS..."
|
|
|
|
$bspatch saved/$ProductType/$iBSS.dfu tmp/pwnediBSS resources/patches/$iBSS.patch
|
2022-06-08 18:14:01 +02:00
|
|
|
}
|
|
|
|
|
2022-07-07 08:21:53 +02:00
|
|
|
SendPwnediBSSA5() {
|
2022-12-14 12:01:24 +01:00
|
|
|
Echo "* You need to have an Arduino and USB Host Shield to proceed for PWNED DFU mode."
|
|
|
|
Echo "* If you do not know what you are doing, select N and restart your device in normal mode before retrying."
|
|
|
|
read -p "$(Input 'Is your device in PWNED DFU mode using synackuk checkm8-a5? (y/N):')" opt
|
|
|
|
if [[ $opt != "Y" && $opt != "y" && $DeviceProc == 5 ]]; then
|
|
|
|
echo -e "\n${Color_R}[Error] 32-bit A5 device is not in PWNED DFU mode. ${Color_N}"
|
|
|
|
echo "${Color_Y}* Please put the device in normal mode and jailbroken before proceeding. ${Color_N}"
|
|
|
|
echo "${Color_Y}* Exit DFU mode by holding the TOP and HOME buttons for 15 seconds. ${Color_N}"
|
|
|
|
echo "${Color_Y}* For usage of kDFU/pwnDFU, read the \"Troubleshooting\" wiki page in GitHub ${Color_N}"
|
|
|
|
ExitWin 1
|
|
|
|
fi
|
2022-06-08 18:14:01 +02:00
|
|
|
Input "No iBSS Option"
|
2022-06-09 04:37:29 +02:00
|
|
|
Echo "* If you already have sent pwned iBSS manually, select Y. If not, select N."
|
2022-06-08 18:14:01 +02:00
|
|
|
Echo "* This option is disabled by default (N)."
|
|
|
|
read -p "$(Input 'Enable this option? (y/N):')" SendiBSS
|
|
|
|
if [[ $SendiBSS == 'Y' || $SendiBSS == 'y' ]]; then
|
|
|
|
Log "No iBSS option enabled by user."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
Input "Send iBSS Option"
|
2022-06-09 04:37:29 +02:00
|
|
|
Echo "* To send pwned iBSS using ipwndfu, select Y. (does not work on ARM Macs)"
|
|
|
|
Echo "* To let futurerestore send iBSS, select N. (likely does not work)"
|
2022-11-02 01:08:29 +01:00
|
|
|
Echo "* Make sure to have python2 installed first before using ipwndfu."
|
2022-06-08 18:14:01 +02:00
|
|
|
Echo "* This option is enabled by default (Y)."
|
|
|
|
read -p "$(Input 'Enable this option? (Y/n):')" SendiBSS
|
|
|
|
if [[ $SendiBSS == 'N' || $SendiBSS == 'n' ]]; then
|
|
|
|
Log "Send iBSS option disabled by user."
|
|
|
|
SendiBSS=1
|
|
|
|
return
|
|
|
|
fi
|
2022-07-07 08:21:53 +02:00
|
|
|
SendPwnediBSS
|
|
|
|
}
|
2022-06-08 18:14:01 +02:00
|
|
|
|
2022-07-07 08:21:53 +02:00
|
|
|
SendPwnediBSS() {
|
|
|
|
SaveExternal ipwndfu
|
2022-06-09 04:37:29 +02:00
|
|
|
PatchiBSS
|
2022-06-08 18:14:01 +02:00
|
|
|
cd resources/ipwndfu
|
|
|
|
Log "Sending iBSS..."
|
|
|
|
$ipwndfu -l ../../tmp/pwnediBSS
|
|
|
|
cd ../..
|
|
|
|
}
|
|
|
|
|
|
|
|
kDFU() {
|
|
|
|
local kloader
|
|
|
|
local VerDetect=$(echo $ProductVer | cut -c 1)
|
|
|
|
|
|
|
|
if [[ $DeviceState != "Normal" ]]; then
|
|
|
|
Log "Device is already in $DeviceState mode"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
PatchiBSS
|
2022-05-28 12:21:26 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ $VerDetect == 1 ]] && kloader="kloader_hgsp"
|
|
|
|
[[ $VerDetect == 5 ]] && kloader="kloader5"
|
|
|
|
[[ ! $kloader ]] && kloader="kloader"
|
|
|
|
|
2022-03-12 09:00:10 +01:00
|
|
|
Log "Running iproxy for SSH..."
|
2022-11-26 14:38:37 +01:00
|
|
|
$iproxy 2222 22 >/dev/null &
|
2021-05-29 13:26:08 +02:00
|
|
|
iproxyPID=$!
|
2022-03-12 09:00:10 +01:00
|
|
|
sleep 2
|
2021-09-06 10:50:29 +02:00
|
|
|
|
2022-11-26 14:38:37 +01:00
|
|
|
Log "Please read the message below:"
|
|
|
|
Echo "1. Make sure to have installed the requirements from Cydia."
|
|
|
|
Echo " - Only proceed if you have followed Section 2 (and 2.1 for iOS 10) in the GitHub wiki."
|
|
|
|
Echo " - You will be prompted to enter the root password of your iOS device twice."
|
2022-12-14 12:01:24 +01:00
|
|
|
Echo " - The default root password is \"alpine\""
|
2022-11-26 14:38:37 +01:00
|
|
|
Echo " - Do not worry that your input is not visible, it is still being entered."
|
|
|
|
Echo "2. Afterwards, the device will disconnect and its screen will stay black."
|
|
|
|
Echo " - Proceed to either press the TOP/HOME button, or unplug and replug the device."
|
|
|
|
sleep 3
|
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
|
|
|
Log "Entering kDFU mode..."
|
2021-05-29 13:26:08 +02:00
|
|
|
$SCP -P 2222 resources/tools/$kloader tmp/pwnediBSS root@127.0.0.1:/tmp
|
|
|
|
if [[ $? == 0 ]]; then
|
2021-09-29 07:33:34 +02:00
|
|
|
$SSH -p 2222 root@127.0.0.1 "chmod +x /tmp/$kloader; /tmp/$kloader /tmp/pwnediBSS" &
|
2021-05-29 13:26:08 +02:00
|
|
|
else
|
2022-11-26 14:38:37 +01:00
|
|
|
Log "Failed to connect to device via USB SSH."
|
|
|
|
Echo "* For Linux users, try running \"sudo systemctl restart usbmuxd\" before retrying USB SSH."
|
2022-12-14 12:01:24 +01:00
|
|
|
if [[ $VerDetect == 1 ]]; then
|
|
|
|
Echo "* Try to re-install both OpenSSH and Dropbear, reboot, re-jailbreak with h3lix, and try again."
|
|
|
|
elif [[ $VerDetect == 5 ]]; then
|
|
|
|
Echo "* Try to re-install OpenSSH, reboot, and try again."
|
|
|
|
else
|
|
|
|
Echo "* Try to re-install OpenSSH, reboot, re-jailbreak, and try again."
|
|
|
|
Echo "* Alternatively, you may use kDFUApp from my Cydia repo (see \"Troubleshooting\" wiki page for details)"
|
|
|
|
Echo "* Troubleshooting link: https://github.com/LukeZGD/iOS-OTA-Downgrader/wiki/Troubleshooting#dfu-advanced-menu-kdfu-mode"
|
|
|
|
fi
|
2022-11-26 14:38:37 +01:00
|
|
|
Input "Press Enter/Return to try again with Wi-Fi SSH (or press Ctrl+C to cancel and try again)"
|
2021-05-29 13:26:08 +02:00
|
|
|
read -s
|
|
|
|
Log "Will try again with Wi-Fi SSH..."
|
2022-11-26 14:38:37 +01:00
|
|
|
Echo "* Make sure that your iOS device and PC/Mac are on the same network."
|
|
|
|
Echo "* To get your device's IP Address, go to: Settings -> Wi-Fi/WLAN -> tap the 'i' next to your network name"
|
2021-05-29 13:26:08 +02:00
|
|
|
read -p "$(Input 'Enter the IP Address of your device:')" IPAddress
|
|
|
|
$SCP resources/tools/$kloader tmp/pwnediBSS root@$IPAddress:/tmp
|
2022-11-26 14:38:37 +01:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
Error "Failed to connect to device via SSH, cannot continue."
|
2021-05-30 05:03:39 +02:00
|
|
|
fi
|
2021-11-06 15:10:04 +01:00
|
|
|
$SSH root@$IPAddress "chmod +x /tmp/$kloader; /tmp/$kloader /tmp/pwnediBSS" &
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
FindDevice "DFU"
|
|
|
|
}
|
2022-05-28 12:56:10 +02:00
|
|
|
|
2022-09-20 14:28:20 +02:00
|
|
|
Remove4DL() {
|
|
|
|
local Link
|
|
|
|
if [[ ! -e saved/$ProductType/$1_p ]]; then
|
|
|
|
Link=$(cat $Firmware/11D257/url)
|
|
|
|
[[ -n $2 ]] && Link=$(cat $Firmware/$2/url)
|
|
|
|
Log "Downloading $1..."
|
|
|
|
$partialzip $Link Firmware/dfu/$1.${HWModel}ap.RELEASE.dfu $1
|
|
|
|
mkdir -p saved/$ProductType 2>/dev/null
|
|
|
|
cp $1 saved/$ProductType/$1_p
|
2022-10-11 03:41:07 +02:00
|
|
|
mv $1 tmp/
|
2022-09-20 14:28:20 +02:00
|
|
|
else
|
|
|
|
cp saved/$ProductType/$1_p tmp/$1
|
|
|
|
fi
|
|
|
|
Log "Patching $1..."
|
|
|
|
if [[ -n $2 ]]; then
|
|
|
|
$bspatch tmp/iBSS tmp/pwnediBSS resources/patches/$1.${HWModel}ap.$2.patch
|
|
|
|
else
|
|
|
|
$bspatch tmp/$1 tmp/pwned$1 resources/patches/$1.${HWModel}ap.RELEASE.patch
|
|
|
|
fi
|
|
|
|
Log "Booting $1..."
|
|
|
|
$irecovery -f tmp/pwned$1
|
|
|
|
}
|
|
|
|
|
2022-05-28 12:56:10 +02:00
|
|
|
Remove4() {
|
|
|
|
Input "Select option:"
|
|
|
|
select opt in "Disable exploit" "Enable exploit" "(Any other key to exit)"; do
|
|
|
|
case $opt in
|
|
|
|
"Disable exploit" ) Rec=0; break;;
|
|
|
|
"Enable exploit" ) Rec=2; break;;
|
|
|
|
* ) exit 0;;
|
|
|
|
esac
|
|
|
|
done
|
2022-09-20 14:28:20 +02:00
|
|
|
|
|
|
|
if [[ $ProductType == "iPhone3,1" ]]; then
|
|
|
|
Remove4DL iBSS 8L1
|
2022-05-28 12:56:10 +02:00
|
|
|
else
|
2022-09-20 14:28:20 +02:00
|
|
|
Remove4DL iBSS
|
|
|
|
Remove4DL iBEC
|
2022-05-28 12:56:10 +02:00
|
|
|
fi
|
|
|
|
sleep 2
|
|
|
|
Log "Running commands..."
|
|
|
|
$irecovery -c "setenv boot-partition $Rec"
|
|
|
|
$irecovery -c "saveenv"
|
|
|
|
$irecovery -c "setenv auto-boot true"
|
|
|
|
$irecovery -c "saveenv"
|
|
|
|
$irecovery -c "reset"
|
|
|
|
Log "Done!"
|
2022-12-14 12:01:24 +01:00
|
|
|
Echo "* If disabling the exploit did not work and the device is still in recovery mode screen after restore:"
|
2022-05-28 12:56:10 +02:00
|
|
|
Echo "* You may try another method for clearing NVRAM. See the \"Troubleshooting\" wiki page for more details"
|
2022-12-14 12:01:24 +01:00
|
|
|
Echo "* Troubleshooting link: https://github.com/LukeZGD/iOS-OTA-Downgrader/wiki/Troubleshooting#clearing-nvram"
|
2022-05-28 12:56:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Ramdisk4() {
|
|
|
|
Ramdisk=(
|
|
|
|
058-1056-002.dmg
|
|
|
|
DeviceTree.n90ap.img3
|
|
|
|
iBEC.n90ap.RELEASE.dfu
|
|
|
|
iBSS.n90ap.RELEASE.dfu
|
|
|
|
kernelcache.release.n90
|
|
|
|
)
|
|
|
|
|
|
|
|
Echo "Mode: Ramdisk"
|
|
|
|
Echo "* This uses files and script from 4tify by Zurac-Apps"
|
|
|
|
Echo "* Make sure that your device is already in DFU mode"
|
|
|
|
|
2022-06-18 14:22:46 +02:00
|
|
|
if [[ ! $(ls resources/ramdisk) ]]; then
|
2022-05-28 12:56:10 +02:00
|
|
|
JailbreakLink=https://github.com/Zurac-Apps/4tify/raw/ad319e2774f54dc3a355812cc287f39f7c38cc66
|
|
|
|
cd tmp
|
|
|
|
mkdir ramdisk
|
|
|
|
cd ramdisk
|
|
|
|
Log "Downloading ramdisk files from 4tify repo..."
|
|
|
|
for file in "${Ramdisk[@]}"; do
|
|
|
|
curl -L $JailbreakLink/support_files/7.1.2/Ramdisk/$file -o $file
|
|
|
|
done
|
|
|
|
cd ..
|
2022-11-02 01:08:29 +01:00
|
|
|
cp -R ramdisk ../resources
|
2022-05-28 12:56:10 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
Log "Sending iBSS..."
|
2022-07-29 10:59:38 +02:00
|
|
|
$irecovery -f resources/ramdisk/iBSS.n90ap.RELEASE.dfu
|
2022-05-28 12:56:10 +02:00
|
|
|
sleep 2
|
|
|
|
Log "Sending iBEC..."
|
2022-07-29 10:59:38 +02:00
|
|
|
$irecovery -f resources/ramdisk/iBEC.n90ap.RELEASE.dfu
|
2022-05-28 12:56:10 +02:00
|
|
|
FindDevice "Recovery" error
|
|
|
|
|
|
|
|
Log "Booting..."
|
2022-07-29 10:59:38 +02:00
|
|
|
$irecovery -f resources/ramdisk/DeviceTree.n90ap.img3
|
|
|
|
$irecovery -c devicetree
|
|
|
|
$irecovery -f resources/ramdisk/058-1056-002.dmg
|
|
|
|
$irecovery -c ramdisk
|
|
|
|
$irecovery -f resources/ramdisk/kernelcache.release.n90
|
|
|
|
$irecovery -c bootx
|
2022-05-28 12:56:10 +02:00
|
|
|
FindDevice "Restore" error
|
|
|
|
|
|
|
|
Log "Device should now be in SSH ramdisk mode."
|
|
|
|
echo
|
|
|
|
Echo "* To access SSH ramdisk, run iproxy first:"
|
|
|
|
Echo " iproxy 2022 22"
|
|
|
|
Echo "* Then SSH to 127.0.0.1:2022"
|
|
|
|
Echo " ssh -p 2022 -oHostKeyAlgorithms=+ssh-rsa root@127.0.0.1"
|
|
|
|
Echo "* Enter root password: alpine"
|
2022-09-18 10:16:36 +02:00
|
|
|
Echo "* Mount filesystems with these commands (iOS 5+):"
|
2022-05-28 12:56:10 +02:00
|
|
|
Echo " mount_hfs /dev/disk0s1s1 /mnt1"
|
|
|
|
Echo " mount_hfs /dev/disk0s1s2 /mnt1/private/var"
|
2022-09-18 10:16:36 +02:00
|
|
|
Echo "* If your device is on iOS 4, use these commands instead:"
|
|
|
|
Echo " fsck_hfs /dev/disk0s1"
|
|
|
|
Echo " mount_hfs /dev/disk0s1 /mnt1"
|
|
|
|
Echo " mount_hfs /dev/disk0s2s1 /mnt/private/var"
|
2022-07-29 10:59:38 +02:00
|
|
|
Echo "* To reboot, use this command:"
|
|
|
|
Echo " reboot_bak"
|
2022-05-28 12:56:10 +02:00
|
|
|
}
|
2022-05-29 16:57:53 +02:00
|
|
|
|
|
|
|
EnterPwnREC() {
|
|
|
|
local Attempt=1
|
|
|
|
|
|
|
|
if [[ $ProductType == "iPad4,4" || $ProductType == "iPad4,5" ]]; then
|
|
|
|
Log "iPad mini 2 device detected. Setting iBSS and iBEC to \"ipad4b\""
|
|
|
|
iBEC=$iBECb
|
|
|
|
iBSS=$iBSSb
|
|
|
|
fi
|
|
|
|
|
2022-05-30 16:17:56 +02:00
|
|
|
while (( Attempt < 4 )); do
|
2022-05-29 16:57:53 +02:00
|
|
|
Log "Entering pwnREC mode... (Attempt $Attempt)"
|
|
|
|
Log "Sending iBSS..."
|
|
|
|
$irecovery -f $IPSWCustom/Firmware/dfu/$iBSS.im4p
|
|
|
|
$irecovery -f $IPSWCustom/Firmware/dfu/$iBSS.im4p
|
|
|
|
Log "Sending iBEC..."
|
|
|
|
$irecovery -f $IPSWCustom/Firmware/dfu/$iBEC.im4p
|
|
|
|
sleep 3
|
|
|
|
FindDevice "Recovery" timeout
|
|
|
|
[[ $? == 0 ]] && break
|
2022-05-31 06:35:00 +02:00
|
|
|
Echo "* You may also try to unplug and replug your device"
|
2022-05-29 16:57:53 +02:00
|
|
|
((Attempt++))
|
|
|
|
done
|
|
|
|
|
2022-05-30 16:17:56 +02:00
|
|
|
if (( Attempt == 4 )); then
|
2022-05-29 16:57:53 +02:00
|
|
|
Error "Failed to enter pwnREC mode. You may have to force restart your device and start over entering pwnDFU mode again"
|
|
|
|
fi
|
|
|
|
}
|