@@ -1135,10 +1135,6 @@ device_manufacturing() {
11351135 case $device_type in
11361136 iPhone4,1 | iPhone5,2 | iPad2,7 | iPad3,[26] ) device_9900candidate=1;;
11371137 esac
1138- case $device_type in
1139- iPhone4,1 | iPhone5,* | iPad2,[67] | iPad3,[23] ) device_unsignedbb=1;;
1140- iPad2,3 | iPad3,[23] ) device_unsignedbb=2;;
1141- esac
11421138 if [[ $device_type == " DFU" ]]; then
11431139 print " * Cannot check for manufacturing date in DFU mode"
11441140 return
@@ -2836,9 +2832,6 @@ ipsw_preference_set() {
28362832 [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_other == 1 ]]; then
28372833 ipsw_gasgauge_patch=1
28382834 fi
2839- case $device_type in
2840- iPad2,[367] | iPad3,[23] | iPhone4,1 | iPhone5,[1234] ) ipsw_gasgauge_patch=1;;
2841- esac
28422835 if [[ $device_target_tethered == 1 && $ipsw_gasgauge_patch == 1 &&
28432836 $device_proc == 6 && $target_vers_maj == 10 ]]; then
28442837 warn " multipatch is not supported on A6(X) tethered iOS 10, so it will be disabled."
@@ -2879,7 +2872,7 @@ ipsw_preference_set() {
28792872 # ipsw_nskip being 1 means that it will always create/use a custom ipsw.
28802873 # useful for disabling baseband update, or in the case of macos arm64, not having to use futurerestore for 32-bit.
28812874 case $device_type in
2882- iPad[23],[23] | iPad2,[67] | iPhone4,1 | iPhone5,[1234] | "$device_disable_bbupdate" ) ipsw_nskip=1;;
2875+ iPad[23],[23] | " $device_disable_bbupdate " ) ipsw_nskip=1;;
28832876 esac
28842877 if [[ $ipsw_gasgauge_patch != 1 && $ipsw_jailbreak != 1 && $device_target_vers == " $device_latest_vers " ]]; then
28852878 ipsw_nskip=
@@ -4247,71 +4240,52 @@ replace_plist_data() {
42474240}
42484241
42494242ipsw_bbdigest () {
4250- local loc_sub=
4243+ local loc= " BuildIdentities:0: "
42514244 if [[ $2 != " UniqueBuildID" ]]; then
4252- loc_sub ="Manifest:BasebandFirmware:"
4245+ loc+ =" Manifest:BasebandFirmware:"
42534246 fi
4254- loc_sub+="$2"
4255-
4247+ loc+=" $2 "
42564248 local out=" $1 "
42574249 log " Replacing $2 "
4258-
4259- local ind=(0)
4260- if [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
4261- ind+=(2 4)
4262- [[ $device_type == "iPhone5,"* ]] && ind+=(6)
4263- fi
4264-
42654250 if [[ $platform == " macos" ]]; then
42664251 echo $out | base64 --decode > t
4267- for i in "${ind[@]}"; do
4268- $PlistBuddy -c "Import BuildIdentities:$i:$loc_sub t" BuildManifest.plist
4269- done
4252+ $PlistBuddy -c " Import $loc t" BuildManifest.plist
42704253 rm t
42714254 return
42724255 fi
4273-
4274- for i in "${ind[@]}"; do
4275- in=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub" BuildManifest.plist | tr -d "<>" | xxd -r -p | base64)
4276- in="${in}<"
4277- in="$(echo "$in" | sed -e 's,AAAAAAAAAAAAAAAAAAAAAAA<,==,' \
4278- -e 's,AAAAAAAAAAAAA<,=,' \
4279- -e 's,AAAAAAAAA<,=,')"
4280- case $2 in
4281- *"PartialDigest" )
4282- replace_plist_data "$2" "$out"
4283- return
4284- ;;
4285- * ) mv BuildManifest.plist tmp.plist;;
4286- esac
4287- sed "s,$in,$out," tmp.plist > BuildManifest.plist
4288- rm tmp.plist
4289- done
4256+ in=$( $PlistBuddy -c " Print $loc " BuildManifest.plist | tr -d " <>" | xxd -r -p | base64)
4257+ in=" ${in} <"
4258+ in=" $( echo " $in " | sed -e ' s,AAAAAAAAAAAAAAAAAAAAAAA<,==,' \
4259+ -e ' s,AAAAAAAAAAAAA<,=,' \
4260+ -e ' s,AAAAAAAAA<,=,' ) "
4261+ case $2 in
4262+ * " PartialDigest" )
4263+ in=" ${in% ????????????} "
4264+ in=$( grep -m1 " $in " BuildManifest.plist)
4265+ sed " s,$in ,replace," BuildManifest.plist | \
4266+ awk ' f{f=0; next} /replace/{f=1} 1' | \
4267+ awk ' /replace$/{printf "%s", $0; next} 1' > tmp.plist
4268+ in=" replace"
4269+ ;;
4270+ * ) mv BuildManifest.plist tmp.plist;;
4271+ esac
4272+ sed " s,$in ,$out ," tmp.plist > BuildManifest.plist
4273+ rm tmp.plist
42904274}
42914275
42924276ipsw_bbreplace () {
4293- local rsb1=()
4294- local sbl1=()
4295- local path=()
4277+ local rsb1
4278+ local sbl1
4279+ local path
42964280 local rsb_latest
42974281 local sbl_latest
4298- local loc_sub=" Manifest:BasebandFirmware"
4282+ local bbfw= " Print BuildIdentities:0: Manifest:BasebandFirmware"
42994283 local ubid
4300- if [[ $device_type == "iPad2,6" || $device_type == "iPad2,7" ||
4301- $device_type == "iPhone4,1" || $device_type == "iPhone5,"* ]] &&
4302- [[ $device_target_vers == "$device_latest_vers" ]]; then
4303- :
4304- elif [[ $device_use_bb == 0 || $device_target_vers == "$device_latest_vers" ||
4305- $device_type == "$device_disable_bbupdate" ]] || (( device_proc < 5 )); then
4284+ if [[ $device_use_bb == 0 || $device_target_vers == " $device_latest_vers " ||
4285+ $device_type == " $device_disable_bbupdate " ]] || (( device_proc < 5 )) ; then
43064286 return
43074287 fi
43084288
4309- local ind=(0)
4310- if [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
4311- ind+=(2 4)
4312- [[ $device_type == "iPhone5,"* ]] && ind+=(6)
4313- fi
4314-
43154289 if [[ $1 != " exist" ]]; then
43164290 log " Extracting BuildManifest from IPSW"
43174291 file_extract_from_archive temp.ipsw BuildManifest.plist
@@ -4322,22 +4296,22 @@ ipsw_bbreplace() {
43224296
43234297 case $device_type in
43244298 iPhone4,1 ) ubid=" d9Xbp0xyiFOxDvUcKMsoNjIvhwQ=" ;;
4325- iPhone5,1 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM =";; # iPad3,5 ubid. orig: IcrFKRzWDvccKDfkfMNPOPYHEV0=
4326- iPhone5,2 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM =";; # iPad3,5 ubid. orig: lnU0rtBUK6gCyXhEtHuwbEz/IKY=
4327- iPhone5,3 ) ubid="lnoGRL1B+Be2mF6Y6FNio8TPxM8 =";; # iPhone6,1 ubid. orig: 5MDMapCrTG5J33jbtOLgWNLwzKs=
4328- iPhone5,4 ) ubid="EHCDmDBeezNwTZsyiWYWQCllnz4 =";; # iPhone6,2 ubid. orig: Z4ST0TczwAhpfluQFQNBg7Y3BVE=
4329- iPad2,6 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM =";; # iPad3,5 ubid. orig: L73HfN42pH7qAzlWmsEuIZZg2oE=
4330- iPad2,7 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM=";; # iPad3,5 ubid. orig: z/vJsvnUovZ+RGyXKSFB6DOjt1k=
4331- iPad3,5 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM=";;
4332- iPad3,6 ) ubid="cO+N+Eo8ynFf+0rnsIWIQHTo6rg=";;
4299+ iPhone5,1 ) ubid=" IcrFKRzWDvccKDfkfMNPOPYHEV0 =" ;;
4300+ iPhone5,2 ) ubid=" lnU0rtBUK6gCyXhEtHuwbEz/IKY =" ;;
4301+ iPhone5,3 ) ubid=" dwrol4czV3ijtNHh3w1lWIdsNdA =" ;;
4302+ iPhone5,4 ) ubid=" Z4ST0TczwAhpfluQFQNBg7Y3BVE =" ;;
4303+ iPad2,6 ) ubid=" L73HfN42pH7qAzlWmsEuIZZg2oE =" ;;
4304+ iPad2,7 ) ubid=" z/vJsvnUovZ+RGyXKSFB6DOjt1k=" ;;
4305+ iPad3,5 ) ubid=" 849RPGQ9kNXGMztIQBhVoU/l5lM=" ;;
4306+ iPad3,6 ) ubid=" cO+N+Eo8ynFf+0rnsIWIQHTo6rg=" ;;
43334307 esac
43344308 ipsw_bbdigest $ubid UniqueBuildID
43354309
43364310 case $device_type in
43374311 iPhone4,1 )
4338- rsb1[0] =$($PlistBuddy -c "Print BuildIdentities:0:$loc_sub :eDBL-Version" BuildManifest.plist)
4339- sbl1[0] =$($PlistBuddy -c "Print BuildIdentities:0:$loc_sub :RestoreDBL-Version" BuildManifest.plist)
4340- path[0] =$($PlistBuddy -c "Print BuildIdentities:0:$loc_sub :Info:Path" BuildManifest.plist | tr -d '"')
4312+ rsb1=$( $PlistBuddy -c " $bbfw :eDBL-Version" BuildManifest.plist)
4313+ sbl1=$( $PlistBuddy -c " $bbfw :RestoreDBL-Version" BuildManifest.plist)
4314+ path=$( $PlistBuddy -c " $bbfw :Info:Path" BuildManifest.plist | tr -d ' "' )
43414315 rsb_latest=" -1577031936"
43424316 sbl_latest=" -1575983360"
43434317 ipsw_bbdigest XAAAAADHAQCqerR8d+PvcfusucizfQ4ECBI0TA== RestoreDBL-PartialDigest
@@ -4347,11 +4321,9 @@ ipsw_bbreplace() {
43474321 ipsw_bbdigest 3CHVk7EmtGjL14ApDND81cqFqhM= AMSS-DownloadDigest
43484322 ;;
43494323 iPhone5,[12] | iPad2,[67] | iPad3,[56] )
4350- for i in "${ind[@]}"; do
4351- rsb1[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:RestoreSBL1-Version" BuildManifest.plist)
4352- sbl1[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:SBL1-Version" BuildManifest.plist)
4353- path[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:Info:Path" BuildManifest.plist | tr -d '"')
4354- done
4324+ rsb1=$( $PlistBuddy -c " $bbfw :RestoreSBL1-Version" BuildManifest.plist)
4325+ sbl1=$( $PlistBuddy -c " $bbfw :SBL1-Version" BuildManifest.plist)
4326+ path=$( $PlistBuddy -c " $bbfw :Info:Path" BuildManifest.plist | tr -d ' "' )
43554327 rsb_latest=" -1559114512"
43564328 sbl_latest=" -1560163088"
43574329 ipsw_bbdigest 2bmJ7Vd+WAmogV+hjq1a86UlBvA= APPS-DownloadDigest
@@ -4368,11 +4340,9 @@ ipsw_bbreplace() {
43684340 ipsw_bbdigest kHLoJsT9APu4Xwu/aRjNK10Hx84= SBL2-DownloadDigest
43694341 ;;
43704342 iPhone5,[34] )
4371- for i in "${ind[@]}"; do
4372- rsb1[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:RestoreSBL1-Version" BuildManifest.plist)
4373- sbl1[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:SBL1-Version" BuildManifest.plist)
4374- path[$i]=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub:Info:Path" BuildManifest.plist | tr -d '"')
4375- done
4343+ rsb1=$( $PlistBuddy -c " $bbfw :RestoreSBL1-Version" BuildManifest.plist)
4344+ sbl1=$( $PlistBuddy -c " $bbfw :SBL1-Version" BuildManifest.plist)
4345+ path=$( $PlistBuddy -c " $bbfw :Info:Path" BuildManifest.plist | tr -d ' "' )
43764346 rsb_latest=" -1542379296"
43774347 sbl_latest=" -1543427872"
43784348 ipsw_bbdigest TSVi7eYY4FiAzXynDVik6TY2S1c= APPS-DownloadDigest
@@ -4390,15 +4360,13 @@ ipsw_bbreplace() {
43904360 ;;
43914361 esac
43924362
4393- for i in "${ind[@]}"; do
4394- log "Replacing ${rsb1[$i]} with $rsb_latest"
4395- log "Replacing ${sbl1[$i]} with $sbl_latest"
4396- log "Replacing ${path[$i]} with Firmware/$device_use_bb"
4397- sed -e "s,${rsb1[$i]},$rsb_latest," \
4398- -e "s,${sbl1[$i]},$sbl_latest," \
4399- -e "s,${path[$i]},Firmware/$device_use_bb," BuildManifest.plist > tmp.plist
4400- mv tmp.plist BuildManifest.plist
4401- done
4363+ log " Replacing $rsb1 with $rsb_latest "
4364+ log " Replacing $sbl1 with $sbl_latest "
4365+ log " Replacing $path with Firmware/$device_use_bb "
4366+ sed -e " s,$rsb1 ,$rsb_latest ," \
4367+ -e " s,$sbl1 ,$sbl_latest ," \
4368+ -e " s,$path ,Firmware/$device_use_bb ," BuildManifest.plist > tmp.plist
4369+ mv tmp.plist BuildManifest.plist
44024370
44034371 zip -r0 temp.ipsw Firmware/$device_use_bb BuildManifest.plist
44044372}
@@ -5172,8 +5140,7 @@ ipsw_prepare_multipatch() {
51725140 ' BuildManifest.plist > BuildManifest.tmp
51735141 mv BuildManifest.tmp BuildManifest.plist
51745142 fi
5175- if [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_vers != "$device_latest_vers" ]] ||
5176- [[ $device_type == "iPhone5,"* && $device_target_vers == "$device_latest_vers" ]]; then
5143+ if [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_vers != " $device_latest_vers " ]]; then
51775144 ipsw_bbreplace exist
51785145 else
51795146 zip -r0 temp.ipsw BuildManifest.plist
@@ -8258,24 +8225,16 @@ menu_print_info() {
82588225 if [[ $device_proc != 1 ]] && (( device_proc < 7 )) ; then
82598226 case $device_proc in
82608227 [56] )
8261- if [[ $device_unsignedbb == 1 ]]; then
8262- warn "Latest baseband firmware is currently unsigned for your device. It is not recommended to restore until further notice."
8263- print "* For more details about this issue, see issue #1097: https://github.com/LukeZGD/Legacy-iOS-Kit/issues/1097"
8264- elif [[ $device_unsignedbb == 2 ]]; then
8265- warn "Latest baseband firmware is currently unsigned for your device. All restores require kDFU/pwned DFU mode."
8266- print "* For more details about this issue, see issue #1097: https://github.com/LukeZGD/Legacy-iOS-Kit/issues/1097"
8267- else
8268- if [[ $device_imei == "9900"* ]]; then
8269- warn "Your device's IMEI starts with 9900. These devices are affected by an activation issue."
8270- elif [[ $device_9900candidate == 1 && $device_mode == "Normal" && -n $device_imei ]]; then
8271- print "* Your device's IMEI does not start with 9900. Your device should be safe from the activation issue."
8272- elif [[ $device_9900candidate == 1 && $device_mode != "Normal" ]]; then
8273- warn "Your device is possibly affected by an activation issue. Please check your device's IMEI."
8274- print "* If it starts with 9900, enable Activation Records stitching in Misc Utilities"
8275- elif [[ $device_type == "iPad3,3" ]]; then
8276- warn "Your device is an iPad3,3. These devices are affected by an activation issue."
8277- [[ $device_unactivated != 2 ]] && print "* If you haven't already, dump activation by selecting Activation Records in Misc Utilities"
8278- fi
8228+ if [[ $device_imei == " 9900" * ]]; then
8229+ warn " Your device's IMEI starts with 9900. These devices are affected by an activation issue."
8230+ elif [[ $device_9900candidate == 1 && $device_mode == " Normal" && -n $device_imei ]]; then
8231+ print " * Your device's IMEI does not start with 9900. Your device should be safe from the activation issue."
8232+ elif [[ $device_9900candidate == 1 && $device_mode != " Normal" ]]; then
8233+ warn " Your device is possibly affected by an activation issue. Please check your device's IMEI."
8234+ print " * If it starts with 9900, enable Activation Records stitching in Misc Utilities"
8235+ elif [[ $device_type == " iPad3,3" ]]; then
8236+ warn " Your device is an iPad3,3. These devices are affected by an activation issue."
8237+ [[ $device_unactivated != 2 ]] && print " * If you haven't already, dump activation by selecting Activation Records in Misc Utilities"
82798238 fi
82808239 ;;
82818240 esac
0 commit comments