Legacy-iOS-Kit/resources/depends.sh

217 lines
9.3 KiB
Bash
Raw Normal View History

#!/bin/bash
SetToolPaths() {
local Detect="Detected libimobiledevice and libirecovery installed from "
MPath="./resources/libimobiledevice_"
cherrymac="./resources/ch3rryflower/Tools/macos/UNTETHERED"
if [[ $OSTYPE == "linux"* ]]; then
. /etc/os-release 2>/dev/null
platform="linux"
platformver="$PRETTY_NAME"
MPath+="$platform"
bspatch="$(which bspatch)"
cherry="./resources/ch3rryflower/Tools/ubuntu/UNTETHERED"
futurerestore="./resources/tools/futurerestore_linux"
python="$(which python2)"
xmlstarlet="$(which xmlstarlet)"
2021-11-01 06:34:41 +01:00
zenity="$(which zenity)"
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
Detect+="Homebrew (Intel Mac)"
MPath="/usr/local/bin"
elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then
Detect+="Homebrew (Apple Silicon)"
MPath="/opt/homebrew/bin"
elif [[ -e /opt/local/bin/idevicedate && -e /opt/local/bin/irecovery ]]; then
Detect+="MacPorts"
MPath="/opt/local/bin"
else
Detect=
fi
2021-11-17 07:37:02 +01:00
[[ -n $Detect ]] && Log "$Detect"
bspatch="/usr/bin/bspatch"
cherry="$cherrymac"
futurerestore="./resources/tools/futurerestore_macos_$(uname -m)"
[[ ! -e $futurerestore ]] && futurerestore="./resources/tools/futurerestore_macos_arm64"
ipwnder32="./resources/tools/ipwnder32_macos"
ipwnder_lite="./resources/tools/ipwnder_macos"
python="/usr/bin/python"
xmlstarlet=/
2021-11-01 06:34:41 +01:00
zenity="./resources/tools/zenity_macos"
elif [[ $OSTYPE == "msys" ]]; then
platform="win"
platformver="$(cmd /c ver)"
MPath+="$platform"
bspatch="./resources/tools/bspatch_win"
futurerestore="./resources/tools/futurerestore_win"
python=/
fi
if [[ $platform != "win" ]]; then
expect="$(which expect)"
fi
2022-06-29 04:48:17 +02:00
cherrybin="../$cherry/cherry"
ideviceenterrecovery="$MPath/ideviceenterrecovery"
ideviceinfo="$MPath/ideviceinfo"
idevicerestore="./resources/tools/idevicerestore_$platform"
iproxy="$MPath/iproxy"
2022-05-28 12:21:26 +02:00
ipsw="../resources/tools/ipsw_$platform"
ipwndfu="$python ipwndfu"
irecoverychk="$MPath/irecovery"
irecovery="$irecoverychk"
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"
pwnedDFU="$cherry/pwnedDFU"
rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
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"
2022-06-29 07:00:32 +02:00
xpwntool="../resources/tools/xpwntool_$platform"
if [[ $platform == "linux" ]]; then
2022-07-02 05:48:25 +02:00
irecovery="env LD_LIBRARY_PATH=./resources/lib $irecovery"
irecovery2="env LD_LIBRARY_PATH=./resources/lib $irecovery2"
2022-06-29 07:00:32 +02:00
# openssl
opensslver=$(openssl version | awk '{print $2}' | cut -c -3)
if [[ $opensslver == "3"* ]]; then
cherrybin="env LD_LIBRARY_PATH=../resources/lib $cherrybin"
2022-07-02 05:48:25 +02:00
idevicerestore="${idevicerestore}2"
2022-06-29 07:00:32 +02:00
fi
2022-06-29 04:48:17 +02:00
elif [[ $platform == "macos" ]]; then
2022-07-01 13:22:10 +02:00
# for macOS 12 and newer
if (( ${platformver:0:2} > 11 )); then
python="/usr/bin/python3"
ipwndfu="$(which python2) ipwndfu"
rmsigchks="$(which python2) rmsigchks.py"
SimpleHTTPServer="$python -m http.server 8888"
fi
else
ping="ping -n 1"
zenity="./resources/tools/zenity_$platform"
fi
Log "Running on platform: $platform ($platformver)"
}
SaveExternal() {
if [[ -d ./resources/$2 ]]; then
return
fi
cd tmp
SaveFile $1 $2.zip $3
cd ../resources
unzip -q ../tmp/$2.zip -d .
mv $2* $2
cd ..
}
SaveFile() {
Log "Downloading $2..."
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"
fi
}
InstallDepends() {
local libimobiledevice
mkdir resources/lib tmp 2>/dev/null
cd resources
cp lib/*.so.1.1 ../tmp
rm -rf ipwndfu lib/*
cp ../tmp/*.so.1.1 lib/
cd ../tmp
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"
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
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
if [[ $ID == "arch" || $ID_LIKE == "arch" || $ID == "artix" ]]; then
2022-07-02 05:48:25 +02:00
sudo pacman -Sy --noconfirm --needed base-devel bsdiff curl expect libimobiledevice openssh python2 udev unzip usbmuxd usbutils vim xmlstarlet zenity
2021-11-17 07:37:02 +01:00
elif [[ -n $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] ||
(( DebianVer >= 11 )) || [[ $DebianVer == "sid" ]]; then
2021-11-17 07:37:02 +01:00
[[ -n $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe
sudo apt update
2022-07-02 05:48:25 +02:00
sudo apt install -y bsdiff curl expect libimobiledevice6 openssh-client python2 udev unzip usbmuxd usbutils xmlstarlet xxd zenity
sudo systemctl enable --now udev systemd-udevd usbmuxd 2>/dev/null
2022-06-29 04:48:17 +02:00
elif [[ $ID == "fedora" ]] && (( VERSION_ID >= 35 )); then
ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0
2022-07-02 05:48:25 +02:00
sudo dnf install -y bsdiff ca-certificates libimobiledevice openssl perl-Digest-SHA python2 systemd udev usbmuxd vim-common xmlstarlet zenity
sudo ln -sf /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-certificates.crt
2022-06-29 04:48:17 +02:00
elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == *"Leap 15.4" ]]; then
[[ $ID == "opensuse-leap" ]] && ln -sf /lib64/libreadline.so.7 ../resources/lib/libreadline.so.8
2022-07-02 05:48:25 +02:00
sudo zypper -n in bsdiff curl expect libimobiledevice-1_0-6 openssl python-base usbmuxd vim xmlstarlet zenity
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")
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'"
elif [[ $platform == "win" ]]; then
pacman -Sy --noconfirm --needed ca-certificates curl openssh unzip zip
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")
else
Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros"
fi
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")
2022-07-02 05:48:25 +02:00
# from linux_fix script by Cryptiiiic
sudo systemctl enable --now systemd-udevd usbmuxd 2>/dev/null
echo "QUNUSU9OPT0iYWRkIiwgU1VCU1lTVEVNPT0idXNiIiwgQVRUUntpZFZlbmRvcn09PSIwNWFjIiwgQVRUUntpZFByb2R1Y3R9PT0iMTIyWzI3XXwxMjhbMC0zXSIsIE9XTkVSPSJyb290IiwgR1JPVVA9InVzYm11eGQiLCBNT0RFPSIwNjYwIiwgVEFHKz0idWFjY2VzcyIKCkFDVElPTj09ImFkZCIsIFNVQlNZU1RFTT09InVzYiIsIEFUVFJ7aWRWZW5kb3J9PT0iMDVhYyIsIEFUVFJ7aWRQcm9kdWN0fT09IjEzMzgiLCBPV05FUj0icm9vdCIsIEdST1VQPSJ1c2JtdXhkIiwgTU9ERT0iMDY2MCIsIFRBRys9InVhY2Nlc3MiCgoK" | base64 -d | sudo tee /usr/lib/udev/rules.d/39-libirecovery.rules >/dev/null 2>/dev/null
sudo chown root:root /usr/lib/udev/rules.d/39-libirecovery.rules
sudo chmod 0644 /usr/lib/udev/rules.d/39-libirecovery.rules
sudo udevadm control --reload-rules
fi
if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then
SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]}
mkdir ../resources/libimobiledevice_$platform
Log "Extracting libimobiledevice..."
unzip -q libimobiledevice.zip -d ../resources/libimobiledevice_$platform
chmod +x ../resources/libimobiledevice_$platform/*
elif [[ $MPath != "./resources"* ]]; then
mkdir ../resources/libimobiledevice_$platform
fi
cd ..
Log "Install script done! Please run the script again to proceed"
2022-07-02 05:48:25 +02:00
Log "If your iOS device is plugged in, unplug and replug your device"
}