Skip to content

Commit 8367cc9

Browse files
committed
Update ubids and Fix bbdigest/bbreplace logic for ios 10 buildmanifests
1 parent 125e885 commit 8367cc9

1 file changed

Lines changed: 70 additions & 30 deletions

File tree

restore.sh

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,7 @@ ipsw_preference_set() {
28332833
ipsw_gasgauge_patch=1
28342834
fi
28352835
case $device_type in
2836-
iPad2,[36] | iPhone5,[34] ) ipsw_gasgauge_patch=1;;
2836+
iPad2,[367] | iPhone5,[234] ) ipsw_gasgauge_patch=1;;
28372837
esac
28382838
if [[ $device_target_tethered == 1 && $ipsw_gasgauge_patch == 1 &&
28392839
$device_proc == 6 && $target_vers_maj == 10 ]]; then
@@ -2875,7 +2875,7 @@ ipsw_preference_set() {
28752875
# ipsw_nskip being 1 means that it will always create/use a custom ipsw.
28762876
# useful for disabling baseband update, or in the case of macos arm64, not having to use futurerestore for 32-bit.
28772877
case $device_type in
2878-
iPad[23],[23] | iPad2,6 | iPhone5,[34] | "$device_disable_bbupdate" ) ipsw_nskip=1;;
2878+
iPad[23],[23] | iPad2,[67] | iPhone5,[234] | "$device_disable_bbupdate" ) ipsw_nskip=1;;
28792879
esac
28802880
if [[ $ipsw_gasgauge_patch != 1 && $ipsw_jailbreak != 1 && $device_target_vers == "$device_latest_vers" ]]; then
28812881
ipsw_nskip=
@@ -4208,38 +4208,75 @@ ipsw_prepare_32bit() {
42084208
mv temp.ipsw "$ipsw_custom.ipsw"
42094209
}
42104210

4211+
replace_plist_data() {
4212+
local key="$1"
4213+
local value="$2"
4214+
4215+
awk -v key="$key" -v value="$value" '
4216+
$0 ~ "<key>" key "</key>" {
4217+
print
4218+
getline
4219+
if ($0 ~ /<data>/) {
4220+
print
4221+
print "\t\t\t\t\t" value
4222+
4223+
while (getline) {
4224+
if ($0 ~ /<\/data>/) {
4225+
print
4226+
break
4227+
}
4228+
}
4229+
next
4230+
}
4231+
}
4232+
{ print }
4233+
' BuildManifest.plist > tmp.plist &&
4234+
mv tmp.plist BuildManifest.plist
4235+
}
4236+
42114237
ipsw_bbdigest() {
42124238
local loc="BuildIdentities:0:"
4239+
local loc_sub=
42134240
if [[ $2 != "UniqueBuildID" ]]; then
4214-
loc+="Manifest:BasebandFirmware:"
4241+
loc_sub="Manifest:BasebandFirmware:"
42154242
fi
4216-
loc+="$2"
4243+
loc_sub+="$2"
4244+
loc+="$loc_sub"
4245+
42174246
local out="$1"
42184247
log "Replacing $2"
4248+
4249+
local ind=(0)
4250+
if [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
4251+
ind+=(2 4)
4252+
[[ $device_type == "iPhone5,"* ]] && ind+=(6)
4253+
fi
4254+
42194255
if [[ $platform == "macos" ]]; then
42204256
echo $out | base64 --decode > t
4221-
$PlistBuddy -c "Import $loc t" BuildManifest.plist
4257+
for i in "${ind[@]}"; do
4258+
$PlistBuddy -c "Import BuildIdentities:$i:$loc_sub t" BuildManifest.plist
4259+
done
42224260
rm t
42234261
return
42244262
fi
4225-
in=$($PlistBuddy -c "Print $loc" BuildManifest.plist | tr -d "<>" | xxd -r -p | base64)
4226-
in="${in}<"
4227-
in="$(echo "$in" | sed -e 's,AAAAAAAAAAAAAAAAAAAAAAA<,==,' \
4228-
-e 's,AAAAAAAAAAAAA<,=,' \
4229-
-e 's,AAAAAAAAA<,=,')"
4230-
case $2 in
4231-
*"PartialDigest" )
4232-
in="${in%????????????}"
4233-
in=$(grep -m1 "$in" BuildManifest.plist)
4234-
sed "s,$in,replace," BuildManifest.plist | \
4235-
awk 'f{f=0; next} /replace/{f=1} 1' | \
4236-
awk '/replace$/{printf "%s", $0; next} 1' > tmp.plist
4237-
in="replace"
4238-
;;
4239-
* ) mv BuildManifest.plist tmp.plist;;
4240-
esac
4241-
sed "s,$in,$out," tmp.plist > BuildManifest.plist
4242-
rm tmp.plist
4263+
4264+
for i in "${ind[@]}"; do
4265+
in=$($PlistBuddy -c "Print BuildIdentities:$i:$loc_sub" BuildManifest.plist | tr -d "<>" | xxd -r -p | base64)
4266+
in="${in}<"
4267+
in="$(echo "$in" | sed -e 's,AAAAAAAAAAAAAAAAAAAAAAA<,==,' \
4268+
-e 's,AAAAAAAAAAAAA<,=,' \
4269+
-e 's,AAAAAAAAA<,=,')"
4270+
case $2 in
4271+
*"PartialDigest" )
4272+
replace_plist_data "$2" "$out"
4273+
return
4274+
;;
4275+
* ) mv BuildManifest.plist tmp.plist;;
4276+
esac
4277+
sed "s,$in,$out," tmp.plist > BuildManifest.plist
4278+
rm tmp.plist
4279+
done
42434280
}
42444281

42454282
ipsw_bbreplace() {
@@ -4250,7 +4287,9 @@ ipsw_bbreplace() {
42504287
local sbl_latest
42514288
local bbfw="Print BuildIdentities:0:Manifest:BasebandFirmware"
42524289
local ubid
4253-
if [[ $device_type == "iPad2,6" || $device_type == "iPhone5,3" || $device_type == "iPhone5,4" ]] && [[ $device_target_vers == "$device_latest_vers" ]]; then
4290+
if [[ $device_type == "iPad2,6" || $device_type == "iPad2,7" || $device_type == "iPhone5,2" ||
4291+
$device_type == "iPhone5,3" || $device_type == "iPhone5,4" ]] &&
4292+
[[ $device_target_vers == "$device_latest_vers" ]]; then
42544293
:
42554294
elif [[ $device_use_bb == 0 || $device_target_vers == "$device_latest_vers" ||
42564295
$device_type == "$device_disable_bbupdate" ]] || (( device_proc < 5 )); then
@@ -4268,13 +4307,13 @@ ipsw_bbreplace() {
42684307
case $device_type in
42694308
iPhone4,1 ) ubid="d9Xbp0xyiFOxDvUcKMsoNjIvhwQ=";;
42704309
iPhone5,1 ) ubid="IcrFKRzWDvccKDfkfMNPOPYHEV0=";;
4271-
iPhone5,2 ) ubid="lnU0rtBUK6gCyXhEtHuwbEz/IKY=";;
4310+
iPhone5,2 ) ubid="IcrFKRzWDvccKDfkfMNPOPYHEV0=";; # iPhone5,1 ubid. orig: lnU0rtBUK6gCyXhEtHuwbEz/IKY=
42724311
iPhone5,3 ) ubid="lnoGRL1B+Be2mF6Y6FNio8TPxM8=";; # iPhone6,1 ubid. orig: 5MDMapCrTG5J33jbtOLgWNLwzKs=
42734312
iPhone5,4 ) ubid="EHCDmDBeezNwTZsyiWYWQCllnz4=";; # iPhone6,2 ubid. orig: Z4ST0TczwAhpfluQFQNBg7Y3BVE=
4274-
iPad2,6 ) ubid="z/vJsvnUovZ+RGyXKSFB6DOjt1k=";; # iPad2,7 ubid. orig: L73HfN42pH7qAzlWmsEuIZZg2oE=
4275-
iPad2,7 ) ubid="z/vJsvnUovZ+RGyXKSFB6DOjt1k=";;
4276-
iPad3,5 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM=";;
4277-
iPad3,6 ) ubid="cO+N+Eo8ynFf+0rnsIWIQHTo6rg=";;
4313+
iPad2,6 ) ubid="IcrFKRzWDvccKDfkfMNPOPYHEV0=";; # iPhone5,1 ubid. orig: L73HfN42pH7qAzlWmsEuIZZg2oE=
4314+
iPad2,7 ) ubid="IcrFKRzWDvccKDfkfMNPOPYHEV0=";; # iPhone5,1 ubid. orig: z/vJsvnUovZ+RGyXKSFB6DOjt1k=
4315+
iPad3,5 ) ubid="849RPGQ9kNXGMztIQBhVoU/l5lM=";;
4316+
iPad3,6 ) ubid="cO+N+Eo8ynFf+0rnsIWIQHTo6rg=";;
42784317
esac
42794318
ipsw_bbdigest $ubid UniqueBuildID
42804319

@@ -5113,7 +5152,8 @@ ipsw_prepare_multipatch() {
51135152
fi
51145153
if [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_vers != "$device_latest_vers" ]]; then
51155154
ipsw_bbreplace exist
5116-
elif [[ $device_type == "iPhone5,3" || $device_type == "iPhone5,4" ]] && [[ $device_target_vers == "$device_latest_vers" ]]; then
5155+
elif [[ $device_type == "iPhone5,2" || $device_type == "iPhone5,3" || $device_type == "iPhone5,4" ]] &&
5156+
[[ $device_target_vers == "$device_latest_vers" ]]; then
51175157
ipsw_bbreplace exist
51185158
else
51195159
zip -r0 temp.ipsw BuildManifest.plist

0 commit comments

Comments
 (0)