Add Windows support (#138)

- Tested on Windows 10 64-bit 1809, iTunes 12.10.something (I don't remember the specific version), and the latest MSYS2
- To run iOS-OTA-Downgrader on Windows, MSYS2 and iTunes are needed to be installed
This commit is contained in:
LukeeGD 2021-09-29 13:33:34 +08:00 committed by GitHub
parent b3990bcfe5
commit ec7adc51a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 27 deletions

View File

@ -1,7 +1,8 @@
# iOS-OTA-Downgrader # iOS-OTA-Downgrader
### Downgrade/restore and jailbreak iOS devices to signed OTA firmwares ### Downgrade/restore and jailbreak iOS devices to signed OTA firmwares
- **Linux and macOS** are supported - **Linux, macOS, and Windows** are supported
- Windows users can create a Linux live USB (see Requirements) - Windows support is limited. [MSYS2](https://www.msys2.org/#installation) and iTunes 64-bit are required. To run the script, click `restore.cmd`.
- Windows users can also create a Linux live USB (see Requirements)
- iOS 8.4.1 and 6.1.3 downgrades have the option to **jailbreak** the install - iOS 8.4.1 and 6.1.3 downgrades have the option to **jailbreak** the install
- For iOS 10.3.3, use [TotallyNotSpyware](https://totally-not.spyware.lol) or [sockH3lix](https://github.com/SongXiaoXi/sockH3lix) to jailbreak - For iOS 10.3.3, use [TotallyNotSpyware](https://totally-not.spyware.lol) or [sockH3lix](https://github.com/SongXiaoXi/sockH3lix) to jailbreak
- **You do NOT need blobs to use this**, the script will get them for you - **You do NOT need blobs to use this**, the script will get them for you
@ -13,6 +14,8 @@
- You can identify your device [here](https://ipsw.me/device-finder) - You can identify your device [here](https://ipsw.me/device-finder)
- **iPhone 5C and iPad mini 3 devices are NOT supported** (OTA versions for them are not signed) - **iPhone 5C and iPad mini 3 devices are NOT supported** (OTA versions for them are not signed)
- iPhone 5C can still be restored to versions that you have SHSH blobs for - iPhone 5C can still be restored to versions that you have SHSH blobs for
- **A7 devices are not supported on Windows.**
- **Restoring to other versions with SHSH blobs is not supported on Windows.**
<table> <table>
<thead> <thead>
@ -70,6 +73,7 @@
3. Open a Terminal window 3. Open a Terminal window
4. `cd` to where the extracted files are located, and run `./restore.sh` 4. `cd` to where the extracted files are located, and run `./restore.sh`
- You can also drag `restore.sh` to the Terminal window and press Enter/Return - You can also drag `restore.sh` to the Terminal window and press Enter/Return
- For Windows users, click `restore.cmd` to run the script
5. Select options to be used 5. Select options to be used
6. Follow instructions 6. Follow instructions
@ -80,6 +84,7 @@
- [**Debian**](https://www.debian.org/) 11 Bullseye, Testing and Unstable - [**Debian**](https://www.debian.org/) 11 Bullseye, Testing and Unstable
- [**openSUSE**](https://www.opensuse.org/) Tumbleweed and Leap 15.3 - [**openSUSE**](https://www.opensuse.org/) Tumbleweed and Leap 15.3
- **macOS** 10.13 and newer - **macOS** 10.13 and newer
- Windows 10 (8.1 and lower may also work but this is untested)
## Other notes: ## Other notes:
- **If something in the process does not work for you:** try unplugging/replugging the device, switching between different USB ports/cables, also try USB 2.0 ports - **If something in the process does not work for you:** try unplugging/replugging the device, switching between different USB ports/cables, also try USB 2.0 ports

View File

@ -16,7 +16,7 @@ SetToolPaths() {
ipwndfu="sudo $python ipwndfu" ipwndfu="sudo $python ipwndfu"
rmsigchks="sudo $python rmsigchks.py" rmsigchks="sudo $python rmsigchks.py"
SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 80" SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 80"
elif [[ $OSTYPE == "darwin"* ]]; then elif [[ $OSTYPE == "darwin"* ]]; then
platform="macos" platform="macos"
platformver="${1:-$(sw_vers -productVersion)}" platformver="${1:-$(sw_vers -productVersion)}"
@ -31,7 +31,7 @@ SetToolPaths() {
Log "Detected libimobiledevice and libirecovery installed from MacPorts" Log "Detected libimobiledevice and libirecovery installed from MacPorts"
MPath="/opt/local/bin" MPath="/opt/local/bin"
fi fi
bspatch="/usr/bin/bspatch" bspatch="/usr/bin/bspatch"
futurerestore1="./resources/tools/futurerestore1_macos" futurerestore1="./resources/tools/futurerestore1_macos"
futurerestore2="./resources/tools/futurerestore2_macos" futurerestore2="./resources/tools/futurerestore2_macos"
@ -41,6 +41,13 @@ SetToolPaths() {
ipwndfu="$python ipwndfu" ipwndfu="$python ipwndfu"
rmsigchks="$python rmsigchks.py" rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 80" SimpleHTTPServer="$python -m SimpleHTTPServer 80"
elif [[ $OSTYPE == "msys" ]]; then
platform="win"
MPath+="$platform"
bspatch="./resources/tools/bspatch_win"
idevicerestore="./resources/tools/idevicerestore_win"
python=/
fi fi
git="$(which git)" git="$(which git)"
ideviceenterrecovery="$MPath/ideviceenterrecovery" ideviceenterrecovery="$MPath/ideviceenterrecovery"
@ -55,7 +62,7 @@ SetToolPaths() {
SCP="$(which scp) $SSH" SCP="$(which scp) $SSH"
SSH="$(which ssh) $SSH" SSH="$(which ssh) $SSH"
tsschecker="./resources/tools/tsschecker_$platform" tsschecker="./resources/tools/tsschecker_$platform"
Log "Running on platform: $platform ($platformver)" Log "Running on platform: $platform ($platformver)"
} }
@ -96,12 +103,12 @@ SavePkg() {
InstallDepends() { InstallDepends() {
local libimobiledevice local libimobiledevice
mkdir resources/lib tmp 2>/dev/null mkdir resources/lib tmp 2>/dev/null
cd resources cd resources
rm -rf firmware ipwndfu lib/* rm -rf firmware ipwndfu lib/*
cd ../tmp cd ../tmp
Log "Installing dependencies..." Log "Installing dependencies..."
if [[ $platform == "linux" ]]; then if [[ $platform == "linux" ]]; then
Echo "* iOS-OTA-Downgrader will be installing dependencies from your distribution's package manager" Echo "* iOS-OTA-Downgrader will be installing dependencies from your distribution's package manager"
@ -113,7 +120,7 @@ InstallDepends() {
sudo pacman -Syu --noconfirm --needed base-devel bsdiff curl libcurl-compat libpng12 libimobiledevice libzip openssh openssl-1.0 python2 unzip usbutils zenity sudo pacman -Syu --noconfirm --needed base-devel bsdiff curl libcurl-compat libpng12 libimobiledevice libzip openssh openssl-1.0 python2 unzip usbutils zenity
ln -sf /usr/lib/libcurl.so.3 ../resources/lib/libcurl.so.3 ln -sf /usr/lib/libcurl.so.3 ../resources/lib/libcurl.so.3
ln -sf /usr/lib/libzip.so.5 ../resources/lib/libzip.so.4 ln -sf /usr/lib/libzip.so.5 ../resources/lib/libzip.so.4
elif [[ ! -z $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] || elif [[ ! -z $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] ||
[[ $VERSION == "11 (bullseye)" || $PRETTY_NAME == "Debian"*"sid" ]]; then [[ $VERSION == "11 (bullseye)" || $PRETTY_NAME == "Debian"*"sid" ]]; then
[[ ! -z $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe [[ ! -z $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe
@ -126,14 +133,14 @@ InstallDepends() {
else else
sudo apt install -y libzip4 sudo apt install -y libzip4
fi fi
elif [[ $ID == "fedora" ]] && (( $VERSION_ID >= 33 )); then elif [[ $ID == "fedora" ]] && (( $VERSION_ID >= 33 )); then
sudo dnf install -y bsdiff git libimobiledevice libpng12 libzip perl-Digest-SHA python2 zenity sudo dnf install -y bsdiff git libimobiledevice libpng12 libzip perl-Digest-SHA python2 zenity
SavePkg SavePkg
cp libcrypto.so.1.0.0 libssl.so.1.0.0 ../resources/lib cp libcrypto.so.1.0.0 libssl.so.1.0.0 ../resources/lib
ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4 ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4
ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0 ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0
elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == "openSUSE Leap 15.3" ]]; then elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == "openSUSE Leap 15.3" ]]; then
if [[ $ID == "opensuse-tumbleweed" ]]; then if [[ $ID == "opensuse-tumbleweed" ]]; then
libimobiledevice="libimobiledevice-1_0-6" libimobiledevice="libimobiledevice-1_0-6"
@ -143,7 +150,7 @@ InstallDepends() {
fi fi
sudo zypper -n in bsdiff curl git $libimobiledevice libpng12-0 libopenssl1_0_0 libzip5 python-base zenity sudo zypper -n in bsdiff curl git $libimobiledevice libpng12-0 libopenssl1_0_0 libzip5 python-base zenity
ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4 ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4
elif [[ $platform == "macos" ]]; then elif [[ $platform == "macos" ]]; then
xcode-select --install 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") libimobiledevice=("https://github.com/libimobiledevice-win32/imobiledevice-net/releases/download/v1.3.14/libimobiledevice.1.2.1-r1116-osx-x64.zip" "328e809dea350ae68fb644225bbf8469c0f0634b")
@ -151,15 +158,21 @@ InstallDepends() {
Echo "* In case that problems occur, try installing them from Homebrew" 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 "* The script will detect this automatically and will use the Homebrew versions of the tools"
Echo "* Install using this command: 'brew install libimobiledevice libirecovery'" Echo "* Install using this command: 'brew install libimobiledevice libirecovery'"
elif [[ $platform == "win" ]]; then
pacman -Sy --noconfirm --needed git openssh unzip
SaveFile https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/tools_win.zip tools_win.zip a7de26af8f2e94ebd44f5080d973c03035cf91f8
unzip tools_win.zip -d ../resources/tools
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_win.zip" "669dec0d0c257066f22a0664dcef2f58cebbcadf")
else else
Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros" Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros"
fi fi
if [[ $platform == "linux" ]]; then if [[ $platform == "linux" ]]; then
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_linux.zip" "4344b3ca95d7433d5a49dcacc840d47770ba34c4") libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_linux.zip" "4344b3ca95d7433d5a49dcacc840d47770ba34c4")
fi fi
if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then
Log "Downloading libimobiledevice..." Log "Downloading libimobiledevice..."
SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]} SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]}
@ -170,8 +183,13 @@ InstallDepends() {
elif [[ $MPath != "./resources"* ]]; then elif [[ $MPath != "./resources"* ]]; then
mkdir ../resources/libimobiledevice_$platform mkdir ../resources/libimobiledevice_$platform
fi fi
cd .. cd ..
Log "Install script done! Please run the script again to proceed" Log "Install script done! Please run the script again to proceed"
if [[ $platform == "win" ]]; then
Input "Press Enter/Return to exit."
read -s
fi
exit 0 exit 0
} }

View File

@ -10,8 +10,11 @@ FindDevice() {
Log "Finding device in $1 mode..." Log "Finding device in $1 mode..."
while (( $i < $Timeout )); do while (( $i < $Timeout )); do
[[ $platform == "linux" ]] && DeviceIn=$(lsusb | grep -c "05ac:$USB") if [[ $platform == "linux" ]]; then
[[ $platform == "macos" && $($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-) == "$1" ]] && DeviceIn=1 DeviceIn=$(lsusb | grep -c "05ac:$USB")
else
[[ $($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-) == "$1" ]] && DeviceIn=1
fi
if [[ $DeviceIn == 1 ]]; then if [[ $DeviceIn == 1 ]]; then
Log "Found device in $1 mode." Log "Found device in $1 mode."
DeviceState="$1" DeviceState="$1"
@ -42,7 +45,7 @@ GetDeviceValues() {
if [[ $DeviceState == "DFU" || $DeviceState == "Recovery" ]]; then if [[ $DeviceState == "DFU" || $DeviceState == "Recovery" ]]; then
local ProdCut=7 local ProdCut=7
ProductType=$($irecovery -qv 2>&1 | grep "iP" | cut -c 14-) ProductType=$($irecovery -qv 2>&1 | grep "Connected to iP" | cut -c 14-)
[[ $(echo $ProductType | cut -c 3) == 'h' ]] && ProdCut=9 [[ $(echo $ProductType | cut -c 3) == 'h' ]] && ProdCut=9
ProductType=$(echo $ProductType | cut -c -$ProdCut) ProductType=$(echo $ProductType | cut -c -$ProdCut)
if [[ ! $ProductType ]]; then if [[ ! $ProductType ]]; then
@ -286,7 +289,7 @@ kDFU() {
Echo "* The default password is \"alpine\"" Echo "* The default password is \"alpine\""
$SCP -P 2222 resources/tools/$kloader tmp/pwnediBSS root@127.0.0.1:/tmp $SCP -P 2222 resources/tools/$kloader tmp/pwnediBSS root@127.0.0.1:/tmp
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
$SSH -p 2222 root@127.0.0.1 "/tmp/$kloader /tmp/pwnediBSS" & $SSH -p 2222 root@127.0.0.1 "chmod +x /tmp/$kloader; /tmp/$kloader /tmp/pwnediBSS" &
else else
Log "Cannot connect to device via USB SSH." Log "Cannot connect to device via USB SSH."
Echo "* Please try the steps above to make sure that SSH is successful" Echo "* Please try the steps above to make sure that SSH is successful"

View File

@ -121,7 +121,10 @@ Downgrade() {
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore" IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom" IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
if [[ $Jailbreak != 1 && $DeviceProc != 7 ]]; then if [[ $Jailbreak != 1 && $platform == "win" ]]; then
IPSWCustom="${IPSWCustom}W"
IPSWCustomW=1
elif [[ $Jailbreak != 1 && $DeviceProc != 7 ]]; then
Selection=("futurerestore" "idevicerestore") Selection=("futurerestore" "idevicerestore")
Echo "* Select 1 (futurerestore) if unsure" Echo "* Select 1 (futurerestore) if unsure"
Echo "* Select 2 (idevicerestore) if you experience issues with futurerestore" Echo "* Select 2 (idevicerestore) if you experience issues with futurerestore"

View File

@ -70,12 +70,14 @@ IPSW32() {
ExtraArgs+="-bbupdate" ExtraArgs+="-bbupdate"
if [[ ! -e $IPSWCustom.ipsw ]]; then if [[ ! -e $IPSWCustom.ipsw ]]; then
Echo "* By default, memory option is set to Y." if [[ $platform != "win" ]]; then
Echo "* Make sure that you have at least 8GB of RAM for it to work!" Echo "* By default, memory option is set to Y."
Echo "* If it freezes or fails, this may mean that you do not have enough RAM." Echo "* Make sure that you have at least 8GB of RAM for it to work!"
Echo "* You may select N if this happens, but make sure that you have enough storage space." Echo "* If it freezes or fails, this may mean that you do not have enough RAM."
read -p "$(Input 'Memory option? (press Enter/Return if unsure) (Y/n):')" JBMemory Echo "* You may select N if this happens, but make sure that you have enough storage space."
[[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory" read -p "$(Input 'Memory option? (press Enter/Return if unsure) (Y/n):')" JBMemory
[[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory"
fi
Log "Preparing custom IPSW..." Log "Preparing custom IPSW..."
cd resources cd resources
rm -rf FirmwareBundles rm -rf FirmwareBundles

2
restore.cmd Normal file
View File

@ -0,0 +1,2 @@
@echo off
C:\msys64\msys2.exe "./restore.sh"

View File

@ -40,6 +40,10 @@ Error() {
echo -e "\n${Color_R}[Error] $1 ${Color_N}" echo -e "\n${Color_R}[Error] $1 ${Color_N}"
[[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}" [[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}"
echo echo
if [[ $platform == "win" ]]; then
Input "Press Enter/Return to exit."
read -s
fi
exit 1 exit 1
} }
@ -103,6 +107,9 @@ Main() {
mkdir tmp mkdir tmp
if [[ $DeviceProc == 7 ]]; then if [[ $DeviceProc == 7 ]]; then
if [[ $platform == "win" ]]; then
Error "A7 devices are not supported in Windows."
fi
if [[ $DeviceState == "Normal" ]]; then if [[ $DeviceState == "Normal" ]]; then
Echo "* The device needs to be in recovery/DFU mode before proceeding." Echo "* The device needs to be in recovery/DFU mode before proceeding."
read -p "$(Input 'Send device to recovery mode? (y/N):')" Selection read -p "$(Input 'Send device to recovery mode? (y/N):')" Selection
@ -183,6 +190,11 @@ Main() {
Log "Option: $Mode" Log "Option: $Mode"
$Mode $Mode
if [[ $platform == "win" ]]; then
Input "Press Enter/Return to exit."
read -s
fi
exit 0 exit 0
} }
@ -206,7 +218,7 @@ SelectVersion() {
Selection+=("iOS 6.1.3") Selection+=("iOS 6.1.3")
fi fi
[[ $Mode == "Downgrade" ]] && Selection+=("Other (use SHSH blobs)") [[ $Mode == "Downgrade" && $platform != "win" ]] && Selection+=("Other (use SHSH blobs)")
Selection+=("(Any other key to exit)") Selection+=("(Any other key to exit)")
Input "Select iOS version:" Input "Select iOS version:"