A bit of code restructure

This commit is contained in:
LukeZGD 2022-05-28 18:21:26 +08:00
parent d703ab0157
commit e74fe5f03b
17 changed files with 211 additions and 193 deletions

View File

@ -15,6 +15,7 @@
- [Identify your device here](https://ipsw.me/device-finder) - [Identify your device here](https://ipsw.me/device-finder)
- **iPhone 5C and iPad mini 3 devices are NOT supported!** - **iPhone 5C and iPad mini 3 devices are NOT supported!**
- iPhone 5C can still be restored to versions that you have SHSH blobs for - iPhone 5C can still be restored to versions that you have SHSH blobs for
- iPhone 4 devices also support restoring with SHSH blobs (iOS 5 and newer only)
<table> <table>
<thead> <thead>

View File

@ -30,7 +30,7 @@ SaveOTABlobs() {
Log "Saving iOS $OSVer blobs with tsschecker..." Log "Saving iOS $OSVer blobs with tsschecker..."
BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist" BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist"
ExtraArgs="-d $ProductType -i $OSVer -e $UniqueChipID -m $BuildManifest -o -s -B ${HWModel}ap --generator 0x1111111111111111 --no-baseband" ExtraArgs="-d $ProductType -i $OSVer -e $UniqueChipID -m $BuildManifest -o -s -B ${HWModel}ap -g 0x1111111111111111 -b"
SHSHChk=${UniqueChipID}_${ProductType}_${HWModel}ap_${OSVer}-${BuildVer}_3a88b7c3802f2f0510abc432104a15ebd8bd7154.shsh* SHSHChk=${UniqueChipID}_${ProductType}_${HWModel}ap_${OSVer}-${BuildVer}_3a88b7c3802f2f0510abc432104a15ebd8bd7154.shsh*
$tsschecker $ExtraArgs $tsschecker $ExtraArgs
@ -41,7 +41,7 @@ SaveOTABlobs() {
"It is also possible that $OSVer for $ProductType is no longer signed" "It is also possible that $OSVer for $ProductType is no longer signed"
elif [[ ! -e $SHSH ]]; then elif [[ ! -e $SHSH ]]; then
Log "Saving $OSVer blobs failed, but found existing saved SHSH blobs. Continuing..." Log "Saving $OSVer blobs failed, but found existing saved SHSH blobs."
cp $SHSHExisting . cp $SHSHExisting .
SHSH=$(ls $SHSHChk) SHSH=$(ls $SHSHChk)
SHSHContinue=1 SHSHContinue=1

View File

@ -44,11 +44,12 @@ SetToolPaths() {
ideviceenterrecovery="$MPath/ideviceenterrecovery" ideviceenterrecovery="$MPath/ideviceenterrecovery"
ideviceinfo="$MPath/ideviceinfo" ideviceinfo="$MPath/ideviceinfo"
iproxy="$MPath/iproxy" iproxy="$MPath/iproxy"
ipsw="./tools/ipsw_$platform" ipsw="../resources/tools/ipsw_$platform"
ipwndfu="$python ipwndfu" ipwndfu="$python ipwndfu"
irecoverychk="$MPath/irecovery" irecoverychk="$MPath/irecovery"
irecovery="$irecoverychk" irecovery="$irecoverychk"
partialzip="./resources/tools/partialzip_$platform" partialzip="./resources/tools/partialzip_$platform"
ping="ping -c1"
rmsigchks="$python rmsigchks.py" rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888" SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
SSH="-F ./resources/ssh_config" SSH="-F ./resources/ssh_config"
@ -78,7 +79,6 @@ SetToolPaths() {
SaveExternal() { SaveExternal() {
local ExternalURL="https://github.com/$1/$2.git" local ExternalURL="https://github.com/$1/$2.git"
local External=$2 local External=$2
[[ $2 == "iOS-OTA-Downgrader-Keys" ]] && External="firmware"
cd resources cd resources
if [[ ! -d $External || ! -d $External/.git ]]; then if [[ ! -d $External || ! -d $External/.git ]]; then
Log "Downloading $External..." Log "Downloading $External..."
@ -150,7 +150,7 @@ InstallDepends() {
elif [[ $platform == "macos" ]]; then elif [[ $platform == "macos" ]]; then
xcode-select --install xcode-select --install
libimobiledevice=("https://github.com/libimobiledevice-win32/imobiledevice-net/releases/download/v1.3.14/libimobiledevice.1.2.1-r1116-osx-x64.zip" "328e809dea350ae68fb644225bbf8469c0f0634b") 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 "* iOS-OTA-Downgrader provides a copy of libimobiledevice and libirecovery by default"
Echo "* In case that problems occur, try installing them from Homebrew" 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 "* The script will detect this automatically and will use the Homebrew versions of the tools"

View File

@ -5,8 +5,12 @@ FindDevice() {
local i=0 local i=0
local Timeout=999 local Timeout=999
local USB local USB
[[ $1 == "DFU" ]] && USB=1227 || USB=1281 if [[ $1 == "DFU" ]]; then
[[ -n $2 ]] && Timeout=3 USB=1227
elif [[ $1 == "Recovery" ]]; then
USB=1281
fi
[[ -n $2 ]] && Timeout=5
Log "Finding device in $1 mode..." Log "Finding device in $1 mode..."
while (( i < Timeout )); do while (( i < Timeout )); do
@ -92,7 +96,7 @@ GetDeviceValues() {
BasebandSHA1="e6f54acc5d5652d39a0ef9af5589681df39e0aca" BasebandSHA1="e6f54acc5d5652d39a0ef9af5589681df39e0aca"
LatestVer="9.3.5" LatestVer="9.3.5"
elif [[ $ProductType == "iPad2,3" ]]; then elif [[ $ProductType == "iPad2,3" || $ProductType == "iPhone3,3" ]]; then
Baseband="Phoenix-3.6.03.Release.bbfw" Baseband="Phoenix-3.6.03.Release.bbfw"
BasebandSHA1="8d4efb2214344ea8e7c9305392068ab0a7168ba4" BasebandSHA1="8d4efb2214344ea8e7c9305392068ab0a7168ba4"
@ -114,22 +118,34 @@ GetDeviceValues() {
Baseband="Mav5-11.80.00.Release.bbfw" Baseband="Mav5-11.80.00.Release.bbfw"
BasebandSHA1="8951cf09f16029c5c0533e951eb4c06609d0ba7f" BasebandSHA1="8951cf09f16029c5c0533e951eb4c06609d0ba7f"
LatestVer="10.3.4" LatestVer="10.3.4"
elif [[ $ProductType == "iPad4,2" || $ProductType == "iPad4,3" || $ProductType == "iPad4,5" || elif [[ $ProductType == "iPad4,2" || $ProductType == "iPad4,3" || $ProductType == "iPad4,5" ||
$ProductType == "iPhone6,1" || $ProductType == "iPhone6,2" || $ProductType == "iPhone5"* || $ProductType == "iPhone6"* ]]; then
$ProductType == "iPhone5,3" || $ProductType == "iPhone5,4" ]]; then
BasebandURL=$(cat $Firmware/14G60/url) BasebandURL=$(cat $Firmware/14G60/url)
Baseband="Mav7Mav8-7.60.00.Release.bbfw" Baseband="Mav7Mav8-7.60.00.Release.bbfw"
BasebandSHA1="f397724367f6bed459cf8f3d523553c13e8ae12c" BasebandSHA1="f397724367f6bed459cf8f3d523553c13e8ae12c"
if [[ $ProductType == "iPhone5"* ]]; then
elif [[ $ProductType != "iPad2"* && $ProductType != "iPad3"* && $ProductType != "iPad4,1" && Log "iPhone 5C detected. Your device does not support OTA downgrades."
$ProductType != "iPad4,4" && $ProductType != "iPod5,1" ]]; then Echo "* Functions will be limited to entering kDFU and restoring with blobs."
Error "Your device $ProductType ${version}is not supported." fi
else
elif [[ $ProductType == "iPhone3"* ]]; then
BasebandURL=$(cat $Firmware/11D257/url)
Baseband="ICE3_04.12.09_BOOT_02.13.Release.bbfw"
BasebandSHA1="007365a5655ac2f9fbd1e5b6dba8f4be0513e364"
elif [[ $ProductType == "iPad2"* || $ProductType == "iPad3"* || $ProductType == "iPad4,1" ||
$ProductType == "iPad4,4" || $ProductType == "iPod5,1" ]]; then
BasebandURL=0 BasebandURL=0
else
Error "Your device $ProductType ${version}is not supported."
fi fi
if [[ $ProductType == "iPad2"* || $ProductType == "iPad3,1" || $ProductType == "iPad3,2" || if [[ $ProductType == "iPhone3"* ]]; then
DeviceProc=4
Log "$ProductType detected. Your device does not support OTA downgrades."
Echo "* Functions will be limited to entering kDFU and restoring with blobs."
elif [[ $ProductType == "iPad2"* || $ProductType == "iPad3,1" || $ProductType == "iPad3,2" ||
$ProductType == "iPad3,3" || $ProductType == "iPhone4,1" || $ProductType == "iPod5,1" ]]; then $ProductType == "iPad3,3" || $ProductType == "iPhone4,1" || $ProductType == "iPod5,1" ]]; then
DeviceProc=5 DeviceProc=5
elif [[ $ProductType == "iPhone5"* || $ProductType == "iPad3"* ]]; then elif [[ $ProductType == "iPhone5"* || $ProductType == "iPad3"* ]]; then
@ -148,7 +164,7 @@ GetDeviceValues() {
if [[ $ProductType == "iPod5,1" ]]; then if [[ $ProductType == "iPod5,1" ]]; then
iBSS="${HWModel}ap" iBSS="${HWModel}ap"
iBSSBuildVer="10B329" iBSSBuildVer="10B329"
elif [[ $ProductType == "iPad3,1" ]]; then elif [[ $ProductType == "iPad3,1" || $ProductType == "iPhone3"* ]]; then
iBSS="${HWModel}ap" iBSS="${HWModel}ap"
iBSSBuildVer="11D257" iBSSBuildVer="11D257"
elif [[ $ProductType == "iPhone6"* ]]; then elif [[ $ProductType == "iPhone6"* ]]; then
@ -169,23 +185,22 @@ GetDeviceValues() {
Log "ECID: $UniqueChipID" Log "ECID: $UniqueChipID"
} }
CheckM8() { EnterPwnDFU() {
local pwnDFUTool local pwnDFUTool
local pwnDFUDevice local pwnDFUDevice
local pwnD=1 local pwnD=1
if [[ $platform == "macos" ]]; then if [[ $platform == "macos" ]]; then
Selection=("iPwnder32" "ipwnder_lite") Selection=("ipwnder_lite" "iPwnder32")
Input "PwnDFU Tool Option" Input "PwnDFU Tool Option"
Echo "* This option selects what tool to use to put your device in pwnDFU mode." Echo "* This option selects what tool to use to put your device in pwnDFU mode."
Echo "* If unsure, select 1 for Intel Macs, select 2 for Apple Silicon (M1) Macs." Echo "* If unsure, select 1. Select 2 if 1 does not work."
Echo "* This option is set to iPwnder32 by default (1)." Echo "* This option is set to ${Selection[0]} by default (1)."
Input "Select your option:" Input "Select your option:"
select opt in "${Selection[@]}"; do select opt in "${Selection[@]}"; do
case $opt in case $opt in
"ipwnder_lite" ) pwnDFUTool="$ipwnder_lite"; break;; "ipwnder_lite" ) pwnDFUTool="$ipwnder_lite"; break;;
"ipwndfu" ) pwnDFUTool="ipwndfu"; break;; "iPwnder32" ) pwnDFUTool="$ipwnder32"; break;;
* ) pwnDFUTool="$ipwnder32"; break;;
esac esac
done done
else else
@ -197,21 +212,21 @@ CheckM8() {
cd resources/ipwndfu cd resources/ipwndfu
Echo "* Enter your user password when prompted" Echo "* Enter your user password when prompted"
$ipwndfu -p $ipwndfu -p
if [[ $DeviceProc == 7 ]]; then pwnDFUDevice=$?
if [[ $DeviceProc == 7 ]]; then
Log "Running rmsigchks.py..." Log "Running rmsigchks.py..."
$rmsigchks $rmsigchks
pwnDFUDevice=$? pwnDFUDevice=$?
cd ../..
else else
cd ../.. SendiBSS=1
kDFU iBSS || echo
pwnDFUDevice=$?
fi fi
cd ../..
else else
$pwnDFUTool -p $pwnDFUTool -p
pwnDFUDevice=$? pwnDFUDevice=$?
fi fi
[[ $DeviceProc == 7 ]] && pwnD=$($irecovery -q | grep -c "PWND") [[ $DeviceProc == 7 ]] && pwnD=$($irecovery -q | grep -c "PWND")
[[ $DeviceProc == 4 ]] && SendiBSS=1
if [[ $pwnDFUDevice != 0 && $pwnD != 1 ]]; then if [[ $pwnDFUDevice != 0 && $pwnD != 1 ]]; then
echo -e "\n${Color_R}[Error] Failed to enter pwnDFU mode. Please run the script again ${Color_N}" echo -e "\n${Color_R}[Error] Failed to enter pwnDFU mode. Please run the script again ${Color_N}"
@ -246,8 +261,8 @@ Recovery() {
exit 0 exit 0
fi fi
Echo "* Hold TOP and HOME buttons for 8 seconds." Echo "* Hold TOP and HOME buttons for 10 seconds."
for i in {08..01}; do for i in {10..01}; do
echo -n "$i " echo -n "$i "
sleep 1 sleep 1
done done
@ -259,7 +274,7 @@ Recovery() {
echo echo
FindDevice "DFU" error FindDevice "DFU" error
CheckM8 EnterPwnDFU
} }
RecoveryExit() { RecoveryExit() {
@ -275,6 +290,17 @@ kDFU() {
local kloader local kloader
local VerDetect=$(echo $ProductVer | cut -c 1) local VerDetect=$(echo $ProductVer | cut -c 1)
if [[ $DeviceState != "Normal" ]]; then
Log "Device is already in $DeviceState mode"
return
fi
if [[ $iBSSBuildVer == $BuildVer && -e "$IPSW.ipsw" ]]; then
Log "Extracting iBSS from IPSW..."
mkdir -p saved/$ProductType 2>/dev/null
unzip -o -j $IPSW.ipsw Firmware/dfu/$iBSS.dfu -d saved/$ProductType
fi
if [[ ! -e saved/$ProductType/$iBSS.dfu ]]; then if [[ ! -e saved/$ProductType/$iBSS.dfu ]]; then
Log "Downloading iBSS..." Log "Downloading iBSS..."
$partialzip "$(cat $Firmware/$iBSSBuildVer/url)" Firmware/dfu/$iBSS.dfu $iBSS.dfu $partialzip "$(cat $Firmware/$iBSSBuildVer/url)" Firmware/dfu/$iBSS.dfu $iBSS.dfu
@ -288,22 +314,7 @@ kDFU() {
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
cd resources/ipwndfu
if [[ $platform == "macos" ]]; then
Echo "* Attempting to send pwned iBSS."
Echo "* This will fail on Apple Silicon Macs, as well as on macOS 12.3 and later."
Echo "* If this is the case, you need to send pwned iBSS yourself before continuing."
Echo "* For more details, read the \"Troubleshooting\" wiki page in GitHub"
fi
Log "Sending iBSS..."
$ipwndfu -l ../../tmp/pwnediBSS
local ret=$?
cd ../..
return $ret
fi
[[ $VerDetect == 1 ]] && kloader="kloader_hgsp" [[ $VerDetect == 1 ]] && kloader="kloader_hgsp"
[[ $VerDetect == 5 ]] && kloader="kloader5" [[ $VerDetect == 5 ]] && kloader="kloader5"
[[ ! $kloader ]] && kloader="kloader" [[ ! $kloader ]] && kloader="kloader"

View File

@ -32,91 +32,8 @@ FRBaseband() {
fi fi
} }
Downgrade() { FutureRestore() {
local ExtraArgs=("--use-pwndfu") local ExtraArgs=("--use-pwndfu")
local IPSWExtract
Verify=1
Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)."
echo
if [[ $OSVer == "Other" ]]; then
Input "Select your IPSW file in the file selection window."
IPSW="$($zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select IPSW file")"
[[ ! -s "$IPSW" ]] && Error "No IPSW selected, or IPSW file not found."
IPSW="${IPSW%?????}"
Log "Selected IPSW file: $IPSW.ipsw"
Input "Select your SHSH file in the file selection window."
SHSH="$($zenity --file-selection --file-filter='SHSH | *.shsh *.shsh2' --title="Select SHSH file")"
[[ ! -s "$SHSH" ]] && Error "No SHSH selected, or SHSH file not found."
Log "Selected SHSH file: $SHSH"
unzip -o -j "$IPSW.ipsw" Restore.plist -d tmp
BuildVer=$(cat tmp/Restore.plist | grep -i ProductBuildVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
Log "Getting firmware keys for $ProductType-$BuildVer"
mkdir resources/firmware/$ProductType/$BuildVer 2>/dev/null
curl -L https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/raw/master/$ProductType/$BuildVer/index.html -o tmp/index.html
mv tmp/index.html resources/firmware/$ProductType/$BuildVer
elif [[ $DeviceProc != 7 ]]; then
Input "Jailbreak Option"
Echo "* When this option is enabled, your device will be jailbroken on restore."
if [[ $ProductType == "iPad2,5" || $ProductType == "iPad2,6" || $ProductType == "iPad2,7" ]]; then
Echo "* Based on some reported issues, Jailbreak Option might be broken for iPad mini 1 devices."
Echo "* I recommend to disable the option for these devices and sideload EtasonJB, HomeDepot, or daibutsu manually."
fi
Echo "* This option is enabled by default (Y)."
read -p "$(Input 'Enable this option? (Y/n):')" Jailbreak
if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then
JailbreakSet
Log "Jailbreak option enabled."
else
Log "Jailbreak option disabled by user."
fi
echo
fi
if [[ $OSVer != "Other" ]]; then
[[ -z $IPSWCustom ]] && IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
MemoryOption
SaveOTABlobs
IPSWFind
if [[ $Verify == 1 ]]; then
IPSWVerify
elif [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Found existing Custom IPSW. Skipping IPSW verification."
Log "Setting restore IPSW to: $IPSWCustom.ipsw"
IPSWRestore=$IPSWCustom
fi
if [[ $DeviceState == "Normal" && $iBSSBuildVer == $BuildVer && -e "$IPSW.ipsw" ]]; then
Log "Extracting iBSS from IPSW..."
mkdir -p saved/$ProductType 2>/dev/null
unzip -o -j $IPSW.ipsw Firmware/dfu/$iBSS.dfu -d saved/$ProductType
fi
else
IPSWCustom=0
fi
[[ $DeviceState == "Normal" ]] && kDFU
if [[ $Jailbreak == 1 ]]; then
IPSW32
IPSWExtract="$IPSWCustom"
else
IPSWExtract="$IPSW"
fi
Log "Extracting IPSW: $IPSWExtract.ipsw"
unzip -oq "$IPSWExtract.ipsw" -d "$IPSWExtract"/
if [[ ! $IPSWRestore ]]; then
Log "Setting restore IPSW to: $IPSW.ipsw"
IPSWRestore="$IPSW"
fi
Log "Proceeding to futurerestore..." Log "Proceeding to futurerestore..."
[[ $platform == "linux" ]] && Echo "* Enter your user password when prompted" [[ $platform == "linux" ]] && Echo "* Enter your user password when prompted"
@ -130,7 +47,7 @@ Downgrade() {
$irecovery -f README.md $irecovery -f README.md
sleep 2 sleep 2
ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest") ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest")
else elif [[ $SendiBSS != 1 ]]; then
ExtraArgs+=("--no-ibss") ExtraArgs+=("--no-ibss")
fi fi
@ -159,3 +76,48 @@ Downgrade() {
fi fi
Log "Downgrade script done!" Log "Downgrade script done!"
} }
DowngradeOther() {
Input "Select your IPSW file in the file selection window."
IPSW="$($zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select IPSW file")"
[[ ! -s "$IPSW" ]] && Error "No IPSW selected, or IPSW file not found."
IPSW="${IPSW%?????}"
Log "Selected IPSW file: $IPSW.ipsw"
Input "Select your SHSH file in the file selection window."
SHSH="$($zenity --file-selection --file-filter='SHSH | *.shsh *.shsh2' --title="Select SHSH file")"
[[ ! -s "$SHSH" ]] && Error "No SHSH selected, or SHSH file not found."
Log "Selected SHSH file: $SHSH"
if [[ ! -e resources/firmware/$ProductType/$BuildVer/index.html ]]; then
unzip -o -j "$IPSW.ipsw" Restore.plist -d tmp
BuildVer=$(cat tmp/Restore.plist | grep -i ProductBuildVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
Log "Getting firmware keys for $ProductType-$BuildVer"
mkdir -p resources/firmware/$ProductType/$BuildVer 2>/dev/null
curl -L https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/raw/master/$ProductType/$BuildVer/index.html -o tmp/index.html
mv tmp/index.html resources/firmware/$ProductType/$BuildVer
fi
kDFU
IPSWSetExtract
FutureRestore
}
DowngradeOTA() {
[[ $DeviceProc != 7 ]] && JailbreakOption
SaveOTABlobs
IPSWFindVerify
kDFU
[[ $Jailbreak == 1 ]] && IPSW32
IPSWSetExtract
FutureRestore
}
Downgrade() {
Log "Select your options when asked. If unsure, go for the defaults (press Enter/Return)."
echo
if [[ $OSVer == "Other" ]]; then
DowngradeOther
return
fi
DowngradeOTA
}

View File

@ -0,0 +1 @@
http://appldnld.apple.com/iOS7.1/031-4812.20140627.cq6y8/iPhone3,1_7.1.2_11D257_Restore.ipsw

View File

@ -0,0 +1 @@
n90

View File

@ -0,0 +1 @@
http://appldnld.apple.com/iOS7.1/031-4785.20140627.zZ42j/iPhone3,2_7.1.2_11D257_Restore.ipsw

View File

@ -0,0 +1 @@
n90b

View File

@ -0,0 +1 @@
http://appldnld.apple.com/iOS7.1/031-4768.20140627.DXmmp/iPhone3,3_7.1.2_11D257_Restore.ipsw

View File

@ -0,0 +1 @@
http://updates-http.cdn-apple.com/2019/ios/041-80042-20190722-68F07B91-8EA1-4A3B-A930-35314A006ECB/iPad2,3_9.3.6_13G37_Restore.ipsw

View File

@ -0,0 +1 @@
n92

View File

@ -3,7 +3,6 @@
JailbreakSet() { JailbreakSet() {
Jailbreak=1 Jailbreak=1
IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom" IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
[[ -e "$IPSWCustom.ipsw" ]] && Verify=
if [[ $ProductType == "iPhone4,1" || $ProductType == "iPhone5,2" ]] && [[ $OSVer == "8.4.1" ]]; then if [[ $ProductType == "iPhone4,1" || $ProductType == "iPhone5,2" ]] && [[ $OSVer == "8.4.1" ]]; then
Input "Jailbreak Tool Option" Input "Jailbreak Tool Option"
@ -34,40 +33,68 @@ JailbreakSet() {
Log "Using $JBName for the jailbreak" Log "Using $JBName for the jailbreak"
} }
MemoryOption() { JailbreakOption() {
if [[ $Jailbreak == 1 && $Verify == 1 ]]; then Input "Jailbreak Option"
Input "Memory Option for creating custom IPSW" Echo "* When this option is enabled, your device will be jailbroken on restore."
Echo "* This option makes creating the custom IPSW faster, but it requires at least 8GB of RAM." if [[ $ProductType == "iPad2,5" || $ProductType == "iPad2,6" || $ProductType == "iPad2,7" ]]; then
Echo "* If you do not have enough RAM, disable this option and make sure that you have enough storage space." Echo "* Based on some reported issues, Jailbreak Option might be broken for iPad mini 1 devices."
Echo "* This option is enabled by default (Y)." Echo "* I recommend to disable the option for these devices and sideload EtasonJB, HomeDepot, or daibutsu manually."
read -p "$(Input 'Enable this option? (Y/n):')" JBMemory
if [[ $JBMemory == 'N' || $JBMemory == 'n' ]]; then
Log "Memory option disabled by user."
else
Log "Memory option enabled."
fi
echo
fi fi
Echo "* This option is enabled by default (Y)."
read -p "$(Input 'Enable this option? (Y/n):')" Jailbreak
if [[ $Jailbreak != 'N' && $Jailbreak != 'n' ]]; then
JailbreakSet
Log "Jailbreak option enabled."
else
Log "Jailbreak option disabled by user."
fi
[[ -z $IPSWCustom ]] && IPSWCustom="${IPSWType}_${OSVer}_${BuildVer}_Custom"
echo
if [[ $Jailbreak != 1 ]]; then
return
fi
Input "Memory Option for creating custom IPSW"
Echo "* This option makes creating the custom IPSW faster, but it requires at least 8GB of RAM."
Echo "* If you do not have enough RAM, disable this option and make sure that you have enough storage space."
Echo "* This option is enabled by default (Y)."
read -p "$(Input 'Enable this option? (Y/n):')" JBMemory
if [[ $JBMemory == 'N' || $JBMemory == 'n' ]]; then
Log "Memory option disabled by user."
JBMemory=
else
Log "Memory option enabled."
JBMemory="-memory"
fi
echo
} }
IPSWFind() { IPSWFindVerify() {
IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore" IPSW="${IPSWType}_${OSVer}_${BuildVer}_Restore"
if [[ ! -e "$IPSW.ipsw" && $Verify == 1 ]]; then local IPSWDL=$IPSW
Log "iOS $OSVer IPSW for $ProductType cannot be found." local OSVerDL=$OSVer
local BuildVerDL=$BuildVer
if [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Found existing Custom IPSW. Skipping $OSVerDL IPSW verification."
return
fi
if [[ ! -e "$IPSW.ipsw" ]]; then
Log "iOS $OSVerDL IPSW for $ProductType cannot be found."
Echo "* If you already downloaded the IPSW, move/copy it to the directory where the script is located." Echo "* If you already downloaded the IPSW, move/copy it to the directory where the script is located."
Echo "* Do NOT rename the IPSW as the script will fail to detect it." Echo "* Do NOT rename the IPSW as the script will fail to detect it."
Echo "* The script will now proceed to download it for you. If you want to download it yourself, here is the link: $(cat $Firmware/$BuildVer/url)" Echo "* The script will now proceed to download it for you. If you want to download it yourself, here is the link: $(cat $Firmware/$BuildVerDL/url)"
Log "Downloading IPSW... (Press Ctrl+C to cancel)" Log "Downloading IPSW... (Press Ctrl+C to cancel)"
curl -L $(cat $Firmware/$BuildVer/url) -o tmp/$IPSW.ipsw curl -L $(cat $Firmware/$BuildVerDL/url) -o tmp/$IPSWDL.ipsw
mv tmp/$IPSW.ipsw . mv tmp/$IPSWDL.ipsw .
fi fi
}
IPSWVerify() { Log "Verifying $IPSWDL.ipsw..."
Log "Verifying IPSW..." IPSWSHA1=$(cat $Firmware/$BuildVerDL/sha1sum)
IPSWSHA1=$(cat $Firmware/$BuildVer/sha1sum)
Log "Expected SHA1sum: $IPSWSHA1" Log "Expected SHA1sum: $IPSWSHA1"
IPSWSHA1L=$(shasum $IPSW.ipsw | awk '{print $1}') IPSWSHA1L=$(shasum $IPSWDL.ipsw | awk '{print $1}')
Log "Actual SHA1sum: $IPSWSHA1L" Log "Actual SHA1sum: $IPSWSHA1L"
if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then if [[ $IPSWSHA1L != $IPSWSHA1 ]]; then
Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \ Error "Verifying IPSW failed. Your IPSW may be corrupted or incomplete. Delete/replace the IPSW and run the script again" \
@ -76,13 +103,27 @@ IPSWVerify() {
Log "IPSW SHA1sum matches." Log "IPSW SHA1sum matches."
} }
IPSWSetExtract() {
if [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Setting restore IPSW to: $IPSWCustom.ipsw"
IPSWRestore="$IPSWCustom"
elif [[ -z $IPSWRestore ]]; then
Log "Setting restore IPSW to: $IPSW.ipsw"
IPSWRestore="$IPSW"
fi
Log "Extracting IPSW: $IPSWRestore.ipsw"
unzip -oq "$IPSWRestore.ipsw" -d "$IPSWRestore"/
}
IPSW32() { IPSW32() {
local Bundle="Down_${ProductType}_${OSVer}_${BuildVer}.bundle" local Bundle="Down_${ProductType}_${OSVer}_${BuildVer}.bundle"
local ExtraArgs local ExtraArgs
local JBFiles local JBFiles
local JBFiles2
local JBSHA1 local JBSHA1
if [[ $IPSWRestore == $IPSWCustom ]]; then if [[ -e $IPSWCustom.ipsw ]]; then
Log "Found existing Custom IPSW. Skipping IPSW creation." Log "Found existing Custom IPSW. Skipping IPSW creation."
return return
fi fi
@ -96,6 +137,7 @@ IPSW32() {
JBFiles2=("bin.tar" "cydia.tar" "untether.tar") JBFiles2=("bin.tar" "cydia.tar" "untether.tar")
JBSHA1=("98034227c68610f4c7dd48ca9e622314a1e649e7" "2e9e662afe890e50ccf06d05429ca12ce2c0a3a3" "f88ec9a1b3011c4065733249363e9850af5f57c8") JBSHA1=("98034227c68610f4c7dd48ca9e622314a1e649e7" "2e9e662afe890e50ccf06d05429ca12ce2c0a3a3" "f88ec9a1b3011c4065733249363e9850af5f57c8")
cd tmp cd tmp
mkdir jailbreak
for i in {0..2}; do for i in {0..2}; do
local URL="https://github.com/dora2-iOS/daibutsuCFW/raw/main/build/src/" local URL="https://github.com/dora2-iOS/daibutsuCFW/raw/main/build/src/"
(( i > 0 )) && URL+="daibutsu/${JBFiles2[$i]}" || URL+="${JBFiles2[$i]}" (( i > 0 )) && URL+="daibutsu/${JBFiles2[$i]}" || URL+="${JBFiles2[$i]}"
@ -104,7 +146,7 @@ IPSW32() {
SaveFile $URL ${JBFiles2[$i]} ${JBSHA1[$i]} SaveFile $URL ${JBFiles2[$i]} ${JBSHA1[$i]}
mv ${JBFiles2[$i]} ../resources/jailbreak mv ${JBFiles2[$i]} ../resources/jailbreak
fi fi
JBFiles2[$i]=jailbreak/${JBFiles2[$i]} cp ../resources/jailbreak/${JBFiles2[$i]} jailbreak/
done done
cd .. cd ..
@ -112,13 +154,11 @@ IPSW32() {
if [[ $OSVer == "8.4.1" ]]; then if [[ $OSVer == "8.4.1" ]]; then
JBFiles=("fstab.tar" "etasonJB-untether.tar" "Cydia8.tar") JBFiles=("fstab.tar" "etasonJB-untether.tar" "Cydia8.tar")
JBSHA1="6459dbcbfe871056e6244d23b33c9b99aaeca970" JBSHA1="6459dbcbfe871056e6244d23b33c9b99aaeca970"
ExtraArgs+="-s 2305 " ExtraArgs+="-s 2305"
elif [[ $OSVer == "6.1.3" ]]; then elif [[ $OSVer == "6.1.3" ]]; then
JBFiles=("fstab_rw.tar" "p0sixspwn.tar" "Cydia6.tar") JBFiles=("fstab_rw.tar" "p0sixspwn.tar" "Cydia6.tar")
JBSHA1="1d5a351016d2546aa9558bc86ce39186054dc281" JBSHA1="1d5a351016d2546aa9558bc86ce39186054dc281"
ExtraArgs+="-s 1260 " ExtraArgs+="-s 1260"
else
Error "No OSVer selected?"
fi fi
if [[ ! -e resources/jailbreak/${JBFiles[2]} ]]; then if [[ ! -e resources/jailbreak/${JBFiles[2]} ]]; then
cd tmp cd tmp
@ -128,29 +168,25 @@ IPSW32() {
cd .. cd ..
fi fi
for i in {0..2}; do for i in {0..2}; do
JBFiles[$i]=jailbreak/${JBFiles[$i]} JBFiles[$i]=../resources/jailbreak/${JBFiles[$i]}
done done
fi fi
ExtraArgs+="-bbupdate" ExtraArgs+="-bbupdate"
if [[ ! -e $IPSWCustom.ipsw ]]; then if [[ ! -e $IPSWCustom.ipsw ]]; then
[[ $JBMemory != 'N' && $JBMemory != 'n' ]] && ExtraArgs+=" -memory"
Log "Preparing custom IPSW..." Log "Preparing custom IPSW..."
cd resources cd tmp
rm -rf FirmwareBundles if [[ $JBDaibutsu == 1 ]]; then
if [[ $JBDaibutsu == 1 && -d firmware/JailbreakBundles/$Bundle ]]; then cp -R ../resources/firmware/JailbreakBundles FirmwareBundles
cp -R firmware/JailbreakBundles FirmwareBundles
else else
cp -R firmware/FirmwareBundles FirmwareBundles cp -R ../resources/firmware/FirmwareBundles FirmwareBundles
fi fi
$ipsw ./../$IPSW.ipsw ./../$IPSWCustom.ipsw $ExtraArgs ${JBFiles[@]} $ipsw ./../$IPSW.ipsw ./../$IPSWCustom.ipsw $ExtraArgs $JBMemory ${JBFiles[@]}
cd .. cd ..
fi fi
if [[ ! -e $IPSWCustom.ipsw ]]; then if [[ ! -e $IPSWCustom.ipsw ]]; then
Error "Failed to find custom IPSW. Please run the script again" \ Error "Failed to find custom IPSW. Please run the script again" \
"You may try selecting N for memory option" "You may try selecting N for memory option"
fi fi
Log "Setting restore IPSW to: $IPSWCustom.ipsw"
IPSWRestore=$IPSWCustom
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -75,7 +75,7 @@ Main() {
fi fi
Log "Checking Internet connection..." Log "Checking Internet connection..."
ping -c1 8.8.8.8 >/dev/null $ping 8.8.8.8 >/dev/null
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
Error "Please check your Internet connection before proceeding." Error "Please check your Internet connection before proceeding."
fi fi
@ -106,11 +106,13 @@ Main() {
Mode="$1" Mode="$1"
else else
[[ $1 != "NoDevice" ]] && Selection+=("Downgrade Device") [[ $1 != "NoDevice" ]] && Selection+=("Downgrade Device")
Selection+=("Save OTA Blobs") [[ $DeviceProc != 4 ]] && Selection+=("Save OTA Blobs")
if [[ $DeviceProc != 7 ]]; then if [[ $DeviceProc != 7 ]]; then
Selection+=("Create Custom IPSW") [[ $DeviceProc != 4 ]] && Selection+=("Create Custom IPSW")
[[ $DeviceState == "Normal" ]] && Selection+=("Put Device in kDFU Mode") [[ $DeviceState == "Normal" ]] && Selection+=("Put Device in kDFU Mode")
fi fi
Selection+=("(Re-)Install Dependencies" "(Any other key to exit)") Selection+=("(Re-)Install Dependencies" "(Any other key to exit)")
Echo "*** Main Menu ***" Echo "*** Main Menu ***"
Input "Select an option:" Input "Select an option:"
@ -129,18 +131,18 @@ Main() {
SelectVersion SelectVersion
if [[ $Mode == "IPSW32" ]]; then if [[ $Mode == "IPSW32" ]]; then
Verify=1
echo echo
JailbreakSet JailbreakOption
MemoryOption if [[ -e "$IPSWCustom.ipsw" ]]; then
IPSWFind
if [[ $Verify == 1 ]]; then
IPSWVerify
elif [[ -e "$IPSWCustom.ipsw" ]]; then
Log "Found existing Custom IPSW, stopping here." Log "Found existing Custom IPSW, stopping here."
Echo "* If you want to re-create the custom IPSW, move/delete the existing one first." Echo "* If you want to re-create the custom IPSW, move/delete the existing one first."
exit 0 exit 0
elif [[ $Jailbreak != 1 ]]; then
Log "Creating custom IPSW is not needed for non-jailbroken restores on your device."
exit 0
fi fi
IPSWFindVerify
IPSW32 IPSW32
Log "Custom IPSW has been created: $IPSWCustom.ipsw" Log "Custom IPSW has been created: $IPSWCustom.ipsw"
Echo "* This custom IPSW has a jailbreak built in ($JBName)" Echo "* This custom IPSW has a jailbreak built in ($JBName)"
@ -161,9 +163,9 @@ Main() {
elif [[ $DeviceState == "Recovery" ]]; then elif [[ $DeviceState == "Recovery" ]]; then
Recovery Recovery
elif [[ $DeviceState == "DFU" ]]; then elif [[ $DeviceState == "DFU" ]]; then
CheckM8 EnterPwnDFU
fi fi
elif [[ $DeviceState == "DFU" ]]; then elif [[ $DeviceState == "DFU" ]]; then
if [[ $1 != "PwnedDevice" ]]; then if [[ $1 != "PwnedDevice" ]]; then
echo -e "\n${Color_R}[Error] 32-bit A${DeviceProc} device detected in DFU mode. ${Color_N}" echo -e "\n${Color_R}[Error] 32-bit A${DeviceProc} device detected in DFU mode. ${Color_N}"
@ -179,26 +181,25 @@ Main() {
Echo "* If you do not know what you are doing, EXIT NOW by pressing Ctrl+C and restart your device in normal mode." Echo "* If you do not know what you are doing, EXIT NOW by pressing Ctrl+C and restart your device in normal mode."
Input "Select the mode that your device is currently in:" Input "Select the mode that your device is currently in:"
Selection=("kDFU mode") Selection=("kDFU mode")
[[ $DeviceProc == 5 ]] && Selection+=("pwnDFU mode (A5)") [[ $DeviceProc == 5 ]] && Selection+=("pwnDFU mode (A5)") || Selection+=("DFU mode (A6)")
[[ $DeviceProc == 6 ]] && Selection+=("DFU mode (A6)")
Selection+=("Any other key to exit") Selection+=("Any other key to exit")
select opt in "${Selection[@]}"; do select opt in "${Selection[@]}"; do
case $opt in case $opt in
"kDFU mode" ) break;; "kDFU mode" ) break;;
"DFU mode (A6)" ) CheckM8; break;; "DFU mode (A6)" ) EnterPwnDFU; break;;
"pwnDFU mode (A5)" ) "pwnDFU mode (A5)" )
Echo "* Make sure that your device is in pwnDFU mode using an Arduino+USB Host Shield!"; Echo "* Make sure that your device is in pwnDFU mode using an Arduino+USB Host Shield!";
Echo "* This option will not work if your device is not in pwnDFU mode."; Echo "* This option will not work if your device is not in pwnDFU mode.";
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"; Input "Press Enter/Return to continue (or press Ctrl+C to cancel)";
read -s; read -s;
kDFU iBSS; break;; SendiBSS=1; break;;
* ) exit 0;; * ) exit 0;;
esac esac
done done
Log "Downgrading $ProductType in kDFU/pwnDFU mode..." Log "Downgrading $ProductType in kDFU/pwnDFU mode..."
elif [[ $DeviceState == "Recovery" ]]; then elif [[ $DeviceState == "Recovery" ]]; then
if [[ $DeviceProc == 6 ]]; then if [[ $DeviceProc == 4 || $DeviceProc == 6 ]]; then
Recovery Recovery
else else
Log "32-bit A${DeviceProc} device detected in recovery mode." Log "32-bit A${DeviceProc} device detected in recovery mode."
@ -222,7 +223,7 @@ SelectVersion() {
return return
fi fi
if [[ $ProductType == "iPhone5,3" || $ProductType == "iPhone5,4" ]]; then if [[ $ProductType == "iPhone5,3" || $ProductType == "iPhone5,4" || $ProductType == "iPhone3"* ]]; then
Selection=() Selection=()
else else
Selection=("iOS 8.4.1") Selection=("iOS 8.4.1")