Skip to content

Commit ee26363

Browse files
committed
Changes
1 parent d39578e commit ee26363

File tree

1 file changed

+74
-34
lines changed

1 file changed

+74
-34
lines changed

restore.sh

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ clean_usbmuxd() {
7272
if [[ $(ls "$(dirname "$0")" | grep -v tmp$$ | grep -c tmp) != 0 ]]; then
7373
return
7474
fi
75-
sudo killall usbmuxd usbmuxd2 2>/dev/null
75+
sudo killall -9 usbmuxd usbmuxd2 2>/dev/null
7676
if [[ $(command -v systemctl) ]]; then
77-
sleep 1
7877
sudo systemctl restart usbmuxd
78+
elif [[ $(command -v rc-service) ]]; then
79+
sudo rc-service usbmuxd start
7980
fi
8081
}
8182

@@ -98,6 +99,8 @@ List of options:
9899
--no-device Enable no device mode
99100
--no-version-check Disable script version checking
100101
--pwn Pwn the connected device
102+
--sshrd Enter SSH ramdisk mode (requires additional arguments)
103+
--sshrd-menu Re-enter SSH ramdisk menu (device must be in SSH ramdisk mode)
101104
102105
For 32-bit devices compatible with restores/downgrades (see README):
103106
--activation-records Enable dumping/stitching activation records
@@ -291,6 +294,10 @@ set_tool_paths() {
291294
if [[ $othertmp == 0 ]]; then
292295
if [[ $(command -v systemctl) ]]; then
293296
sudo systemctl stop usbmuxd
297+
elif [[ $(command -v rc-service) ]]; then
298+
sudo rc-service usbmuxd zap
299+
else
300+
sudo killall -9 usbmuxd
294301
fi
295302
#sudo killall usbmuxd 2>/dev/null
296303
#sleep 1
@@ -614,7 +621,7 @@ device_entry() {
614621
until [[ -n $device_type ]]; do
615622
read -p "$(input 'Enter device type (eg. iPad2,1): ')" device_type
616623
done
617-
if [[ $main_argmode == "device_justboot" ]]; then
624+
if [[ $main_argmode == "device_justboot" || $main_argmode == "device_enter_ramdisk"* ]]; then
618625
:
619626
elif [[ $device_type != "iPhone1"* && $device_type != "iPod1,1" ]]; then
620627
until [[ -n $device_ecid ]] && [ "$device_ecid" -eq "$device_ecid" ]; do
@@ -859,6 +866,9 @@ device_get_info() {
859866
log "No device mode is enabled."
860867
device_mode="none"
861868
device_vers="Unknown"
869+
elif [[ $main_argmode == "device_enter_ramdisk_menu" ]]; then
870+
log "sshrd-menu flag detected, assuming device is in SSH ramdisk mode"
871+
device_mode="Normal"
862872
else
863873
log "Finding device in Normal mode..."
864874
if [[ $platform == "linux" ]]; then
@@ -867,15 +877,14 @@ device_get_info() {
867877
print "* If it fails to detect devices, try to delete all \"tmp\" folders in your Legacy iOS Kit folder"
868878
fi
869879
fi
870-
fi
871-
872-
$ideviceinfo -s >/dev/null
873-
if [[ $? == 0 ]]; then
874-
device_mode="Normal"
875-
else
876-
$ideviceinfo >/dev/null
880+
$ideviceinfo -s >/dev/null
877881
if [[ $? == 0 ]]; then
878882
device_mode="Normal"
883+
else
884+
$ideviceinfo >/dev/null
885+
if [[ $? == 0 ]]; then
886+
device_mode="Normal"
887+
fi
879888
fi
880889
fi
881890

@@ -1319,10 +1328,10 @@ device_iproxy() {
13191328
port=$2
13201329
fi
13211330
if [[ $1 == "no-logging" && $debug_mode != 1 ]]; then
1322-
"$dir/iproxy" $ssh_port $port >/dev/null &
1331+
"$dir/iproxy" $ssh_port $port -s 127.0.0.1 >/dev/null &
13231332
iproxy_pid=$!
13241333
else
1325-
"$dir/iproxy" $ssh_port $port &
1334+
"$dir/iproxy" $ssh_port $port -s 127.0.0.1 &
13261335
iproxy_pid=$!
13271336
fi
13281337
log "iproxy PID: $iproxy_pid"
@@ -1766,7 +1775,14 @@ device_enter_mode() {
17661775
"ipwndfu" ) device_ipwndfu pwn; tool_pwned=$?; break;;
17671776
"ipwnder (SHAtter)" ) $ipwnder -s; tool_pwned=$?; break;;
17681777
"ipwnder (limera1n)" ) $ipwnder -p; tool_pwned=$?; break;;
1769-
"ipwnder" ) $ipwnder -d; tool_pwned=$?; break;;
1778+
"ipwnder" )
1779+
mkdir image3 ../saved/image3 2>/dev/null
1780+
cp ../saved/image3/* image3/ 2>/dev/null
1781+
$ipwnder -d
1782+
tool_pwned=$?
1783+
cp image3/* ../saved/image3/
1784+
break
1785+
;;
17701786
esac
17711787
done
17721788
elif [[ $platform == "linux" ]]; then
@@ -1776,8 +1792,11 @@ device_enter_mode() {
17761792
elif [[ $device_proc == 6 ]]; then
17771793
# A6 asi mac uses ipwnder_lite
17781794
log "Placing device to pwnDFU mode using ipwnder_lite"
1795+
mkdir image3 ../saved/image3 2>/dev/null
1796+
cp ../saved/image3/* image3/ 2>/dev/null
17791797
$ipwnder -d
17801798
tool_pwned=$?
1799+
cp image3/* ../saved/image3/
17811800
elif [[ $platform_arch == "arm64" ]]; then
17821801
# A7 asi mac uses ipwnder_lite
17831802
log "Placing device to pwnDFU mode using ipwnder_lite"
@@ -4044,7 +4063,7 @@ ipsw_prepare_multipatch() {
40444063
"$dir/hfsplus" RestoreRamdisk.dec grow 30000000
40454064

40464065
log "Patch ASR"
4047-
if [[ $ipsw_prepare_usepowder == 1 ]]; then
4066+
if [[ $ipsw_prepare_usepowder == 1 && $ipsw_gasgauge_patch != 1 ]]; then
40484067
rm -f asr
40494068
"$dir/hfsplus" ramdisk2.dec extract usr/sbin/asr
40504069
"$dir/hfsplus" RestoreRamdisk.dec rm usr/sbin/asr
@@ -5414,22 +5433,8 @@ device_ramdisk64() {
54145433
build_id="18C66"
54155434
fi
54165435

5417-
if [[ $1 == "jailbreak" ]]; then
5436+
if [[ $device_ramdisk_ios8 == 1 ]]; then
54185437
ios8=1
5419-
elif (( device_proc <= 8 )) && [[ $device_type != "iPad5,1" && $device_type != "iPad5,2" ]]; then
5420-
local ver="12"
5421-
if [[ $device_type == "iPad5"* ]]; then
5422-
ver="14"
5423-
fi
5424-
device_ramdiskver="$ver"
5425-
input "Version Select Option"
5426-
print "* The version of the SSH Ramdisk is set to iOS $ver by default. This is the recommended option."
5427-
print "* There is also an option to use iOS 8 ramdisk. This can be used to fix devices on iOS 7 not booting after using iOS $ver ramdisk."
5428-
print "* If not sure, just press Enter/Return. This will select the default version."
5429-
read -p "$(input "Select Y to use iOS $ver, select N to use iOS 8 (Y/n) ")" opt
5430-
if [[ $opt == 'n' || $opt == 'N' ]]; then
5431-
ios8=1
5432-
fi
54335438
fi
54345439

54355440
if [[ $ios8 == 1 ]]; then
@@ -9026,18 +9031,48 @@ device_justboot() {
90269031

90279032
device_enter_ramdisk() {
90289033
if (( device_proc >= 7 )); then
9029-
device_ramdisk64
9030-
return
9034+
if (( device_proc <= 8 )) && [[ $device_type != "iPad5,1" && $device_type != "iPad5,2" ]]; then
9035+
device_ramdiskver="12"
9036+
if [[ $device_type == "iPad5"* ]]; then
9037+
device_ramdiskver="14"
9038+
fi
9039+
local ver="$device_ramdiskver"
9040+
input "Version Select Option"
9041+
print "* The version of the SSH Ramdisk is set to iOS $ver by default. This is the recommended option."
9042+
print "* There is also an option to use iOS 8 ramdisk. This can be used to fix devices on iOS 7 not booting after using iOS $ver ramdisk."
9043+
print "* If not sure, just press Enter/Return. This will select the default version."
9044+
read -p "$(input "Select Y to use iOS $ver, select N to use iOS 8 (Y/n) ")" opt
9045+
if [[ $opt == 'n' || $opt == 'N' ]]; then
9046+
device_ramdisk_ios8=1
9047+
fi
9048+
fi
90319049
elif (( device_proc >= 5 )) && [[ $device_vers == "9"* || $device_vers == "10"* ]]; then
90329050
device_rd_build="13A452"
90339051
elif (( device_proc >= 5 )) && (( device_det <= 8 )) && [[ $device_mode == "Normal" ]]; then
90349052
:
9035-
elif (( device_proc >= 5 )); then
9053+
elif (( device_proc >= 5 )) && [[ -z $device_rd_build ]]; then
90369054
print "* To mount /var (/mnt2) for iOS 9-10, I recommend using 9.0.2 (13A452)."
90379055
print "* If not sure, just press Enter/Return. This will select the default version."
90389056
device_enter_build
90399057
fi
9040-
device_ramdisk $1
9058+
9059+
if [[ $1 == "menu" ]]; then
9060+
clear
9061+
device_iproxy
9062+
device_sshpass alpine
9063+
menu_ramdisk
9064+
return
9065+
fi
9066+
9067+
if (( device_proc >= 7 )); then
9068+
device_ramdisk64
9069+
else
9070+
device_ramdisk $1
9071+
fi
9072+
}
9073+
9074+
device_enter_ramdisk_menu() {
9075+
device_enter_ramdisk menu
90419076
}
90429077

90439078
device_ideviceinstaller() {
@@ -9296,9 +9331,9 @@ device_fourthree_check() {
92969331
}
92979332

92989333
device_backup_create() {
9299-
device_backup="../saved/backups/${device_ecid}_${device_type}/$(date +%Y-%m-%d-%H%M)"
93009334
print "* A backup of your device will be created using idevicebackup2. Please see the notes above."
93019335
pause
9336+
device_backup="../saved/backups/${device_ecid}_${device_type}/$(date +%Y-%m-%d-%H%M)"
93029337
mkdir -p $device_backup
93039338
pushd "$(dirname $device_backup)"
93049339
dir="../../$dir"
@@ -9516,6 +9551,11 @@ case $1 in
95169551
main_argmode="device_justboot"
95179552
;;
95189553
"--pwn" ) main_argmode="pwned-ibss";;
9554+
"--sshrd" ) main_argmode="device_enter_ramdisk";;
9555+
"--sshrd-menu" )
9556+
device_argmode="entry"
9557+
main_argmode="device_enter_ramdisk_menu"
9558+
;;
95199559
esac
95209560

95219561
trap "clean" EXIT

0 commit comments

Comments
 (0)