Changes for dependencies (especially macOS)

- python3 no longer required
- Homebrew no longer required
- macOS libimobiledevice is from imobiledevice-net
This commit is contained in:
LukeeGD 2020-08-14 11:57:20 +08:00
parent 028d6fb283
commit d55072aaa8
3 changed files with 64 additions and 50 deletions

BIN
resources/tools/bspatch_macos Executable file

Binary file not shown.

BIN
resources/tools/irecovery_macos Executable file

Binary file not shown.

View File

@ -21,22 +21,39 @@ function Main {
echo "******* iOS-OTA-Downgrader *******" echo "******* iOS-OTA-Downgrader *******"
echo " Downgrader script by LukeZGD " echo " Downgrader script by LukeZGD "
echo echo
[[ $OSTYPE == "linux-gnu" ]] && platform='linux'
[[ $OSTYPE == "darwin"* ]] && platform='macos' if [[ $OSTYPE == "linux-gnu" ]]; then
platform='linux'
bspatch="bspatch"
ideviceenterrecovery="ideviceenterrecovery"
ideviceinfo="ideviceinfo"
iproxy="iproxy"
irecovery="sudo LD_LIBRARY_PATH=/usr/local/lib irecovery"
lsusb="lsusb"
python="python2"
elif [[ $OSTYPE == "darwin"* ]]; then
platform='macos'
bspatch="resources/tools/bspatch_macos"
ideviceenterrecovery="resources/libimobiledevice/ideviceenterrecovery"
ideviceinfo="resources/libimobiledevice/ideviceinfo"
iproxy="resources/libimobiledevice/iproxy"
irecovery="resources/tools/irecovery_macos"
lsusb="system_profiler SPUSBDataType"
python="python"
fi
futurerestore1="sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore1_$platform"
futurerestore2="sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore2_$platform"
pzb="resources/tools/pzb_$platform"
tsschecker="env LD_LIBRARY_PATH=/usr/local/lib resources/tools/tsschecker_$platform"
[[ ! $platform ]] && Error "OSTYPE unknown/not supported." "Supports Linux and macOS only" [[ ! $platform ]] && Error "OSTYPE unknown/not supported." "Supports Linux and macOS only"
[[ ! $(ping -c1 google.com 2>/dev/null) ]] && Error "Please check your Internet connection before proceeding." [[ ! $(ping -c1 google.com 2>/dev/null) ]] && Error "Please check your Internet connection before proceeding."
[[ $(uname -m) != 'x86_64' ]] && Error "Only x86_64 distributions are supported. Use a 64-bit distro and try again" [[ $(uname -m) != 'x86_64' ]] && Error "Only x86_64 distributions are supported. Use a 64-bit distro and try again"
futurerestore1="sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore1_$platform" DFUDevice=$($lsusb | grep -c '1227')
futurerestore2="sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore2_$platform" RecoveryDevice=$($lsusb | grep -c '1281')
irecovery="sudo LD_LIBRARY_PATH=/usr/local/lib irecovery" if [[ $1 == Install ]] || [ ! $(which $bspatch) ] || [ ! $(which $ideviceinfo) ] ||
pzb="resources/tools/pzb_$platform" [ ! $(which $lsusb) ] || [ ! $(which ssh) ] || [ ! $(which $python) ]; then
tsschecker="env LD_LIBRARY_PATH=/usr/local/lib resources/tools/tsschecker_$platform"
DFUDevice=$(lsusb | grep -c '1227')
RecoveryDevice=$(lsusb | grep -c '1281')
if [[ $1 == Install ]] || [ ! $(which bspatch) ] || [ ! $(which ideviceinfo) ] ||
[ ! $(which lsusb) ] || [ ! $(which ssh) ] || [ ! $(which python3) ]; then
InstallDependencies InstallDependencies
elif [ $DFUDevice == 1 ] || [ $RecoveryDevice == 1 ]; then elif [ $DFUDevice == 1 ] || [ $RecoveryDevice == 1 ]; then
ProductType=$(sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/igetnonce_$platform 2>/dev/null) ProductType=$(sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/igetnonce_$platform 2>/dev/null)
@ -44,14 +61,14 @@ function Main {
UniqueChipID=$($irecovery -q | grep 'ECID' | cut -c 7-) UniqueChipID=$($irecovery -q | grep 'ECID' | cut -c 7-)
ProductVer='Unknown' ProductVer='Unknown'
else else
ideviceinfo=$(ideviceinfo -s) ideviceinfo2=$($ideviceinfo -s)
HWModel=$(echo "$ideviceinfo" | grep 'HardwareModel' | cut -c 16- | tr '[:upper:]' '[:lower:]' | sed 's/.\{2\}$//') HWModel=$(echo "$ideviceinfo2" | grep 'HardwareModel' | cut -c 16- | tr '[:upper:]' '[:lower:]' | sed 's/.\{2\}$//')
ProductType=$(echo "$ideviceinfo" | grep 'ProductType' | cut -c 14-) ProductType=$(echo "$ideviceinfo2" | grep 'ProductType' | cut -c 14-)
[ ! $ProductType ] && ProductType=$(ideviceinfo | grep 'ProductType' | cut -c 14-) [ ! $ProductType ] && ProductType=$($ideviceinfo | grep 'ProductType' | cut -c 14-)
ProductVer=$(echo "$ideviceinfo" | grep 'ProductVer' | cut -c 17-) ProductVer=$(echo "$ideviceinfo2" | grep 'ProductVer' | cut -c 17-)
VersionDetect=$(echo $ProductVer | cut -c 1) VersionDetect=$(echo $ProductVer | cut -c 1)
UniqueChipID=$(echo "$ideviceinfo" | grep 'UniqueChipID' | cut -c 15-) UniqueChipID=$(echo "$ideviceinfo2" | grep 'UniqueChipID' | cut -c 15-)
UniqueDeviceID=$(echo "$ideviceinfo" | grep 'UniqueDeviceID' | cut -c 17-) UniqueDeviceID=$(echo "$ideviceinfo2" | grep 'UniqueDeviceID' | cut -c 17-)
fi fi
[ ! $ProductType ] && ProductType=0 [ ! $ProductType ] && ProductType=0
BasebandDetect BasebandDetect
@ -74,7 +91,6 @@ function Main {
esac esac
done done
SelectVersion SelectVersion
elif [[ $RecoveryDevice == 1 ]] && [[ $A7Device != 1 ]]; then elif [[ $RecoveryDevice == 1 ]] && [[ $A7Device != 1 ]]; then
Error "32-bit device detected in recovery mode. Please put the device in normal mode and jailbroken before proceeding" "For usage of 32-bit ipwndfu, put the device in DFU mode (A6) or pwnDFU mode (A5 using Arduino)" Error "32-bit device detected in recovery mode. Please put the device in normal mode and jailbroken before proceeding" "For usage of 32-bit ipwndfu, put the device in DFU mode (A6) or pwnDFU mode (A5 using Arduino)"
fi fi
@ -197,12 +213,12 @@ function kDFU {
fi fi
[[ ! -e saved/$ProductType/$iBSS.dfu ]] && Error "Failed to save iBSS. Please run the script again" [[ ! -e saved/$ProductType/$iBSS.dfu ]] && Error "Failed to save iBSS. Please run the script again"
Log "Patching iBSS..." Log "Patching iBSS..."
bspatch saved/$ProductType/$iBSS.dfu tmp/pwnediBSS resources/patches/$iBSS.patch $bspatch saved/$ProductType/$iBSS.dfu tmp/pwnediBSS resources/patches/$iBSS.patch
if [[ $1 == iBSS ]]; then if [[ $1 == iBSS ]]; then
cd resources/ipwndfu 2>/dev/null cd resources/ipwndfu 2>/dev/null
Log "Booting iBSS..." Log "Booting iBSS..."
sudo python2 ipwndfu -l ../../tmp/pwnediBSS sudo $python ipwndfu -l ../../tmp/pwnediBSS
cd ../.. cd ../..
return $? return $?
fi fi
@ -214,7 +230,7 @@ function kDFU {
[ ! $(which iproxy) ] && Error "iproxy cannot be found. Please re-install dependencies and try again" "./restore.sh InstallDependencies" [ ! $(which iproxy) ] && Error "iproxy cannot be found. Please re-install dependencies and try again" "./restore.sh InstallDependencies"
iproxy 2222 22 & iproxy 2222 22 &
iproxyPID=$! iproxyPID=$!
WifiAddr=$(echo "$ideviceinfo" | grep 'WiFiAddress' | cut -c 14-) WifiAddr=$(echo "$ideviceinfo2" | grep 'WiFiAddress' | cut -c 14-)
WifiAddrDecr=$(echo $(printf "%x\n" $(expr $(printf "%d\n" 0x$(echo "${WifiAddr}" | tr -d ':')) - 1)) | sed 's/\(..\)/\1:/g;s/:$//') WifiAddrDecr=$(echo $(printf "%x\n" $(expr $(printf "%d\n" 0x$(echo "${WifiAddr}" | tr -d ':')) - 1)) | sed 's/\(..\)/\1:/g;s/:$//')
echo '#!/bin/bash' > tmp/pwn.sh echo '#!/bin/bash' > tmp/pwn.sh
echo "nvram wifiaddr=$WifiAddrDecr" >> tmp/pwn.sh echo "nvram wifiaddr=$WifiAddrDecr" >> tmp/pwn.sh
@ -236,7 +252,7 @@ function kDFU {
Log "Finding device in DFU mode..." Log "Finding device in DFU mode..."
while [[ $DFUDevice != 1 ]]; do while [[ $DFUDevice != 1 ]]; do
DFUDevice=$(lsusb | grep -c '1227') DFUDevice=$($lsusb | grep -c '1227')
sleep 2 sleep 2
done done
Log "Found device in DFU mode." Log "Found device in DFU mode."
@ -244,12 +260,12 @@ function kDFU {
} }
function Recovery { function Recovery {
RecoveryDevice=$(lsusb | grep -c '1281') RecoveryDevice=$($lsusb | grep -c '1281')
if [[ $RecoveryDevice != 1 ]]; then if [[ $RecoveryDevice != 1 ]]; then
Log "Entering recovery mode..." Log "Entering recovery mode..."
ideviceenterrecovery $UniqueDeviceID >/dev/null ideviceenterrecovery $UniqueDeviceID >/dev/null
while [[ $RecoveryDevice != 1 ]]; do while [[ $RecoveryDevice != 1 ]]; do
RecoveryDevice=$(lsusb | grep -c '1281') RecoveryDevice=$($lsusb | grep -c '1281')
sleep 2 sleep 2
done done
fi fi
@ -268,7 +284,7 @@ function Recovery {
echo -e "\n* Release POWER and hold HOME button for 10 seconds." echo -e "\n* Release POWER and hold HOME button for 10 seconds."
for i in {10..01}; do for i in {10..01}; do
echo -n "$i " echo -n "$i "
DFUDevice=$(lsusb | grep -c '1227') DFUDevice=$($lsusb | grep -c '1227')
[[ $DFUDevice == 1 ]] && CheckM8 [[ $DFUDevice == 1 ]] && CheckM8
sleep 1 sleep 1
done done
@ -280,13 +296,13 @@ function CheckM8 {
[[ $A7Device == 1 ]] && echo -e "\n[Log] Device in DFU mode detected." [[ $A7Device == 1 ]] && echo -e "\n[Log] Device in DFU mode detected."
Log "Entering pwnDFU mode with ipwndfu..." Log "Entering pwnDFU mode with ipwndfu..."
cd resources/ipwndfu cd resources/ipwndfu
sudo python2 ipwndfu -p sudo $python ipwndfu -p
pwnDFUDevice=$(sudo lsusb -v -d 05ac:1227 2>/dev/null | grep -c 'checkm8') pwnDFUDevice=$(sudo $lsusb -v -d 05ac:1227 2>/dev/null | grep -c 'checkm8')
if [ $pwnDFUDevice == 1 ]; then if [ $pwnDFUDevice == 1 ]; then
Log "Device in pwnDFU mode detected." Log "Device in pwnDFU mode detected."
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
Log "Running rmsigchks.py..." Log "Running rmsigchks.py..."
sudo python2 rmsigchks.py sudo $python rmsigchks.py
cd ../.. cd ../..
else else
kDFU iBSS kDFU iBSS
@ -338,8 +354,8 @@ function Downgrade {
if [ ! -e $IPSWCustom.ipsw ]; then if [ ! -e $IPSWCustom.ipsw ]; then
Log "Preparing custom IPSW..." Log "Preparing custom IPSW..."
cp $IPSW/Firmware/all_flash/$SEP . cp $IPSW/Firmware/all_flash/$SEP .
bspatch $IPSW/Firmware/dfu/$iBSS.im4p $iBSS.im4p resources/patches/$iBSS.patch $bspatch $IPSW/Firmware/dfu/$iBSS.im4p $iBSS.im4p resources/patches/$iBSS.patch
bspatch $IPSW/Firmware/dfu/$iBEC.im4p $iBEC.im4p resources/patches/$iBEC.patch $bspatch $IPSW/Firmware/dfu/$iBEC.im4p $iBEC.im4p resources/patches/$iBEC.patch
cp -f $iBSS.im4p $iBEC.im4p $IPSW/Firmware/dfu cp -f $iBSS.im4p $iBEC.im4p $IPSW/Firmware/dfu
cd $IPSW cd $IPSW
zip ../$IPSWCustom.ipsw -rq0 * zip ../$IPSWCustom.ipsw -rq0 *
@ -355,7 +371,7 @@ function Downgrade {
$irecovery -f $iBSS.im4p $irecovery -f $iBSS.im4p
$irecovery -f $iBEC.im4p $irecovery -f $iBEC.im4p
sleep 5 sleep 5
RecoveryDevice=$(lsusb | grep -c '1281') RecoveryDevice=$($lsusb | grep -c '1281')
if [[ $RecoveryDevice != 1 ]]; then if [[ $RecoveryDevice != 1 ]]; then
echo "[Error] Failed to detect device in pwnREC mode." echo "[Error] Failed to detect device in pwnREC mode."
echo "* If you device has backlight turned on, you may try re-plugging in your device and attempt to continue" echo "* If you device has backlight turned on, you may try re-plugging in your device and attempt to continue"
@ -363,7 +379,7 @@ function Downgrade {
read -s read -s
Log "Finding device in pwnREC mode..." Log "Finding device in pwnREC mode..."
while [[ $RecoveryDevice != 1 ]]; do while [[ $RecoveryDevice != 1 ]]; do
RecoveryDevice=$(lsusb | grep -c '1281') RecoveryDevice=$($lsusb | grep -c '1281')
sleep 2 sleep 2
done done
fi fi
@ -373,7 +389,7 @@ function Downgrade {
Log "Preparing for futurerestore... (Enter root password of your PC/Mac when prompted)" Log "Preparing for futurerestore... (Enter root password of your PC/Mac when prompted)"
cd resources cd resources
sudo bash -c "python3 -m http.server 80 &" sudo bash -c "$python -m SimpleHTTPServer 80 &"
cd .. cd ..
if [ $Baseband == 0 ]; then if [ $Baseband == 0 ]; then
@ -420,7 +436,7 @@ function Downgrade {
echo echo
Log "futurerestore done!" Log "futurerestore done!"
Log "Stopping local server... (Enter root password of your PC/Mac when prompted)" Log "Stopping local server... (Enter root password of your PC/Mac when prompted)"
ps aux | awk '/python3/ {print "sudo kill -9 "$2" 2>/dev/null"}' | bash ps aux | awk '/python/ {print "sudo kill -9 "$2" 2>/dev/null"}' | bash
Log "Downgrade script done!" Log "Downgrade script done!"
} }
@ -433,14 +449,14 @@ function InstallDependencies {
Log "Installing dependencies..." Log "Installing dependencies..."
if [[ $ID == "arch" ]] || [[ $ID_LIKE == "arch" ]]; then if [[ $ID == "arch" ]] || [[ $ID_LIKE == "arch" ]]; then
# Arch Linux # Arch Linux
sudo pacman -Sy --noconfirm --needed bsdiff curl libcurl-compat libpng12 libimobiledevice libusbmuxd libzip openssh openssl-1.0 python2 python unzip usbmuxd usbutils sudo pacman -Sy --noconfirm --needed bsdiff curl libcurl-compat libpng12 libimobiledevice libusbmuxd libzip openssh openssl-1.0 python2 unzip usbmuxd usbutils
sudo ln -sf /usr/lib/libzip.so.5 /usr/lib/libzip.so.4 sudo ln -sf /usr/lib/libzip.so.5 /usr/lib/libzip.so.4
elif [[ $UBUNTU_CODENAME == "focal" ]]; then elif [[ $UBUNTU_CODENAME == "focal" ]]; then
# Ubuntu Focal # Ubuntu Focal
sudo add-apt-repository universe sudo add-apt-repository universe
sudo apt update sudo apt update
sudo apt install -y autoconf automake binutils bsdiff build-essential checkinstall curl git libimobiledevice-utils libplist3 libreadline-dev libtool-bin libusb-1.0-0-dev libusbmuxd6 libusbmuxd-tools libzip5 openssh-client python2 python3 usbmuxd usbutils sudo apt install -y autoconf automake binutils bsdiff build-essential checkinstall curl git libimobiledevice-utils libplist3 libreadline-dev libtool-bin libusb-1.0-0-dev libusbmuxd6 libusbmuxd-tools libzip5 openssh-client python2 usbmuxd usbutils
SavePkg SavePkg
ar x libcurl3.deb data.tar.xz ar x libcurl3.deb data.tar.xz
tar xf data.tar.xz tar xf data.tar.xz
@ -451,7 +467,7 @@ function InstallDependencies {
sudo ln -sf /usr/lib/x86_64-linux-gnu/libusbmuxd.so.6 /usr/local/lib/libusbmuxd-2.0.so.6 sudo ln -sf /usr/lib/x86_64-linux-gnu/libusbmuxd.so.6 /usr/local/lib/libusbmuxd-2.0.so.6
elif [[ $ID == "fedora" ]]; then elif [[ $ID == "fedora" ]]; then
sudo dnf install -y automake bsdiff git libimobiledevice-utils libpng12 libtool libusb-devel libusbmuxd-utils libzip make perl-Digest-SHA python2 python readline-devel sudo dnf install -y automake bsdiff git libimobiledevice-utils libpng12 libtool libusb-devel libusbmuxd-utils libzip make perl-Digest-SHA python2 readline-devel
SavePkg SavePkg
rpm2cpio openssl-1.0.0.rpm | cpio -idmv rpm2cpio openssl-1.0.0.rpm | cpio -idmv
sudo cp usr/lib64/libcrypto.so.1.0.0 usr/lib64/libssl.so.1.0.0 /usr/lib64 sudo cp usr/lib64/libcrypto.so.1.0.0 usr/lib64/libssl.so.1.0.0 /usr/lib64
@ -462,22 +478,20 @@ function InstallDependencies {
elif [[ $OSTYPE == "darwin"* ]]; then elif [[ $OSTYPE == "darwin"* ]]; then
# macOS # macOS
if [[ ! $(which brew) ]]; then curl -L https://github.com/libimobiledevice-win32/imobiledevice-net/releases/download/v1.3.4/libimobiledevice.1.2.1-r1079-osx-x64.zip -o libimobiledevice.zip
Log "Homebrew is not detected/installed, installing Homebrew..." rm -rf ../resources/libimobiledevice
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" mkdir ../resources/libimobiledevice
fi unzip libimobiledevice.zip -d ../resources/libimobiledevice
brew install --HEAD usbmuxd chmod +x ../resources/libimobiledevice/*
brew install --HEAD libimobiledevice
brew install --HEAD libusbmuxd
brew install libzip lsusb python3
brew install make automake autoconf libtool pkg-config gcc
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
Compile libimobiledevice libirecovery Compile libimobiledevice libirecovery
[[ $platform == linux ]] && sudo cp ../resources/lib/* /usr/local/lib sudo cp ../resources/lib/* /usr/local/lib
fi
Log "Install script done! Please run the script again to proceed" Log "Install script done! Please run the script again to proceed"
exit exit