diff --git a/README.md b/README.md index 48fac15..005ab4f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # iOS-OTA-Downgrader ### Downgrade/restore and jailbreak iOS devices to signed OTA firmwares -- **Linux and macOS** are supported - - Windows users can create a Linux live USB (see Requirements) +- **Linux, macOS, and Windows** are supported + - 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 - 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 @@ -13,6 +14,8 @@ - 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 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.** @@ -70,6 +73,7 @@ 3. Open a Terminal window 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 + - For Windows users, click `restore.cmd` to run the script 5. Select options to be used 6. Follow instructions @@ -80,6 +84,7 @@ - [**Debian**](https://www.debian.org/) 11 Bullseye, Testing and Unstable - [**openSUSE**](https://www.opensuse.org/) Tumbleweed and Leap 15.3 - **macOS** 10.13 and newer +- Windows 10 (8.1 and lower may also work but this is untested) ## 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 diff --git a/resources/depends.sh b/resources/depends.sh index bff90d6..7585f7a 100755 --- a/resources/depends.sh +++ b/resources/depends.sh @@ -16,7 +16,7 @@ SetToolPaths() { ipwndfu="sudo $python ipwndfu" rmsigchks="sudo $python rmsigchks.py" SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 80" - + elif [[ $OSTYPE == "darwin"* ]]; then platform="macos" platformver="${1:-$(sw_vers -productVersion)}" @@ -31,7 +31,7 @@ SetToolPaths() { Log "Detected libimobiledevice and libirecovery installed from MacPorts" MPath="/opt/local/bin" fi - + bspatch="/usr/bin/bspatch" futurerestore1="./resources/tools/futurerestore1_macos" futurerestore2="./resources/tools/futurerestore2_macos" @@ -41,6 +41,13 @@ SetToolPaths() { ipwndfu="$python ipwndfu" rmsigchks="$python rmsigchks.py" 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 git="$(which git)" ideviceenterrecovery="$MPath/ideviceenterrecovery" @@ -55,7 +62,7 @@ SetToolPaths() { SCP="$(which scp) $SSH" SSH="$(which ssh) $SSH" tsschecker="./resources/tools/tsschecker_$platform" - + Log "Running on platform: $platform ($platformver)" } @@ -96,12 +103,12 @@ SavePkg() { InstallDepends() { local libimobiledevice - + mkdir resources/lib tmp 2>/dev/null cd resources rm -rf firmware ipwndfu lib/* cd ../tmp - + Log "Installing dependencies..." if [[ $platform == "linux" ]]; then 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 ln -sf /usr/lib/libcurl.so.3 ../resources/lib/libcurl.so.3 ln -sf /usr/lib/libzip.so.5 ../resources/lib/libzip.so.4 - + elif [[ ! -z $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] || [[ $VERSION == "11 (bullseye)" || $PRETTY_NAME == "Debian"*"sid" ]]; then [[ ! -z $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe @@ -126,14 +133,14 @@ InstallDepends() { else sudo apt install -y libzip4 fi - + elif [[ $ID == "fedora" ]] && (( $VERSION_ID >= 33 )); then sudo dnf install -y bsdiff git libimobiledevice libpng12 libzip perl-Digest-SHA python2 zenity SavePkg 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/libbz2.so.1.* ../resources/lib/libbz2.so.1.0 - + elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == "openSUSE Leap 15.3" ]]; then if [[ $ID == "opensuse-tumbleweed" ]]; then libimobiledevice="libimobiledevice-1_0-6" @@ -143,7 +150,7 @@ InstallDepends() { fi 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 - + 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") @@ -151,15 +158,21 @@ InstallDepends() { 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'" - + + 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 Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros" fi - + if [[ $platform == "linux" ]]; then libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_linux.zip" "4344b3ca95d7433d5a49dcacc840d47770ba34c4") fi - + if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then Log "Downloading libimobiledevice..." SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]} @@ -170,8 +183,13 @@ InstallDepends() { elif [[ $MPath != "./resources"* ]]; then mkdir ../resources/libimobiledevice_$platform fi - + cd .. 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 } diff --git a/resources/device.sh b/resources/device.sh index 8106365..dff798b 100755 --- a/resources/device.sh +++ b/resources/device.sh @@ -10,8 +10,11 @@ FindDevice() { Log "Finding device in $1 mode..." while (( $i < $Timeout )); do - [[ $platform == "linux" ]] && DeviceIn=$(lsusb | grep -c "05ac:$USB") - [[ $platform == "macos" && $($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-) == "$1" ]] && DeviceIn=1 + if [[ $platform == "linux" ]]; then + 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 Log "Found device in $1 mode." DeviceState="$1" @@ -42,7 +45,7 @@ GetDeviceValues() { if [[ $DeviceState == "DFU" || $DeviceState == "Recovery" ]]; then 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 ProductType=$(echo $ProductType | cut -c -$ProdCut) if [[ ! $ProductType ]]; then @@ -286,7 +289,7 @@ kDFU() { Echo "* The default password is \"alpine\"" $SCP -P 2222 resources/tools/$kloader tmp/pwnediBSS root@127.0.0.1:/tmp 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 Log "Cannot connect to device via USB SSH." Echo "* Please try the steps above to make sure that SSH is successful" diff --git a/resources/downgrade.sh b/resources/downgrade.sh index cec954a..7bba59a 100755 --- a/resources/downgrade.sh +++ b/resources/downgrade.sh @@ -121,7 +121,10 @@ Downgrade() { IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore" 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") Echo "* Select 1 (futurerestore) if unsure" Echo "* Select 2 (idevicerestore) if you experience issues with futurerestore" diff --git a/resources/ipsw.sh b/resources/ipsw.sh index 7dea4a8..0c35a16 100755 --- a/resources/ipsw.sh +++ b/resources/ipsw.sh @@ -70,12 +70,14 @@ IPSW32() { ExtraArgs+="-bbupdate" if [[ ! -e $IPSWCustom.ipsw ]]; then - Echo "* By default, memory option is set to Y." - Echo "* Make sure that you have at least 8GB of RAM for it to work!" - Echo "* If it freezes or fails, this may mean that you do not have enough RAM." - Echo "* You may select N if this happens, but make sure that you have enough storage space." - read -p "$(Input 'Memory option? (press Enter/Return if unsure) (Y/n):')" JBMemory - [[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory" + if [[ $platform != "win" ]]; then + Echo "* By default, memory option is set to Y." + Echo "* Make sure that you have at least 8GB of RAM for it to work!" + Echo "* If it freezes or fails, this may mean that you do not have enough RAM." + Echo "* You may select N if this happens, but make sure that you have enough storage space." + read -p "$(Input 'Memory option? (press Enter/Return if unsure) (Y/n):')" JBMemory + [[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory" + fi Log "Preparing custom IPSW..." cd resources rm -rf FirmwareBundles diff --git a/restore.cmd b/restore.cmd new file mode 100644 index 0000000..634d1da --- /dev/null +++ b/restore.cmd @@ -0,0 +1,2 @@ +@echo off +C:\msys64\msys2.exe "./restore.sh" diff --git a/restore.sh b/restore.sh index bf77220..745e666 100755 --- a/restore.sh +++ b/restore.sh @@ -40,6 +40,10 @@ Error() { echo -e "\n${Color_R}[Error] $1 ${Color_N}" [[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}" echo + if [[ $platform == "win" ]]; then + Input "Press Enter/Return to exit." + read -s + fi exit 1 } @@ -103,6 +107,9 @@ Main() { mkdir tmp if [[ $DeviceProc == 7 ]]; then + if [[ $platform == "win" ]]; then + Error "A7 devices are not supported in Windows." + fi if [[ $DeviceState == "Normal" ]]; then Echo "* The device needs to be in recovery/DFU mode before proceeding." read -p "$(Input 'Send device to recovery mode? (y/N):')" Selection @@ -183,6 +190,11 @@ Main() { Log "Option: $Mode" $Mode + + if [[ $platform == "win" ]]; then + Input "Press Enter/Return to exit." + read -s + fi exit 0 } @@ -206,7 +218,7 @@ SelectVersion() { Selection+=("iOS 6.1.3") fi - [[ $Mode == "Downgrade" ]] && Selection+=("Other (use SHSH blobs)") + [[ $Mode == "Downgrade" && $platform != "win" ]] && Selection+=("Other (use SHSH blobs)") Selection+=("(Any other key to exit)") Input "Select iOS version:"