mirror of
https://github.com/LukeZGD/Legacy-iOS-Kit.git
synced 2024-12-23 23:01:49 +01:00
Update and fix various stuff (#107)
* Add FindDevice timeout and choice to continue * Use libimobiledevice and libirecovery from Homebrew when detected * Update depends.sh * Detect ASi homebrew, add attempts for entering pwnREC * Update depends.sh * Fix some things
This commit is contained in:
parent
d3d27a0c4f
commit
073615b140
@ -90,6 +90,8 @@
|
||||
- Do not use USB-C to lightning cables as this can prevent a successful restore
|
||||
- ipwndfu is unfortunately very unreliable on Linux, you may have to try multiple times (Linux users may also try in a live USB)
|
||||
- If the script cannot find your device in pwnREC mode or gets stuck, you may have to start over by [force restarting](https://support.apple.com/en-ph/guide/iphone/iph8903c3ee6/ios) and re-entering recovery/DFU mode
|
||||
- macOS users may have to install libimobiledevice and libirecovery from [Homebrew](https://brew.sh/) with this command: `brew install libimobiledevice libirecovery`
|
||||
- The script will detect this automatically and will use the Homebrew versions of the tools
|
||||
- Use an Intel PC/Mac as entering pwnDFU (checkm8) may be a lot more unreliable on AMD devices
|
||||
- Other than the above, unfortunately there is not much else I can do to help regarding entering pwnDFU mode.
|
||||
- **For 32-bit devices:**
|
||||
|
@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
SetToolPaths() {
|
||||
local MPath="./resources/libimobiledevice_"
|
||||
if [[ $OSTYPE == "linux"* ]]; then
|
||||
. /etc/os-release 2>/dev/null
|
||||
platform="linux"
|
||||
platformver="$PRETTY_NAME"
|
||||
MPath+="$platform"
|
||||
|
||||
bspatch="$(which bspatch)"
|
||||
futurerestore1="sudo LD_PRELOAD=./resources/lib/libcurl.so.3 LD_LIBRARY_PATH=./resources/lib ./resources/tools/futurerestore1_linux"
|
||||
@ -19,6 +21,14 @@ SetToolPaths() {
|
||||
elif [[ $OSTYPE == "darwin"* ]]; then
|
||||
platform="macos"
|
||||
platformver="${1:-$(sw_vers -productVersion)}"
|
||||
MPath+="$platform"
|
||||
if [[ -e /usr/local/bin/idevicedate && -e /usr/local/bin/irecovery ]]; then
|
||||
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Intel Mac)"
|
||||
MPath="/usr/local/bin"
|
||||
elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then
|
||||
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Apple Silicon)"
|
||||
MPath="/opt/homebrew/bin"
|
||||
fi
|
||||
|
||||
bspatch="/usr/bin/bspatch"
|
||||
futurerestore1="./resources/tools/futurerestore1_macos"
|
||||
@ -32,11 +42,11 @@ SetToolPaths() {
|
||||
tsschecker2="./resources/tools/tsschecker2_macos"
|
||||
fi
|
||||
git="$(which git)"
|
||||
ideviceenterrecovery="./resources/libimobiledevice_$platform/ideviceenterrecovery"
|
||||
ideviceinfo="./resources/libimobiledevice_$platform/ideviceinfo"
|
||||
iproxy="./resources/libimobiledevice_$platform/iproxy"
|
||||
ideviceenterrecovery="$MPath/ideviceenterrecovery"
|
||||
ideviceinfo="$MPath/ideviceinfo"
|
||||
iproxy="$MPath/iproxy"
|
||||
ipsw="./tools/ipsw_$platform"
|
||||
irecoverychk="./resources/libimobiledevice_$platform/irecovery"
|
||||
irecoverychk="$MPath/irecovery"
|
||||
irecovery="$irecoverychk"
|
||||
[[ $platform == "linux" ]] && irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
|
||||
partialzip="./resources/tools/partialzip_$platform"
|
||||
@ -130,6 +140,10 @@ InstallDepends() {
|
||||
elif [[ $platform == "macos" ]]; then
|
||||
xcode-select --install
|
||||
libimobiledevice=("https://github.com/libimobiledevice-win32/imobiledevice-net/releases/download/v1.3.14/libimobiledevice.1.2.1-r1116-osx-x64.zip" "328e809dea350ae68fb644225bbf8469c0f0634b")
|
||||
Echo "* iOS-OTA-Downgrader provides a copy of libimobiledevice and libirecovery by default"
|
||||
Echo "* In case that problems occur, try installing them from Homebrew"
|
||||
Echo "* The script will detect this automatically and will use the Homebrew versions of the tools"
|
||||
Echo "* Install using this command: 'brew install libimobiledevice libirecovery'"
|
||||
|
||||
else
|
||||
Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros"
|
||||
@ -140,9 +154,11 @@ InstallDepends() {
|
||||
fi
|
||||
|
||||
if [[ ! -d ../resources/libimobiledevice_$platform ]]; then
|
||||
Log "Downloading libimobiledevice..."
|
||||
SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]}
|
||||
mkdir ../resources/libimobiledevice_$platform
|
||||
unzip libimobiledevice.zip -d ../resources/libimobiledevice_$platform
|
||||
Log "Extracting libimobiledevice..."
|
||||
unzip -q libimobiledevice.zip -d ../resources/libimobiledevice_$platform
|
||||
chmod +x ../resources/libimobiledevice_$platform/*
|
||||
fi
|
||||
|
||||
|
@ -1,17 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
FindDevice() {
|
||||
local DeviceIn
|
||||
local i=0
|
||||
local Timeout=999
|
||||
local USB
|
||||
[[ $1 == "DFU" ]] && USB=1227 || USB=1281
|
||||
[[ ! -z $2 ]] && Timeout=3
|
||||
|
||||
Log "Finding device in $1 mode..."
|
||||
while [[ $DeviceState != "$1" ]]; do
|
||||
[[ $platform == "linux" ]] && DeviceState=$(lsusb | grep -c $USB)
|
||||
[[ $platform == "macos" && $($irecovery -q 2>/dev/null | grep "MODE" | cut -c 7-) == "$1" ]] && DeviceState=1
|
||||
[[ $DeviceState == 1 ]] && DeviceState="$1"
|
||||
while (( $i < $Timeout )); do
|
||||
[[ $($irecovery -q 2>/dev/null | grep "MODE" | cut -c 7-) == "$1" ]] && DeviceIn=1
|
||||
if [[ $DeviceIn == 1 ]]; then
|
||||
Log "Found device in $1 mode."
|
||||
DeviceState="$1"
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
((i++))
|
||||
done
|
||||
Log "Found device in $1 mode."
|
||||
|
||||
if [[ $DeviceIn != 1 ]]; then
|
||||
[[ $2 == "error" ]] && Error "Failed to find device in $1 mode. (Timed out)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
GetDeviceValues() {
|
||||
@ -171,7 +183,7 @@ CheckM8() {
|
||||
if [[ $pwnDFUDevice != 0 && $($irecovery -q | grep -c "PWND") != 1 ]]; then
|
||||
echo -e "\n${Color_R}[Error] Failed to enter pwnDFU mode. Please run the script again: ./restore.sh Downgrade ${Color_N}"
|
||||
echo "${Color_Y}* This step may fail a lot, especially on Linux, and unfortunately there is nothing I can do about the low success rates. ${Color_N}"
|
||||
echo "${Color_Y}* The only option is to make sure you are using an Intel or M1 device, and to try multiple times ${Color_N}"
|
||||
echo "${Color_Y}* The only option is to make sure you are using an Intel or Apple Silicon device, and to try multiple times ${Color_N}"
|
||||
Echo "* For more details, read the \"Other Notes\" section of the README"
|
||||
exit 1
|
||||
elif [[ $pwnDFUDevice == 0 ]]; then
|
||||
@ -208,7 +220,7 @@ Recovery() {
|
||||
done
|
||||
echo
|
||||
|
||||
FindDevice "DFU"
|
||||
FindDevice "DFU" error
|
||||
CheckM8
|
||||
}
|
||||
|
||||
@ -282,20 +294,29 @@ kDFU() {
|
||||
}
|
||||
|
||||
pwnREC() {
|
||||
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
|
||||
Log "Entering pwnREC mode..."
|
||||
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 5
|
||||
Echo "* If your device has backlight turned on, you may try unplugging and re-plugging in your device to attempt to continue"
|
||||
Echo "* If not, you may have to force restart your device and start over entering pwnDFU mode again"
|
||||
Echo "* You can press Ctrl+C to cancel finding device"
|
||||
FindDevice "Recovery"
|
||||
|
||||
while (( $Attempt < 4 )); do
|
||||
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
|
||||
((Attempt++))
|
||||
done
|
||||
|
||||
if (( $Attempt == 4 )); then
|
||||
Error "Failed to enter pwnREC mode. You may have to force restart your device and start over entering pwnDFU mode again" \
|
||||
"macOS users may have to install libimobiledevice and libirecovery from Homebrew. For more details, read the \"Other Notes\" section of the README"
|
||||
fi
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ Main() {
|
||||
fi
|
||||
|
||||
if [[ $platform == "macos" && $(uname -m) != "x86_64" ]]; then
|
||||
Log "M1 Mac detected. Support is limited, proceed at your own risk."
|
||||
Log "Apple Silicon Mac detected. Support may be limited, proceed at your own risk."
|
||||
elif [[ $(uname -m) != "x86_64" ]]; then
|
||||
Error "Only 64-bit (x86_64) distributions are supported."
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user