Skip to content

Commit 1685fce

Browse files
committed
Better handling of baseband/activation dumping
also activate activation-records flag by default on all a5(x)/a6(x) devices
1 parent 3ffbb7d commit 1685fce

File tree

1 file changed

+60
-48
lines changed

1 file changed

+60
-48
lines changed

restore.sh

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,10 @@ device_get_info() {
15331533
if [[ $device_disable_bbupdate == 1 && $device_use_bb != 0 ]] && (( device_proc < 7 )); then
15341534
device_disable_bbupdate="$device_type"
15351535
fi
1536+
# enable activation records flag if device is a5(x)/a6(x)
1537+
if [[ $device_proc == 5 || $device_proc == 6 ]]; then
1538+
device_actrec=1
1539+
fi
15361540
# if latest vers is not set, copy use vers to latest
15371541
if [[ -z $device_latest_vers || -z $device_latest_build ]]; then
15381542
device_latest_vers=$device_use_vers
@@ -2983,11 +2987,9 @@ ipsw_prepare_jailbreak() {
29832987
if [[ $device_use_bb != 0 && $device_type != "$device_disable_bbupdate" ]]; then
29842988
ExtraArgs+=" -bbupdate"
29852989
elif [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
2986-
device_dump baseband
29872990
ExtraArgs+=" ../saved/$device_type/baseband-$device_ecid.tar"
29882991
fi
29892992
if [[ $device_actrec == 1 ]]; then
2990-
device_dump activation
29912993
ExtraArgs+=" ../saved/$device_type/activation-$device_ecid.tar"
29922994
fi
29932995
if [[ $1 == "iboot" ]]; then
@@ -3664,11 +3666,9 @@ ipsw_prepare_32bit() {
36643666
if [[ $device_use_bb != 0 && $device_type != "$device_disable_bbupdate" ]]; then
36653667
ExtraArgs+=" -bbupdate"
36663668
elif [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
3667-
device_dump baseband
36683669
ExtraArgs+=" ../saved/$device_type/baseband-$device_ecid.tar"
36693670
fi
36703671
if [[ $device_actrec == 1 ]]; then
3671-
device_dump activation
36723672
ExtraArgs+=" ../saved/$device_type/activation-$device_ecid.tar"
36733673
fi
36743674

@@ -4467,7 +4467,6 @@ ipsw_prepare_ios4powder() {
44674467
ExtraArgs+=" -memory"
44684468
fi
44694469
if [[ $device_actrec == 1 ]]; then
4470-
device_dump activation
44714470
ExtraArgs+=" ../saved/$device_type/activation-$device_ecid.tar"
44724471
fi
44734472

@@ -4544,11 +4543,9 @@ ipsw_prepare_powder() {
45444543
if [[ $device_use_bb != 0 && $device_type != "$device_disable_bbupdate" ]]; then
45454544
ExtraArgs+=" -bbupdate"
45464545
elif [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
4547-
device_dump baseband
45484546
ExtraArgs+=" ../saved/$device_type/baseband-$device_ecid.tar"
45494547
fi
45504548
if [[ $device_actrec == 1 ]]; then
4551-
device_dump activation
45524549
ExtraArgs+=" ../saved/$device_type/activation-$device_ecid.tar"
45534550
fi
45544551

@@ -5312,6 +5309,12 @@ device_buttons2() {
53125309
}
53135310

53145311
restore_deviceprepare() {
5312+
if [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
5313+
device_dump baseband
5314+
fi
5315+
if [[ $device_actrec == 1 ]]; then
5316+
device_dump activation
5317+
fi
53155318
case $device_proc in
53165319
1 )
53175320
if [[ $device_target_vers == "4"* && $ipsw_jailbreak == 1 ]]; then
@@ -6368,7 +6371,6 @@ device_ramdisk() {
63686371
fstab="fstab_old" # disk0s2 data
63696372
fi
63706373
$scp -P $ssh_port $jelbrek/$fstab root@127.0.0.1:/mnt1/private/etc/fstab
6371-
$ssh -p $ssh_port root@127.0.0.1 "rm /mnt1/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist" # idk if this is really needed but ill keep it
63726374
;;
63736375
esac
63746376

@@ -7065,13 +7067,23 @@ menu_print_info() {
70657067
if [[ $device_unactivated == 1 ]]; then
70667068
print "* Device is not activated, select Attempt Activation to activate."
70677069
fi
7070+
if [[ $device_argmode == "none" ]]; then
7071+
if [[ $device_type == "$device_disable_bbupdate" || -n $device_deadbb ]]; then
7072+
warn "disable-bbupdate/dead-bb flag detected, but cannot be used in no-device mode."
7073+
device_disable_bbupdate=
7074+
device_deadbb=
7075+
fi
7076+
if [[ $device_actrec == 1 ]]; then
7077+
warn "Activation records flag detected, but cannot be used in no-device mode."
7078+
device_actrec=
7079+
fi
7080+
fi
70687081
if [[ $device_type == "$device_disable_bbupdate" && $device_use_bb != 0 ]] && (( device_proc < 7 )); then
7069-
warn "Disable bbupdate flag detected, baseband update is disabled. Proceed with caution"
7082+
warn "Disable bbupdate flag detected, baseband stitching enabled. Proceed with caution"
70707083
if [[ $device_deadbb == 1 ]]; then
70717084
warn "dead-bb flag detected, baseband dump/stitching is disabled. Your device will not activate after restore"
70727085
else
70737086
print "* Current device baseband will be dumped and stitched to custom IPSW"
7074-
print "* Stitching is supported in these restores/downgrades: 8.4.1/6.1.3, Other (tethered or with SHSH), powdersn0w"
70757087
warn "Note that stitching baseband does not always work! There is a chance of non-working baseband after the restore"
70767088
fi
70777089
elif [[ -n $device_disable_bbupdate ]]; then
@@ -7085,8 +7097,7 @@ menu_print_info() {
70857097
fi
70867098
if [[ $device_proc != 1 ]] && (( device_proc < 7 )); then
70877099
if [[ $device_actrec == 1 ]]; then
7088-
warn "Activation records flag detected. Proceed with caution"
7089-
print "* Stitching is supported in these restores/downgrades: 8.4.1/6.1.3, Other with SHSH, powdersn0w"
7100+
warn "Activation records flag detected. activation_record stitching enabled."
70907101
fi
70917102
if [[ $device_pwnrec == 1 ]]; then
70927103
warn "Pwned recovery flag detected. Assuming device is in pwned recovery mode."
@@ -8323,8 +8334,8 @@ ipsw_print_warnings() {
83238334
else
83248335
warn "Selected Target IPSW failed validation, proceed with caution"
83258336
fi
8326-
if [[ $device_target_vers == "9.3"* && $device_actrec == 1 ]]; then
8327-
warn "Activation records stitching does not work for iOS 9.3+ versions. Use iOS 9.2.1 or lower instead."
8337+
if [[ $device_target_vers == "9.3"* && $device_actrec == 1 && $device_target_vers != "$device_latest_vers" ]]; then
8338+
warn "Activation records stitching does not work for iOS 9.3+ versions, use iOS 9.2.1 or lower instead when possible."
83288339
fi
83298340
if [[ $1 == "powder" ]]; then
83308341
case $device_target_build in
@@ -9322,19 +9333,22 @@ device_dump() {
93229333
log "Dumping files for $arg: $dmps"
93239334
if [[ -s $dump ]]; then
93249335
log "Found existing dumped $arg: $dump"
9325-
print "* Select Y to overwrite, or N to use existing dump"
9326-
print "* Make sure to keep a backup of the dump if needed"
9327-
select_yesno "Overwrite this existing dump?" 0
9328-
if [[ $? != 1 ]]; then
9336+
if [[ $arg == "activation" && $(tar -tf $dump | grep -c "activation_record.plist") == 0 ]]; then
9337+
log "activation_record not found in existing activation dump. Deleting"
9338+
rm $dump
9339+
elif [[ $(tar -tf $dump | grep -c "bbticket.der") == 0 ]]; then
9340+
log "bbticket not found in existing baseband dump. Deleting"
9341+
rm $dump
9342+
else
93299343
return
93309344
fi
9331-
log "Deleting existing dumped $arg"
9332-
rm $dump
93339345
fi
9334-
if [[ $device_mode == "Recovery" ]]; then
9335-
device_enter_mode pwnDFU
9336-
elif [[ $device_mode == "Normal" ]]; then
9346+
if [[ $device_mode == "Normal" ]]; then
93379347
device_buttons2
9348+
else
9349+
log "Recovery/DFU mode device detected, entering pwnDFU mode to continue for SSH ramdisk."
9350+
print "* Note: If you can jailbreak and enter kDFU mode, exit now and proceed to do that instead."
9351+
device_enter_mode pwnDFU
93389352
fi
93399353
if [[ $device_mode == "Normal" ]]; then
93409354
device_ssh_message
@@ -9347,23 +9361,27 @@ device_dump() {
93479361
log "Copying $arg.tar"
93489362
$scp -P $ssh_port ${ssh_user}@127.0.0.1:/tmp/$arg.tar .
93499363
mv $arg.tar $arg-$device_ecid.tar
9364+
if [[ $(tar -tf activation-$device_ecid.tar | grep -c "activation_record.plist") != 0 ]]; then
9365+
cp activation-$device_ecid.tar $dump
9366+
else
9367+
warn "activation_record not found in tar. Will not save activation dump."
9368+
fi
93509369
else
93519370
device_dumpbb
9371+
if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
9372+
cp baseband-$device_ecid.tar $dump
9373+
else
9374+
warn "bbticket not found in tar. Will not save baseband dump."
9375+
fi
93529376
fi
9353-
cp $arg-$device_ecid.tar $dump
93549377
else
9355-
log "This operation requires an SSH ramdisk, proceeding"
9356-
print "* I recommend dumping baseband/activation on Normal mode instead of Recovery/DFU mode if possible"
93579378
device_enter_ramdisk $arg
93589379
device_dumprd
9359-
$ssh -p $ssh_port root@127.0.0.1 "nvram auto-boot=0; reboot_bak"
9360-
log "Done, device should reboot to recovery mode now"
9361-
log "Just exit recovery mode if needed: Main Menu -> Exit Recovery Mode"
9380+
$ssh -p $ssh_port root@127.0.0.1 "nvram auto-boot=1; reboot_bak"
9381+
log "Done, device should reboot now"
93629382
if [[ $mode != "baseband" && $mode != "actrec" ]]; then
9363-
log "Put your device back in kDFU/pwnDFU mode to proceed"
9364-
device_find_mode Recovery
9365-
device_enter_mode DFU
9366-
device_enter_mode pwnDFU
9383+
log "Put your device back in kDFU/pwnDFU mode to proceed, then run the script again."
9384+
exit
93679385
fi
93689386
fi
93699387
kill $iproxy_pid
@@ -9442,16 +9460,13 @@ device_dumprd() {
94429460
case $device_type in
94439461
iPhone[45]* | iPad2,[67] | iPad3,[56] )
94449462
log "Dumping both baseband and activation tars"
9445-
device_dumpbb rd
94469463
print "* Reminder to backup dump tars if needed"
9447-
if [[ -s $dump/baseband-$device_ecid.tar ]]; then
9448-
select_yesno "Baseband dump exists in $dump/baseband-$device_ecid.tar. Overwrite?" 0
9449-
if [[ $? == 1 ]]; then
9450-
log "Deleting existing dumped baseband"
9451-
rm $dump/baseband-$device_ecid.tar
9452-
fi
9464+
device_dumpbb rd
9465+
if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
9466+
cp baseband-$device_ecid.tar $dump
9467+
else
9468+
warn "bbticket not found in tar. Will not save baseband dump."
94539469
fi
9454-
cp baseband-$device_ecid.tar $dump
94559470
;;
94569471
esac
94579472

@@ -9475,14 +9490,11 @@ device_dumprd() {
94759490
"* If your device is on iOS 9 or newer, make sure to set the version of the SSH ramdisk correctly."
94769491
fi
94779492
mv activation.tar activation-$device_ecid.tar
9478-
if [[ -s $dump/activation-$device_ecid.tar ]]; then
9479-
select_yesno "Activation records dump exists in $dump/activation-$device_ecid.tar. Overwrite?" 0
9480-
if [[ $? == 1 ]]; then
9481-
log "Deleting existing dumped activation"
9482-
rm $dump/activation-$device_ecid.tar
9483-
fi
9493+
if [[ $(tar -tf activation-$device_ecid.tar | grep -c "activation_record.plist") != 0 ]]; then
9494+
cp activation-$device_ecid.tar $dump
9495+
else
9496+
warn "activation_record not found in tar. Will not save activation dump."
94849497
fi
9485-
cp activation-$device_ecid.tar $dump
94869498
$ssh -p $ssh_port root@127.0.0.1 "rm -f $tmp/*.tar"
94879499
}
94889500

0 commit comments

Comments
 (0)