Update restore.sh

This commit is contained in:
LukeeGD 2020-07-27 19:27:46 +08:00
parent b7bf6660c6
commit e3480568b7

View File

@ -27,6 +27,12 @@ function Main {
else else
Error "OSTYPE unknown/not supported." "Supports Linux and macOS only" Error "OSTYPE unknown/not supported." "Supports Linux and macOS only"
fi fi
futurerestore152="sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore152_$platform"
futurerestore249="sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore249_$platform"
irecovery="sudo LD_LIBRARY_PATH=/usr/local/lib irecovery"
pzb="resources/tools/pzb_$platform"
tsschecker="env LD_LIBRARY_PATH=/usr/local/lib resources/tools/tsschecker_$platform"
cd resources/tools cd resources/tools
ln -sf futurerestore249_macos futurerestore152_macos ln -sf futurerestore249_macos futurerestore152_macos
cd ../.. cd ../..
@ -35,6 +41,9 @@ function Main {
[[ $(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"
Clean Clean
mkdir tmp mkdir tmp
chmod +x resources/tools/*
SaveExternal firmware
SaveExternal ipwndfu
DFUDevice=$(lsusb | grep -c '1227') DFUDevice=$(lsusb | grep -c '1227')
RecoveryDevice=$(lsusb | grep -c '1281') RecoveryDevice=$(lsusb | grep -c '1281')
@ -44,24 +53,21 @@ function Main {
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)
[ ! $ProductType ] && read -p "[Input] Enter ProductType (eg. iPad2,1): " ProductType [ ! $ProductType ] && read -p "[Input] Enter ProductType (eg. iPad2,1): " ProductType
UniqueChipID=$(sudo LD_LIBRARY_PATH=/usr/local/lib irecovery -q | grep 'ECID' | cut -c 7-) UniqueChipID=$($irecovery -q | grep 'ECID' | cut -c 7-)
ProductVer='Unknown' ProductVer='Unknown'
else else
HWModel=$(ideviceinfo -s | grep 'HardwareModel' | cut -c 16- | tr '[:upper:]' '[:lower:]' | sed 's/.\{2\}$//') ideviceinfo=$(ideviceinfo -s)
ProductType=$(ideviceinfo -s | grep 'ProductType' | cut -c 14-) HWModel=$(echo "$ideviceinfo" | grep 'HardwareModel' | cut -c 16- | tr '[:upper:]' '[:lower:]' | sed 's/.\{2\}$//')
ProductType=$(echo "$ideviceinfo" | grep 'ProductType' | cut -c 14-)
[ ! $ProductType ] && ProductType=$(ideviceinfo | grep 'ProductType' | cut -c 14-) [ ! $ProductType ] && ProductType=$(ideviceinfo | grep 'ProductType' | cut -c 14-)
ProductVer=$(ideviceinfo -s | grep 'ProductVer' | cut -c 17-) ProductVer=$(echo "$ideviceinfo" | grep 'ProductVer' | cut -c 17-)
VersionDetect=$(echo $ProductVer | cut -c 1) VersionDetect=$(echo $ProductVer | cut -c 1)
UniqueChipID=$(ideviceinfo -s | grep 'UniqueChipID' | cut -c 15-) UniqueChipID=$(echo "$ideviceinfo" | grep 'UniqueChipID' | cut -c 15-)
UniqueDeviceID=$(ideviceinfo -s | grep 'UniqueDeviceID' | cut -c 17-) UniqueDeviceID=$(echo "$ideviceinfo" | grep 'UniqueDeviceID' | cut -c 17-)
fi fi
[ ! $ProductType ] && ProductType='NA' [ ! $ProductType ] && ProductType='NA'
BasebandDetect BasebandDetect
chmod +x resources/tools/*
SaveExternal firmware
SaveExternal ipwndfu
if [ $DFUDevice == 1 ]; then if [ $DFUDevice == 1 ]; then
Log "Device in DFU mode detected." Log "Device in DFU mode detected."
if [[ $A7Device != 1 ]]; then if [[ $A7Device != 1 ]]; then
@ -116,6 +122,7 @@ function SelectVersion {
Selection+=("iOS 6.1.3") Selection+=("iOS 6.1.3")
fi fi
[[ $Mode == 'Downgrade' ]] && Selection+=("Other") [[ $Mode == 'Downgrade' ]] && Selection+=("Other")
Selection+=("(Any other key to exit)")
echo "[Input] Select iOS version:" echo "[Input] Select iOS version:"
select opt in "${Selection[@]}"; do select opt in "${Selection[@]}"; do
case $opt in case $opt in
@ -180,11 +187,11 @@ function SaveOTABlobs {
Log "Saving $OSVer blobs with tsschecker..." Log "Saving $OSVer blobs with tsschecker..."
BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist" BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist"
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
APNonce=$(sudo LD_LIBRARY_PATH=/usr/local/lib irecovery -q | grep 'NONC' | cut -c 7-) APNonce=$($irecovery -q | grep 'NONC' | cut -c 7-)
echo "* APNonce: $APNonce" echo "* APNonce: $APNonce"
env LD_LIBRARY_PATH=/usr/local/lib resources/tools/tsschecker_$platform -d $ProductType -B ${HWModel}ap -i $OSVer -e $UniqueChipID -m $BuildManifest --apnonce $APNonce -o -s $tsschecker -d $ProductType -B ${HWModel}ap -i $OSVer -e $UniqueChipID -m $BuildManifest --apnonce $APNonce -o -s
else else
env LD_LIBRARY_PATH=/usr/local/lib resources/tools/tsschecker_$platform -d $ProductType -i $OSVer -e $UniqueChipID -m $BuildManifest -o -s $tsschecker -d $ProductType -i $OSVer -e $UniqueChipID -m $BuildManifest -o -s
SHSH=$(ls *_${ProductType}_${OSVer}-*.shsh2) SHSH=$(ls *_${ProductType}_${OSVer}-*.shsh2)
fi fi
[ ! $SHSH ] && SHSH=$(ls *_${ProductType}_${HWModel}ap_${OSVer}-*.shsh) [ ! $SHSH ] && SHSH=$(ls *_${ProductType}_${HWModel}ap_${OSVer}-*.shsh)
@ -197,7 +204,7 @@ function SaveOTABlobs {
function kDFU { function kDFU {
if [ ! -e saved/$ProductType/$iBSS.dfu ]; then if [ ! -e saved/$ProductType/$iBSS.dfu ]; then
Log "Downloading iBSS..." Log "Downloading iBSS..."
resources/tools/pzb_$platform -g Firmware/dfu/${iBSS}.dfu -o $iBSS.dfu $(cat $Firmware/$iBSSBuildVer/url) $pzb -g Firmware/dfu/$iBSS.dfu -o $iBSS.dfu $(cat $Firmware/$iBSSBuildVer/url)
mkdir -p saved/$ProductType 2>/dev/null mkdir -p saved/$ProductType 2>/dev/null
mv $iBSS.dfu saved/$ProductType mv $iBSS.dfu saved/$ProductType
fi fi
@ -278,7 +285,7 @@ function Recovery {
read -p "[Input] Select Y to continue, N to exit recovery (Y/n) " RecoveryDFU read -p "[Input] Select Y to continue, N to exit recovery (Y/n) " RecoveryDFU
if [[ $RecoveryDFU == n ]] || [[ $RecoveryDFU == N ]]; then if [[ $RecoveryDFU == n ]] || [[ $RecoveryDFU == N ]]; then
Log "Exiting recovery mode." Log "Exiting recovery mode."
sudo LD_LIBRARY_PATH=/usr/local/lib irecovery -n $irecovery -n
exit exit
fi fi
echo "* Hold POWER and HOME button for 10 seconds." echo "* Hold POWER and HOME button for 10 seconds."
@ -363,7 +370,7 @@ function Downgrade {
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 -r0 * zip ../$IPSWCustom.ipsw -rq0 *
cd .. cd ..
mv $IPSW $IPSWCustom mv $IPSW $IPSWCustom
IPSW=$IPSWCustom IPSW=$IPSWCustom
@ -373,8 +380,8 @@ function Downgrade {
cp $IPSW/Firmware/all_flash/$SEP . cp $IPSW/Firmware/all_flash/$SEP .
fi fi
Log "Entering PWNREC mode..." Log "Entering PWNREC mode..."
sudo LD_LIBRARY_PATH=/usr/local/lib irecovery -f $iBSS.im4p $irecovery -f $iBSS.im4p
sudo LD_LIBRARY_PATH=/usr/local/lib 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
@ -393,23 +400,24 @@ function Downgrade {
Log "Device $ProductType has no baseband" Log "Device $ProductType has no baseband"
Log "Proceeding to futurerestore..." Log "Proceeding to futurerestore..."
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore249_$platform -t $SHSH -s $SEP -m $BuildManifest --no-baseband $IPSW.ipsw $futurerestore249 -t $SHSH -s $SEP -m $BuildManifest --no-baseband $IPSW.ipsw
else else
sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore152_$platform -t $SHSH --no-baseband --use-pwndfu $IPSW.ipsw $futurerestore152 -t $SHSH --no-baseband --use-pwndfu $IPSW.ipsw
fi fi
else else
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
cp $IPSW/Firmware/$Baseband . cp $IPSW/Firmware/$Baseband .
elif [ ! -e saved/$ProductType/*.bbfw ]; then elif [ ! -e saved/$ProductType/*.bbfw ]; then
Log "Downloading baseband..." Log "Downloading baseband..."
resources/tools/pzb_$platform -g Firmware/$Baseband -o $Baseband $BasebandURL $pzb -g Firmware/$Baseband -o $Baseband $BasebandURL
resources/tools/pzb_$platform -g BuildManifest.plist -o BuildManifest.plist $BasebandURL $pzb -g BuildManifest.plist -o BuildManifest.plist $BasebandURL
mkdir -p saved/$ProductType 2>/dev/null mkdir -p saved/$ProductType 2>/dev/null
cp $Baseband BuildManifest.plist saved/$ProductType cp $Baseband BuildManifest.plist saved/$ProductType
else else
cp saved/$ProductType/*.bbfw saved/$ProductType/BuildManifest.plist . cp saved/$ProductType/*.bbfw saved/$ProductType/BuildManifest.plist .
fi fi
BasebandSHA1L=$(shasum -a 1 $Baseband | awk '{print $1}') BasebandSHA1L=$(shasum -a 1 $Baseband | awk '{print $1}')
Log "Proceeding to futurerestore..."
if [ ! -e *.bbfw ] || [[ $BasebandSHA1L != $BasebandSHA1 ]]; then if [ ! -e *.bbfw ] || [[ $BasebandSHA1L != $BasebandSHA1 ]]; then
rm -f saved/$ProductType/*.bbfw saved/$ProductType/BuildManifest.plist rm -f saved/$ProductType/*.bbfw saved/$ProductType/BuildManifest.plist
echo "[Error] Downloading/verifying baseband failed." echo "[Error] Downloading/verifying baseband failed."
@ -417,18 +425,15 @@ function Downgrade {
echo "* You can also continue and futurerestore can attempt to download the baseband again" echo "* You can also continue and futurerestore can attempt to download the baseband again"
echo "* Proceeding to futurerestore in 10 seconds (Press Ctrl+C to cancel)" echo "* Proceeding to futurerestore in 10 seconds (Press Ctrl+C to cancel)"
sleep 10 sleep 10
Log "Proceeding to futurerestore..."
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore249_$platform -t $SHSH -s $SEP -m $BuildManifest --latest-baseband $IPSW.ipsw $futurerestore249 -t $SHSH -s $SEP -m $BuildManifest --latest-baseband $IPSW.ipsw
else else
sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore152_$platform -t $SHSH --latest-baseband --use-pwndfu $IPSW.ipsw $futurerestore152 -t $SHSH --latest-baseband --use-pwndfu $IPSW.ipsw
fi fi
elif [[ $A7Device == 1 ]]; then elif [[ $A7Device == 1 ]]; then
Log "Proceeding to futurerestore..." $futurerestore249 -t $SHSH -s $SEP -m $BuildManifest -b $Baseband -p $BuildManifest $IPSW.ipsw
sudo LD_LIBRARY_PATH=/usr/local/lib resources/tools/futurerestore249_$platform -t $SHSH -s $SEP -m $BuildManifest -b $Baseband -p $BuildManifest $IPSW.ipsw
else else
Log "Proceeding to futurerestore..." $futurerestore152 -t $SHSH -b $Baseband -p BuildManifest.plist --use-pwndfu $IPSW.ipsw
sudo LD_PRELOAD=libcurl.so.3 resources/tools/futurerestore152_$platform -t $SHSH -b $Baseband -p BuildManifest.plist --use-pwndfu $IPSW.ipsw
fi fi
fi fi