Updated scripts!

* Included BuildManifests, downloading otafirmware no longer required
* Do not delete ota.json when already downloaded
* install.sh and downgrader.sh merged into one!
* Autodetect distro/OS for installing dependencies
* macOS support!
This commit is contained in:
LukeeGD 2019-12-04 15:11:24 +08:00
parent 580e8bfba2
commit 645608eda1
4 changed files with 114 additions and 90 deletions

BIN
BuildManifests.zip Normal file

Binary file not shown.

View File

@ -13,7 +13,7 @@
### Prerequisites: ### Prerequisites:
- **A supported jailbroken A5 or A6 iOS device on iOS 5 to 10** ([Phoenix](https://phoenixpwn.com/) for 9.3.5/9.3.6, [h3lix](https://h3lix.tihmstar.net/) for 10.3.3/10.3.4) (supported devices are listed below) - **A supported jailbroken A5 or A6 iOS device on iOS 5 to 10** ([Phoenix](https://phoenixpwn.com/) for 9.3.5/9.3.6, [h3lix](https://h3lix.tihmstar.net/) for 10.3.3/10.3.4) (supported devices are listed below)
- **iOS [8.4.1](https://ipsw.me/8.4.1) or [6.1.3](https://ipsw.me/6.1.3) IPSW for your device** - **iOS [8.4.1](https://ipsw.me/8.4.1) or [6.1.3](https://ipsw.me/6.1.3) IPSW for your device**
- **A Linux install or live USB** (Tested on Lubuntu [16.04](http://cdimage.ubuntu.com/lubuntu/releases/16.04/release/), [18.04](http://cdimage.ubuntu.com/lubuntu/releases/18.04/release/), [Manjaro](https://manjaro.org/download/), and [Arch Linux](https://www.archlinux.org/)) (a live USB can be easily created with tools like [balenaEtcher](https://www.balena.io/etcher/) or [Rufus](https://rufus.ie/)) - A **macOS** or **Linux install/live USB** (Tested on Lubuntu [16.04](http://cdimage.ubuntu.com/lubuntu/releases/16.04/release/), [18.04](http://cdimage.ubuntu.com/lubuntu/releases/18.04/release/), [Manjaro](https://manjaro.org/download/), and [Arch Linux](https://www.archlinux.org/)) (a live USB can be easily created with tools like [balenaEtcher](https://www.balena.io/etcher/) or [Rufus](https://rufus.ie/)) (macOS tested on 10.13 and 10.14)
- **[OpenSSH](https://cydia.saurik.com/openssh.html)** installed on iOS device - **[OpenSSH](https://cydia.saurik.com/openssh.html)** installed on iOS device
- **[MTerminal](http://cydia.saurik.com/package/com.officialscheduler.mterminal/)** installed on iOS device (10.x users only) - **[MTerminal](http://cydia.saurik.com/package/com.officialscheduler.mterminal/)** installed on iOS device (10.x users only)
- iOS 7 Pangu users should install the [latest Pangu 7.1.x Untether](http://apt.saurik.com/debs/io.pangu.axe7_0.3_iphoneos-arm.deb) - iOS 7 Pangu users should install the [latest Pangu 7.1.x Untether](http://apt.saurik.com/debs/io.pangu.axe7_0.3_iphoneos-arm.deb)
@ -26,10 +26,9 @@
- When the prerequisites are met, usage should be straightforward: - When the prerequisites are met, usage should be straightforward:
1. [Download](https://github.com/LukeZGD/32bit-OTA-Downgrader/archive/master.zip) or `git clone` this repo 1. [Download](https://github.com/LukeZGD/32bit-OTA-Downgrader/archive/master.zip) or `git clone` this repo
2. Open Terminal, cd to the directory where the scripts are located (example: `cd /home/user/32bit-OTA-Downgrader`) 2. Open Terminal, cd to the directory where the scripts are located (example: `cd /home/user/32bit-OTA-Downgrader`)
3. Run `chmod +x install.sh downgrader.sh` 3. Run `chmod +x restore.sh`
4. Run `./install.sh` 4. Run `./restore.sh`
5. Run `./downgrader.sh` 5. Select option to be used (8.4.1/6.1.3 downgrade or just enter pwnDFU mode)
6. Select option to be used (8.4.1/6.1.3 downgrade or just enter pwnDFU mode)
6. Follow instructions 6. Follow instructions
### Tools used by this script: ### Tools used by this script:

View File

@ -1,46 +0,0 @@
#!/bin/bash
function ubuntu {
sudo apt update
sudo apt -y install bsdiff curl ifuse libimobiledevice-utils libzip4 usbmuxd
}
function ubuntu1804 {
sudo apt -y install binutils
mkdir tmp
cd tmp
apt download -o=dir::cache=. libcurl3
ar x libcurl3* data.tar.xz
tar xf data.tar.xz
sudo cp -L usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/libcurl.so.3
if [ $(uname -m) == 'x86_64' ]
then
mtype='amd64'
else
mtype='i386'
fi
curl -L -# http://mirrors.edge.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_${mtype}.deb -o libpng12.deb
sudo dpkg -i libpng12.deb
cd ..
rm -rf tmp
}
function arch {
sudo pacman -Sy --noconfirm bsdiff curl ifuse libcurl-compat libimobiledevice libpng12 libzip openssh openssl-1.0 usbmuxd usbutils
sudo ln -sf /usr/lib/libzip.so.5 /usr/lib/libzip.so.4
}
clear
echo "******* 32bit-OTA-Downgrader *******"
echo " - by LukeZGD "
echo
echo "Install dependencies"
select opt in "Ubuntu 16.04" "Ubuntu 18.04" "Arch Linux"; do
case $opt in
"Ubuntu 16.04" ) ubuntu; break;;
"Ubuntu 18.04" ) ubuntu; ubuntu1804; break;;
"Arch Linux" ) arch; break;;
esac
done
echo
echo "Install script done"

View File

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
clear
echo "******* 32bit-OTA-Downgrader *******"
echo " - by LukeZGD "
echo
if [[ $OSTYPE == "linux-gnu" ]] if [[ $OSTYPE == "linux-gnu" ]]
then then
platform="linux" platform="linux"
@ -84,7 +89,7 @@ function Downgrade841 {
iBSS="iBSS.$HardwareModelLower.RELEASE" iBSS="iBSS.$HardwareModelLower.RELEASE"
DowngradeVersion="8.4.1" DowngradeVersion="8.4.1"
DowngradeBuildVer="12H321" DowngradeBuildVer="12H321"
DowngradeBuildPre="12H143" BuildManifest="BuildManifest_${ProductType}.plist"
iv=iv_$HardwareModelLower iv=iv_$HardwareModelLower
key=key_$HardwareModelLower key=key_$HardwareModelLower
Downgrade Downgrade
@ -96,7 +101,7 @@ function Downgrade613 {
iBSS="iBSS.${HardwareModelLower}ap.RELEASE" iBSS="iBSS.${HardwareModelLower}ap.RELEASE"
DowngradeVersion="6.1.3" DowngradeVersion="6.1.3"
DowngradeBuildVer="10B329" DowngradeBuildVer="10B329"
DowngradeBuildPre="10B146" BuildManifest="BuildManifest613_${ProductType}.plist"
iv=iv_${HardwareModelLower}_613 iv=iv_${HardwareModelLower}_613
key=key_${HardwareModelLower}_613 key=key_${HardwareModelLower}_613
Downgrade Downgrade
@ -120,20 +125,22 @@ function SaveOTABlobs {
echo "Download/extract tsschecker failed. Please run the script again" echo "Download/extract tsschecker failed. Please run the script again"
exit exit
fi fi
if [ ! -e /tmp/ota.json ] && [ ! -e $TMPDIR/ota.json ] if [ ! -e ota.json ]
then then
echo "Downloading ota.json..." echo "Downloading ota.json..."
curl -L -# "https://api.ipsw.me/v2.1/ota.json/condensed" -o "tmp/ota.json" curl -L -# "https://api.ipsw.me/v2.1/ota.json/condensed" -o "ota.json"
echo 'Copying ota.json to tmp...'
if [ $platform == macos ]
then
cp tmp/ota.json $TMPDIR
else
cp tmp/ota.json /tmp
fi
echo
fi fi
echo 'Copying ota.json to tmp...'
if [ $platform == macos ]
then
cp ota.json $TMPDIR
else
cp ota.json /tmp
fi
echo
if [ ! -e /tmp/ota.json ] && [ ! -e $TMPDIR/ota.json ] if [ ! -e /tmp/ota.json ] && [ ! -e $TMPDIR/ota.json ]
then then
echo "Download ota.json failed. Please run the script again" echo "Download ota.json failed. Please run the script again"
@ -141,12 +148,10 @@ function SaveOTABlobs {
exit exit
fi fi
echo "Downloading OTA Firmware..."
curl -L -# "https://api.ipsw.me/v4/ota/download/${ProductType}/${DowngradeBuildVer}?prerequisite=${DowngradeBuildPre}" -o "tmp/otafirmware.zip"
echo "Extracting BuildManifest.plist..." echo "Extracting BuildManifest.plist..."
unzip -j tmp/otafirmware.zip AssetData/boot/BuildManifest.plist -d "tmp/" unzip -j BuildManifests.zip $BuildManifest -d "tmp/"
echo echo
if [ ! -e tmp/BuildManifest.plist ] if [ ! -e tmp/$BuildManifest ]
then then
echo "Download/extract BuildManifest.plist failed. Please run the script again" echo "Download/extract BuildManifest.plist failed. Please run the script again"
rm -rf tmp/ rm -rf tmp/
@ -154,21 +159,21 @@ function SaveOTABlobs {
fi fi
echo "Saving $DowngradeVersion blobs with tsschecker..." echo "Saving $DowngradeVersion blobs with tsschecker..."
env "LD_PRELOAD=libcurl.so.3" tools/tsschecker_$platform -d $ProductType -i $DowngradeVersion -o -s -e $UniqueChipID -m tmp/BuildManifest.plist env "LD_PRELOAD=libcurl.so.3" tools/tsschecker_$platform -d $ProductType -i $DowngradeVersion -o -s -e $UniqueChipID -m tmp/$BuildManifest
echo echo
SHSH=$(ls *.shsh2) SHSH=$(ls *.shsh2)
if [ ! -e $SHSH ] if [ ! -e $SHSH ]
then then
echo "Saving $DowngradeVersion blobs failed. Please run the script again" echo "Saving $DowngradeVersion blobs failed. Please run the script again"
rm -rf tmp/ BuildManifest.plist rm -rf tmp/
exit exit
fi fi
} }
function Downgrade { function Downgrade {
IPSW="${ProductType}_${DowngradeVersion}_${DowngradeBuildVer}_Restore" IPSW="${ProductType}_${DowngradeVersion}_${DowngradeBuildVer}_Restore.ipsw"
if [ ! -e ${IPSW}.ipsw ] if [ ! -e ${IPSW} ]
then then
echo "iOS $DowngradeVersion IPSW is missing! Please put the IPSW on the same directory of this script" echo "iOS $DowngradeVersion IPSW is missing! Please put the IPSW on the same directory of this script"
exit exit
@ -198,7 +203,7 @@ function Downgrade {
fi fi
echo "Extracting $DowngradeVersion IPSW..." echo "Extracting $DowngradeVersion IPSW..."
unzip -q ${IPSW}.ipsw -d "$IPSW/" unzip -q ${IPSW} -d "$IPSW/"
cp $IPSW/Firmware/dfu/$iBSS.dfu tmp/ cp $IPSW/Firmware/dfu/$iBSS.dfu tmp/
echo echo
@ -211,10 +216,10 @@ function Downgrade {
do do
if [[ ! $NoBaseband ]] if [[ ! $NoBaseband ]]
then then
sudo env "LD_PRELOAD=libcurl.so.3" tools/futurerestore_$platform -t $SHSH --latest-baseband --use-pwndfu ${IPSW}.ipsw sudo env "LD_PRELOAD=libcurl.so.3" tools/futurerestore_$platform -t $SHSH --latest-baseband --use-pwndfu ${IPSW}
else else
echo "Detected device has no baseband" echo "Detected device has no baseband"
sudo env "LD_PRELOAD=libcurl.so.3" tools/futurerestore_$platform -t $SHSH --no-baseband --use-pwndfu ${IPSW}.ipsw sudo env "LD_PRELOAD=libcurl.so.3" tools/futurerestore_$platform -t $SHSH --no-baseband --use-pwndfu ${IPSW}
fi fi
echo echo
@ -234,16 +239,16 @@ function Downgrade {
function pwnDFUSelf { function pwnDFUSelf {
DowngradeVersion="8.4.1" DowngradeVersion="8.4.1"
IPSW="${ProductType}_8.4.1_12H321_Restore" IPSW="${ProductType}_8.4.1_12H321_Restore.ipsw"
iBSS="iBSS.$HardwareModelLower.RELEASE" iBSS="iBSS.$HardwareModelLower.RELEASE"
iv=iv_$HardwareModelLower iv=iv_$HardwareModelLower
key=key_$HardwareModelLower key=key_$HardwareModelLower
if [ ! -e ${IPSW}.ipsw ] if [ ! -e ${IPSW} ]
then then
echo "Please provide an iOS 8.4.1 IPSW for your device to get to pwnDFU mode" echo "Please provide an iOS 8.4.1 IPSW for your device to get to pwnDFU mode"
else else
echo "Extracting iBSS from IPSW..." echo "Extracting iBSS from IPSW..."
unzip -j ${IPSW}.ipsw Firmware/dfu/$iBSS.dfu -d "tmp/" unzip -j ${IPSW} Firmware/dfu/$iBSS.dfu -d "tmp/"
pwnDFU pwnDFU
fi fi
} }
@ -332,12 +337,9 @@ UniqueChipID=$(ideviceinfo | grep 'UniqueChipID' | cut -c 15-)
function MainMenu { function MainMenu {
rm -rf iP*/ tmp/ $(ls *.shsh2 2>/dev/null) rm -rf iP*/ tmp/ $(ls *.shsh2 2>/dev/null)
mkdir tmp mkdir tmp
clear echo "Main Menu"
echo "******* 32bit-OTA-Downgrader *******"
echo " - by LukeZGD "
echo
if [ ! $HardwareModel ] if [ ! $HardwareModel ]
then then
echo "Please plug the device in and trust this computer before proceeding" echo "Please plug the device in and trust this computer before proceeding"
@ -352,16 +354,85 @@ function MainMenu {
echo "ProductVersion: $ProductVersion" echo "ProductVersion: $ProductVersion"
echo "UniqueChipID (ECID): $UniqueChipID" echo "UniqueChipID (ECID): $UniqueChipID"
echo echo
} select opt in "Downgrade device to iOS 8.4.1" "Downgrade device to iOS 6.1.3" "Just put device in pwnDFU mode" "Exit"; do
MainMenu
select opt in "Downgrade device to iOS 8.4.1" "Downgrade device to iOS 6.1.3" "Just put device in pwnDFU mode" "Exit"; do
case $opt in case $opt in
"Downgrade device to iOS 8.4.1" ) Downgrade841; break;; "Downgrade device to iOS 8.4.1" ) Downgrade841; break;;
"Downgrade device to iOS 6.1.3" ) Downgrade613; break;; "Downgrade device to iOS 6.1.3" ) Downgrade613; break;;
"Just put device in pwnDFU mode" ) pwnDFUSelf; break;; "Just put device in pwnDFU mode" ) pwnDFUSelf; break;;
"Exit" ) break;; "Exit" ) exit;;
*) MainMenu;; *) MainMenu;;
esac esac
done done
}
function Ubuntu {
sudo apt update
sudo apt -y install bsdiff curl ifuse libimobiledevice-utils libzip4 usbmuxd
}
function Ubuntu1804 {
sudo apt -y install binutils
mkdir tmp
cd tmp
apt download -o=dir::cache=. libcurl3
ar x libcurl3* data.tar.xz
tar xf data.tar.xz
sudo cp -L usr/lib/x86_64-linux-gnu/libcurl.so.4 /usr/lib/libcurl.so.3
if [ $(uname -m) == 'x86_64' ]
then
mtype='amd64'
else
mtype='i386'
fi
curl -L -# http://mirrors.edge.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_${mtype}.deb -o libpng12.deb
sudo dpkg -i libpng12.deb
cd ..
rm -rf tmp
}
if [ ! $(which bspatch) ] || [ ! $(which ideviceinfo) ] || [ ! $(which ssh) ] || [ ! $(which scp) ]
then
echo "Install dependencies"
. /etc/os-release 2> /dev/null
if [[ $(which pacman) ]] || [[ $NAME == "Arch Linux" ]]
then
sudo pacman -Sy --noconfirm bsdiff curl ifuse libcurl-compat libimobiledevice libpng12 libzip openssh openssl-1.0 unzip usbmuxd usbutils
sudo ln -sf /usr/lib/libzip.so.5 /usr/lib/libzip.so.4
elif [[ $NAME == "Ubuntu" ]] && [[ $VERSION_ID == "16.04" ]]
then
Ubuntu
elif [[ $(which apt) ]] || [[ $NAME == "Ubuntu" ]] && [[ $VERSION_ID == "18.04" ]]
then
Ubuntu
Ubuntu1804
elif [[ $OSTYPE == "darwin"* ]]
then
if [[ ! $(which brew) ]]
then
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew uninstall --ignore-dependencies usbmuxd
brew uninstall --ignore-dependencies libimobiledevice
brew install --HEAD usbmuxd
brew install --HEAD libimobiledevice
brew install libzip
brew install openssl
else
echo "Distro not detected/supported. Please select manually"
select opt in "Ubuntu 16.04" "Ubuntu 18.04" "Arch Linux" "macOS"; do
case $opt in
"Ubuntu 16.04" ) ubuntu; break;;
"Ubuntu 18.04" ) ubuntu; ubuntu1804; break;;
"Arch Linux" ) arch; break;;
"macOS" ) macos; break;;
esac
done
fi
echo "Install script done! Will now proceed to main menu..."
sleep 5
MainMenu
else
MainMenu
fi