Update restore.sh

This commit is contained in:
LukeZGD 2023-07-19 18:54:39 +08:00
parent 7b14c75a54
commit c075398587

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
device_disable_bbupdate="iPad2,3" # Disable baseband update for this device. You can also change this to your device if needed. ipsw_openssh=1 # OpenSSH will be added to jailbreak/custom IPSW if set to 1.
ipsw_openssh=1 # OpenSSH will be added to custom IPSW/jailbreak if set to 1.
device_ramdisk_build="" # You can change the version of SSH Ramdisk and Pwned iBSS/iBEC here. (default is 10B329 for most devices) device_ramdisk_build="" # You can change the version of SSH Ramdisk and Pwned iBSS/iBEC here. (default is 10B329 for most devices)
device_verbose_boot=0 # By setting this to 1 and changing the build version above, the SSH Ramdisk option turns to tethered verbose boot.
print() { print() {
echo "${color_B}${1}${color_N}" echo "${color_B}${1}${color_N}"
@ -72,7 +72,7 @@ List of options:
--no-device Enable no device mode --no-device Enable no device mode
--no-version-check Disable script version checking --no-version-check Disable script version checking
For devices compatible with powdersn0w and OTA restores (see README): For 32-bit devices compatible with restores/downgrades (see README):
--ipsw-verbose Enable verbose boot option (powdersn0w only) --ipsw-verbose Enable verbose boot option (powdersn0w only)
--jailbreak Enable jailbreak option --jailbreak Enable jailbreak option
--memory Enable memory option for creating IPSW --memory Enable memory option for creating IPSW
@ -2360,13 +2360,18 @@ restore_idevicerestore() {
print "* Windows users may encounter errors like \"Unable to send APTicket\" or \"Unable to send iBEC\" in the restore process." print "* Windows users may encounter errors like \"Unable to send APTicket\" or \"Unable to send iBEC\" in the restore process."
print "* Follow the troubleshoting link for steps to attempt fixing this issue." print "* Follow the troubleshoting link for steps to attempt fixing this issue."
print "* Troubleshooting link: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Troubleshooting#windows" print "* Troubleshooting link: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Troubleshooting#windows"
echo
fi fi
if [[ $device_target_vers == "4"* ]]; then if [[ $device_target_vers == "4"* ]]; then
print "* For device activation, go to: Other Utilities -> Attempt Activation" print "* For device activation, go to: Other Utilities -> Attempt Activation"
echo
fi fi
if [[ $opt != 0 ]]; then if [[ $opt != 0 ]]; then
print "* If you are getting the error \"could not retrieve device serial number\":" print "* If you are getting the error \"could not retrieve device serial number\":"
print " -> This means that your device is not compatible with $device_target_vers" print " -> This means that your device is not compatible with $device_target_vers"
print "* If the restore failed on updating baseband:"
print " -> Try disabling baseband update: ./restore.sh --disable-bbupdate"
echo
fi fi
print "* Please read the \"Troubleshooting\" wiki page in GitHub before opening any issue!" print "* Please read the \"Troubleshooting\" wiki page in GitHub before opening any issue!"
print "* Your problem may have already been addressed within the wiki page." print "* Your problem may have already been addressed within the wiki page."
@ -2709,6 +2714,7 @@ device_ramdisk() {
local path local path
local url local url
local decrypt local decrypt
local ramdisk_path
case $device_type in case $device_type in
iPod2,1 ) device_target_build="8C148";; iPod2,1 ) device_target_build="8C148";;
@ -2721,14 +2727,14 @@ device_ramdisk() {
if [[ -n $device_ramdisk_build ]]; then if [[ -n $device_ramdisk_build ]]; then
device_target_build=$device_ramdisk_build device_target_build=$device_ramdisk_build
fi fi
#local verbose_boot=1 ramdisk_path="../saved/$device_type/ramdisk_$device_target_build"
device_fw_key_check device_fw_key_check
url=$(cat "$device_fw_dir/$device_target_build/url" 2>/dev/null) url=$(cat "$device_fw_dir/$device_target_build/url" 2>/dev/null)
if [[ -z $url ]]; then if [[ -z $url ]]; then
log "Getting URL for $device_type-$device_target_build" log "Getting URL for $device_type-$device_target_build"
url=$(curl https://api.ipsw.me/v2.1/$device_type/$device_target_build/url) url=$(curl https://api.ipsw.me/v2.1/$device_type/$device_target_build/url)
fi fi
mkdir ../saved/$device_type/ramdisk 2>/dev/null mkdir $ramdisk_path 2>/dev/null
for getcomp in "${comps[@]}"; do for getcomp in "${comps[@]}"; do
name=$(echo $device_fw_key | $jq -j '.keys[] | select(.image | startswith("'$getcomp'")) | .filename') name=$(echo $device_fw_key | $jq -j '.keys[] | select(.image | startswith("'$getcomp'")) | .filename')
iv=$(echo $device_fw_key | $jq -j '.keys[] | select(.image | startswith("'$getcomp'")) | .iv') iv=$(echo $device_fw_key | $jq -j '.keys[] | select(.image | startswith("'$getcomp'")) | .iv')
@ -2740,11 +2746,11 @@ device_ramdisk() {
esac esac
log "$getcomp" log "$getcomp"
if [[ -e ../saved/$device_type/ramdisk/$name ]]; then if [[ -e $ramdisk_path/$name ]]; then
cp ../saved/$device_type/ramdisk/$name . cp $ramdisk_path/$name .
else else
"$dir/partialzip" "$url" "${path}$name" "$name" "$dir/partialzip" "$url" "${path}$name" "$name"
cp $name ../saved/$device_type/ramdisk/ cp $name $ramdisk_path/
fi fi
mv $name $getcomp.orig mv $name $getcomp.orig
if [[ $getcomp == "Kernelcache" && $device_type == "iPod2,1" ]]; then if [[ $getcomp == "Kernelcache" && $device_type == "iPod2,1" ]]; then
@ -2779,7 +2785,7 @@ device_ramdisk() {
"$dir/xpwntool" iBSS.patched iBSS -t iBSS.dec "$dir/xpwntool" iBSS.patched iBSS -t iBSS.dec
log "Patch iBEC" log "Patch iBEC"
"$dir/xpwntool" iBEC.dec iBEC.raw "$dir/xpwntool" iBEC.dec iBEC.raw
if [[ $verbose_boot == 1 ]]; then if [[ $device_verbose_boot == 1 ]]; then
"$dir/iBoot32Patcher" iBEC.raw iBEC.patched --rsa -b "-v" "$dir/iBoot32Patcher" iBEC.raw iBEC.patched --rsa -b "-v"
else else
"$dir/iBoot32Patcher" iBEC.raw iBEC.patched --rsa --debug -b "rd=md0 -v amfi=0xff cs_enforcement_disable=1" "$dir/iBoot32Patcher" iBEC.raw iBEC.patched --rsa --debug -b "rd=md0 -v amfi=0xff cs_enforcement_disable=1"
@ -2787,7 +2793,7 @@ device_ramdisk() {
"$dir/xpwntool" iBEC.patched iBEC -t iBEC.dec "$dir/xpwntool" iBEC.patched iBEC -t iBEC.dec
fi fi
mv iBSS iBEC AppleLogo.dec DeviceTree.dec Kernelcache.dec Ramdisk.dmg ../saved/$device_type/ramdisk 2>/dev/null mv iBSS iBEC AppleLogo.dec DeviceTree.dec Kernelcache.dec Ramdisk.dmg $ramdisk_path 2>/dev/null
if [[ $device_proc == 4 || $1 == "jailbreak" ]]; then if [[ $device_proc == 4 || $1 == "jailbreak" ]]; then
device_enter_mode pwnDFU device_enter_mode pwnDFU
@ -2795,22 +2801,22 @@ device_ramdisk() {
device_enter_mode kDFU device_enter_mode kDFU
fi fi
log "Sending iBSS..." log "Sending iBSS..."
$irecovery -f ../saved/$device_type/ramdisk/iBSS $irecovery -f $ramdisk_path/iBSS
if [[ $device_type != "iPod2,1" ]]; then if [[ $device_type != "iPod2,1" ]]; then
sleep 2 sleep 2
log "Sending iBEC..." log "Sending iBEC..."
$irecovery -f ../saved/$device_type/ramdisk/iBEC $irecovery -f $ramdisk_path/iBEC
fi fi
device_find_mode Recovery device_find_mode Recovery
log "Booting, please wait..." log "Booting, please wait..."
$irecovery -f ../saved/$device_type/ramdisk/DeviceTree.dec $irecovery -f $ramdisk_path/DeviceTree.dec
$irecovery -c devicetree $irecovery -c devicetree
if [[ $verbose_boot != 1 ]]; then if [[ $device_verbose_boot != 1 ]]; then
$irecovery -f ../saved/$device_type/ramdisk/Ramdisk.dmg $irecovery -f $ramdisk_path/Ramdisk.dmg
$irecovery -c ramdisk $irecovery -c ramdisk
fi fi
$irecovery -f ../saved/$device_type/ramdisk/Kernelcache.dec $irecovery -f $ramdisk_path/Kernelcache.dec
$irecovery -c bootx $irecovery -c bootx
sleep 20 sleep 20
@ -2858,7 +2864,8 @@ device_ramdisk() {
else else
cp activation.tar $dump cp activation.tar $dump
fi fi
$ssh -p 2222 root@127.0.0.1 "rm -f /mnt1/baseband.tar /mnt1/activation.tar; reboot_bak" $ssh -p 2222 root@127.0.0.1 "rm -f /mnt1/baseband.tar /mnt1/activation.tar; nvram auto-boot=0; reboot_bak"
log "Done, device should boot to recovery mode now"
return return
;; ;;
@ -2995,6 +3002,8 @@ device_ramdisk() {
print " mount.sh" print " mount.sh"
print "* Clear NVRAM with this command:" print "* Clear NVRAM with this command:"
print " nvram -c" print " nvram -c"
print "* Erase All Content and Settings with this command (iOS 9+ only):"
print " nvram oblit-inprogress=5"
print "* To reboot, use this command:" print "* To reboot, use this command:"
print " reboot_bak" print " reboot_bak"
} }
@ -3545,9 +3554,9 @@ ipsw_custom_set() {
ipsw_custom="../$1_Custom" ipsw_custom="../$1_Custom"
fi fi
# disable bbupdate for iphone 5 devices on other/powder # disable bbupdate for iphone 5 devices on other/powder
if [[ $device_type == "iPhone5"* ]] && [[ $device_target_other == 1 || $device_target_powder == 1 ]]; then #if [[ $device_type == "iPhone5"* ]] && [[ $device_target_other == 1 || $device_target_powder == 1 ]]; then
device_disable_bbupdate="$device_type" # device_disable_bbupdate="$device_type"
fi #fi
if [[ $device_type == "$device_disable_bbupdate" ]]; then if [[ $device_type == "$device_disable_bbupdate" ]]; then
device_use_bb=0 device_use_bb=0
ipsw_custom+="B" ipsw_custom+="B"
@ -3751,10 +3760,10 @@ device_dump() {
local dmps local dmps
if [[ -s $dump ]]; then if [[ -s $dump ]]; then
log "Found existing dumped $arg: $dump" log "Found existing dumped $arg: $dump"
print "* Select Y to use this, or N to delete and re-dump $arg" print "* Select Y to overwrite, or N to use existing dump"
print "* Make sure to keep a backup of the dump if needed" print "* Make sure to keep a backup of the dump if needed"
read -p "$(input 'Use this existing dump? (y/N) ')" opt read -p "$(input 'Overwrite this existing dump? (Y/n) ')" opt
if [[ $opt == 'Y' || $opt == 'y' ]]; then if [[ $opt == 'N' || $opt == 'n' ]]; then
return return
fi fi
log "Deleting existing dumped $arg" log "Deleting existing dumped $arg"
@ -3764,7 +3773,7 @@ device_dump() {
device_enter_mode pwnDFU device_enter_mode pwnDFU
fi fi
if [[ $device_mode == "Normal" ]]; then if [[ $device_mode == "Normal" ]]; then
print "* Make sure to have installed the requirements from Cydia." print "* Make sure to have installed the requirements from Cydia/Zebra."
print "* Only proceed if you have followed the steps in the GitHub wiki." print "* Only proceed if you have followed the steps in the GitHub wiki."
print "* You will be prompted to enter the root password of your iOS device." print "* You will be prompted to enter the root password of your iOS device."
print "* The default root password is \"alpine\"" print "* The default root password is \"alpine\""
@ -3784,6 +3793,7 @@ device_dump() {
cp $arg.tar $dump cp $arg.tar $dump
elif [[ $device_mode == "DFU" ]]; then elif [[ $device_mode == "DFU" ]]; then
device_ramdisk $arg device_ramdisk $arg
device_enter_mode pwnDFU
fi fi
kill $iproxy_pid kill $iproxy_pid
if [[ ! -e $dump ]]; then if [[ ! -e $dump ]]; then
@ -3792,11 +3802,16 @@ device_dump() {
log "Dumping $arg done: $dump" log "Dumping $arg done: $dump"
} }
device_activate() {
log "Attempting to activate device with ideviceactivation"
$ideviceactivation activate
}
restore_customipsw() { restore_customipsw() {
print "* You are about to restore with a custom IPSW." print "* You are about to restore with a custom IPSW."
print "* Note that this might only work on old bootrom devices." print "* Note that this might only work on old bootrom devices."
print "* Also note that Legacy iOS Kit does not support tethered booting." print "* Also note that Legacy iOS Kit does not support tethered booting."
print "* Legacy iOS Kit will not support tethered boots, downgrades, and jailbreaks." print "* Legacy iOS Kit will not support tethered downgrades and jailbreaks."
print "* Proceed with caution when restoring to custom IPSWs not made with Legacy iOS Kit." print "* Proceed with caution when restoring to custom IPSWs not made with Legacy iOS Kit."
if [[ $device_newbr == 1 ]]; then if [[ $device_newbr == 1 ]]; then
warn "Your device is a new bootrom model and custom IPSWs might not be compatible." warn "Your device is a new bootrom model and custom IPSWs might not be compatible."
@ -3851,7 +3866,6 @@ main() {
install_depends install_depends
fi fi
while [[ $mode != "exit" ]]; do
device_get_info device_get_info
mkdir -p ../saved/baseband ../saved/$device_type ../saved/shsh mkdir -p ../saved/baseband ../saved/$device_type ../saved/shsh
@ -3891,19 +3905,15 @@ main() {
"pwned-ibss" ) device_enter_mode pwnDFU;; "pwned-ibss" ) device_enter_mode pwnDFU;;
"save-onboard-blobs" ) shsh_save_onboard;; "save-onboard-blobs" ) shsh_save_onboard;;
"save-cydia-blobs" ) shsh_save_cydia;; "save-cydia-blobs" ) shsh_save_cydia;;
"activate" ) $ideviceactivation activate;; "activate" ) device_activate;;
"alloc8" ) device_alloc8;; "alloc8" ) device_alloc8;;
"jailbreak" ) device_jailbreakrd;; "jailbreak" ) device_jailbreakrd;;
"customipsw" ) restore_customipsw;; "customipsw" ) restore_customipsw;;
* ) :;; * ) :;;
esac esac
if [[ $mode != "exit" ]]; then
echo echo
print "* Save the terminal output now if needed." print "* Save the terminal output now if needed."
break
fi
done
echo echo
} }
@ -3941,10 +3951,6 @@ if [[ $no_color != 1 ]]; then
color_N=$(tput sgr0) color_N=$(tput sgr0)
fi fi
if [[ $device_disable_bbupdate != "iPad2,3" ]]; then
de_bbupdate=1
fi
main main
popd >/dev/null popd >/dev/null