2021-05-29 13:26:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SetToolPaths() {
|
2021-11-06 15:10:04 +01:00
|
|
|
local Detect="Detected libimobiledevice and libirecovery installed from "
|
2021-11-07 14:29:31 +01:00
|
|
|
MPath="./resources/libimobiledevice_"
|
2022-05-28 12:56:10 +02:00
|
|
|
cherrymac="./resources/ch3rryflower/Tools/macos/UNTETHERED"
|
2021-11-06 15:10:04 +01:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $OSTYPE == "linux"* ]]; then
|
|
|
|
. /etc/os-release 2>/dev/null
|
|
|
|
platform="linux"
|
2021-06-07 07:49:58 +02:00
|
|
|
platformver="$PRETTY_NAME"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath+="$platform"
|
2021-06-20 11:45:53 +02:00
|
|
|
bspatch="$(which bspatch)"
|
2022-05-28 12:56:10 +02:00
|
|
|
cherry="./resources/ch3rryflower/Tools/ubuntu/UNTETHERED"
|
2021-11-06 15:10:04 +01:00
|
|
|
futurerestore="./resources/tools/futurerestore_linux"
|
2021-05-29 13:26:08 +02:00
|
|
|
python="$(which python2)"
|
2022-05-28 12:56:10 +02:00
|
|
|
xmlstarlet="$(which xmlstarlet)"
|
2021-11-01 06:34:41 +01:00
|
|
|
zenity="$(which zenity)"
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $OSTYPE == "darwin"* ]]; then
|
|
|
|
platform="macos"
|
2021-06-07 07:49:58 +02:00
|
|
|
platformver="${1:-$(sw_vers -productVersion)}"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath+="$platform"
|
|
|
|
if [[ -e /usr/local/bin/idevicedate && -e /usr/local/bin/irecovery ]]; then
|
2021-11-06 15:10:04 +01:00
|
|
|
Detect+="Homebrew (Intel Mac)"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath="/usr/local/bin"
|
|
|
|
elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then
|
2021-11-06 15:10:04 +01:00
|
|
|
Detect+="Homebrew (Apple Silicon)"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath="/opt/homebrew/bin"
|
2021-09-09 04:20:19 +02:00
|
|
|
elif [[ -e /opt/local/bin/idevicedate && -e /opt/local/bin/irecovery ]]; then
|
2021-11-06 15:10:04 +01:00
|
|
|
Detect+="MacPorts"
|
2021-09-09 04:20:19 +02:00
|
|
|
MPath="/opt/local/bin"
|
2021-11-06 15:10:04 +01:00
|
|
|
else
|
|
|
|
Detect=
|
2021-07-12 16:36:51 +02:00
|
|
|
fi
|
2021-11-17 07:37:02 +01:00
|
|
|
[[ -n $Detect ]] && Log "$Detect"
|
2021-06-20 11:45:53 +02:00
|
|
|
bspatch="/usr/bin/bspatch"
|
2022-05-28 12:56:10 +02:00
|
|
|
cherry="$cherrymac"
|
2021-10-21 13:42:50 +02:00
|
|
|
futurerestore="./resources/tools/futurerestore_macos_$(uname -m)"
|
|
|
|
[[ ! -e $futurerestore ]] && futurerestore="./resources/tools/futurerestore_macos_arm64"
|
2021-05-29 13:26:08 +02:00
|
|
|
ipwnder32="./resources/tools/ipwnder32_macos"
|
2022-02-14 09:08:57 +01:00
|
|
|
ipwnder_lite="./resources/tools/ipwnder_macos"
|
2021-05-29 13:26:08 +02:00
|
|
|
python="/usr/bin/python"
|
2022-05-28 12:56:10 +02:00
|
|
|
xmlstarlet=/
|
2021-11-01 06:34:41 +01:00
|
|
|
zenity="./resources/tools/zenity_macos"
|
2022-05-29 16:57:53 +02:00
|
|
|
|
|
|
|
elif [[ $OSTYPE == "msys" ]]; then
|
|
|
|
platform="win"
|
|
|
|
platformver="$(cmd /c ver)"
|
|
|
|
MPath+="$platform"
|
|
|
|
bspatch="./resources/tools/bspatch_win"
|
|
|
|
futurerestore="./resources/tools/futurerestore_win"
|
|
|
|
python=/
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-11-06 15:10:04 +01:00
|
|
|
|
2022-05-29 16:57:53 +02:00
|
|
|
if [[ $platform != "win" ]]; then
|
|
|
|
expect="$(which expect)"
|
|
|
|
git="$(which git)"
|
|
|
|
fi
|
2021-07-12 16:36:51 +02:00
|
|
|
ideviceenterrecovery="$MPath/ideviceenterrecovery"
|
|
|
|
ideviceinfo="$MPath/ideviceinfo"
|
2022-05-28 12:56:10 +02:00
|
|
|
idevicerestore="./resources/tools/idevicerestore_$platform"
|
2021-07-12 16:36:51 +02:00
|
|
|
iproxy="$MPath/iproxy"
|
2022-05-28 12:21:26 +02:00
|
|
|
ipsw="../resources/tools/ipsw_$platform"
|
2021-11-06 15:10:04 +01:00
|
|
|
ipwndfu="$python ipwndfu"
|
2021-07-12 16:36:51 +02:00
|
|
|
irecoverychk="$MPath/irecovery"
|
2021-05-29 13:26:08 +02:00
|
|
|
irecovery="$irecoverychk"
|
2022-05-28 12:56:10 +02:00
|
|
|
irecovery2="../tools/irecovery_$platform"
|
2021-06-01 09:21:37 +02:00
|
|
|
partialzip="./resources/tools/partialzip_$platform"
|
2022-05-28 12:21:26 +02:00
|
|
|
ping="ping -c1"
|
2022-05-28 12:56:10 +02:00
|
|
|
pwnedDFU="$cherry/pwnedDFU"
|
2021-11-06 15:10:04 +01:00
|
|
|
rmsigchks="$python rmsigchks.py"
|
|
|
|
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
|
2021-05-29 13:26:08 +02:00
|
|
|
SSH="-F ./resources/ssh_config"
|
|
|
|
SCP="$(which scp) $SSH"
|
|
|
|
SSH="$(which ssh) $SSH"
|
2021-05-30 05:03:39 +02:00
|
|
|
tsschecker="./resources/tools/tsschecker_$platform"
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-11-06 15:10:04 +01:00
|
|
|
if [[ $platform == "linux" ]]; then
|
|
|
|
# these need to run as root for device detection
|
2022-05-28 12:56:10 +02:00
|
|
|
expect="sudo $expect"
|
2021-11-06 15:10:04 +01:00
|
|
|
futurerestore="sudo $futurerestore"
|
2022-05-28 12:56:10 +02:00
|
|
|
idevicerestore="sudo LD_LIBRARY_PATH=./resources/lib $idevicerestore"
|
2021-11-06 15:10:04 +01:00
|
|
|
ipwndfu="sudo $ipwndfu"
|
|
|
|
irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
|
2022-05-28 12:56:10 +02:00
|
|
|
irecovery2="sudo LD_LIBRARY_PATH=./resources/lib $irecovery2"
|
|
|
|
pwnedDFU="sudo $pwnedDFU"
|
2021-11-06 15:10:04 +01:00
|
|
|
rmsigchks="sudo $rmsigchks"
|
2022-03-16 04:42:58 +01:00
|
|
|
elif [[ $platform == "macos" ]]; then
|
2022-04-20 04:39:57 +02:00
|
|
|
# for macOS 12.3 and newer
|
2022-03-16 04:42:58 +01:00
|
|
|
if (( ${platformver:0:2} > 11 )) && [[ -z $python ]]; then
|
|
|
|
python="/usr/bin/python3"
|
2022-04-20 04:39:57 +02:00
|
|
|
ipwndfu="$(which python2) ipwndfu"
|
2022-03-16 04:42:58 +01:00
|
|
|
rmsigchks="$(which python2) rmsigchks.py"
|
|
|
|
SimpleHTTPServer="$python -m http.server 8888"
|
|
|
|
fi
|
2022-05-29 16:57:53 +02:00
|
|
|
else
|
|
|
|
ping="ping -n 1"
|
|
|
|
zenity="./resources/tools/zenity_$platform"
|
2021-11-06 15:10:04 +01:00
|
|
|
fi
|
|
|
|
|
2021-06-07 07:49:58 +02:00
|
|
|
Log "Running on platform: $platform ($platformver)"
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SaveExternal() {
|
2021-09-06 10:50:29 +02:00
|
|
|
local ExternalURL="https://github.com/$1/$2.git"
|
|
|
|
local External=$2
|
2021-05-29 13:26:08 +02:00
|
|
|
cd resources
|
|
|
|
if [[ ! -d $External || ! -d $External/.git ]]; then
|
|
|
|
Log "Downloading $External..."
|
|
|
|
rm -rf $External
|
2021-11-20 14:56:52 +01:00
|
|
|
$git clone --depth 1 $ExternalURL $External
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-09-06 10:50:29 +02:00
|
|
|
if [[ ! $(ls $External/*.md) || ! -d $External/.git ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
rm -rf $External
|
2021-09-06 10:50:29 +02:00
|
|
|
Error "Downloading/updating $2 failed. Please run the script again"
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveFile() {
|
|
|
|
curl -L $1 -o $2
|
2021-09-29 11:26:04 +02:00
|
|
|
local SHA1=$(shasum $2 | awk '{print $1}')
|
|
|
|
if [[ $SHA1 != $3 ]]; then
|
|
|
|
Error "Verifying $2 failed. The downloaded file may be corrupted or incomplete. Please run the script again" \
|
|
|
|
"SHA1sum mismatch. Expected $3, got $SHA1"
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
InstallDepends() {
|
|
|
|
local libimobiledevice
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
mkdir resources/lib tmp 2>/dev/null
|
|
|
|
cd resources
|
2022-05-28 12:56:10 +02:00
|
|
|
cp lib/*.so.1.1 ../tmp
|
2021-10-07 15:50:26 +02:00
|
|
|
rm -rf ipwndfu lib/*
|
2022-05-28 12:56:10 +02:00
|
|
|
cp ../tmp/*.so.1.1 lib/
|
2021-05-29 13:26:08 +02:00
|
|
|
cd ../tmp
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
Log "Installing dependencies..."
|
2021-08-20 03:58:17 +02:00
|
|
|
if [[ $platform == "linux" ]]; then
|
|
|
|
Echo "* iOS-OTA-Downgrader will be installing dependencies from your distribution's package manager"
|
2022-03-05 12:57:23 +01:00
|
|
|
Echo "* Enter your user password when prompted"
|
2021-08-20 03:58:17 +02:00
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
|
|
|
fi
|
2022-05-12 09:57:33 +02:00
|
|
|
|
|
|
|
if [[ -e /etc/debian_version ]]; then
|
|
|
|
DebianVer=$(cat /etc/debian_version)
|
|
|
|
if [[ $DebianVer == *"sid" ]]; then
|
|
|
|
DebianVer="sid"
|
|
|
|
else
|
|
|
|
DebianVer="$(echo $DebianVer | cut -c -2)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-08-26 13:41:52 +02:00
|
|
|
if [[ $ID == "arch" || $ID_LIKE == "arch" || $ID == "artix" ]]; then
|
2022-05-28 12:56:10 +02:00
|
|
|
sudo pacman -Sy --noconfirm --needed base-devel bsdiff curl expect libimobiledevice openssh python2 unzip usbutils vim xmlstarlet zenity
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-11-17 07:37:02 +01:00
|
|
|
elif [[ -n $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] ||
|
2022-05-12 09:57:33 +02:00
|
|
|
(( DebianVer >= 11 )) || [[ $DebianVer == "sid" ]]; then
|
2021-11-17 07:37:02 +01:00
|
|
|
[[ -n $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe
|
2021-05-29 13:26:08 +02:00
|
|
|
sudo apt update
|
2022-05-28 12:56:10 +02:00
|
|
|
sudo apt install -y bsdiff curl expect git libimobiledevice6 openssh-client python2 unzip usbmuxd usbutils xmlstarlet xxd zenity
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-11-17 07:37:02 +01:00
|
|
|
elif [[ $ID == "fedora" ]] && (( VERSION_ID >= 33 )); then
|
2021-05-29 13:26:08 +02:00
|
|
|
ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0
|
2022-05-28 12:56:10 +02:00
|
|
|
sudo dnf install -y bsdiff expect git libimobiledevice perl-Digest-SHA python2 vim-common xmlstarlet zenity
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-06-07 07:49:58 +02:00
|
|
|
elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == "openSUSE Leap 15.3" ]]; then
|
|
|
|
if [[ $ID == "opensuse-tumbleweed" ]]; then
|
|
|
|
libimobiledevice="libimobiledevice-1_0-6"
|
|
|
|
else
|
|
|
|
libimobiledevice="libimobiledevice6"
|
|
|
|
ln -sf /lib64/libreadline.so.7 ../resources/lib/libreadline.so.8
|
|
|
|
fi
|
2022-05-28 12:56:10 +02:00
|
|
|
sudo zypper -n in bsdiff curl expect git $libimobiledevice python-base vim xmlstarlet zenity
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $platform == "macos" ]]; then
|
|
|
|
xcode-select --install
|
2022-05-28 12:21:26 +02:00
|
|
|
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_macos.zip" "66a49e4f69757a3d9dc51109a8e4651020bfacb8")
|
2021-07-12 16:36:51 +02:00
|
|
|
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'"
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2022-05-29 16:57:53 +02:00
|
|
|
elif [[ $platform == "win" ]]; then
|
|
|
|
pacman -Sy --noconfirm --needed ca-certificates curl openssh unzip zip
|
|
|
|
Log "Downloading Windows tools..."
|
|
|
|
SaveFile https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/tools_win.zip tools_win.zip a34cbce38d89f96b97e62199aece78a58dd00e15
|
|
|
|
Log "Extracting Windows tools..."
|
|
|
|
unzip -oq tools_win.zip -d ../resources
|
|
|
|
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_win.zip" "75ae3af3347b89107f0f6b7e41fde42e6ccdd404")
|
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
else
|
|
|
|
Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros"
|
|
|
|
fi
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $platform == "linux" ]]; then
|
2022-04-29 10:16:31 +02:00
|
|
|
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_linux.zip" "fc5e714adf6fa72328d3e1ddea4e633f370559a4")
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-07-31 10:58:19 +02:00
|
|
|
if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then
|
2021-07-12 16:36:51 +02:00
|
|
|
Log "Downloading libimobiledevice..."
|
2021-05-29 13:26:08 +02:00
|
|
|
SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]}
|
2021-08-31 19:12:39 +02:00
|
|
|
mkdir ../resources/libimobiledevice_$platform
|
2021-07-12 16:36:51 +02:00
|
|
|
Log "Extracting libimobiledevice..."
|
|
|
|
unzip -q libimobiledevice.zip -d ../resources/libimobiledevice_$platform
|
2021-05-29 13:26:08 +02:00
|
|
|
chmod +x ../resources/libimobiledevice_$platform/*
|
2021-08-31 19:12:39 +02:00
|
|
|
elif [[ $MPath != "./resources"* ]]; then
|
|
|
|
mkdir ../resources/libimobiledevice_$platform
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
2021-09-29 07:33:34 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
cd ..
|
|
|
|
Log "Install script done! Please run the script again to proceed"
|
|
|
|
}
|