well the value of K is same, but value of CID won't be
% test_nvram -dump
no spi-flash type given, but found MBA62. Assuming N25Q064..3E from experience
...
===================================================
test_nvram_shell_script 13-Dec-2024 by Macschrauber
scanning: /Users/user/Downloads/14.12.2024_18-39-05_N25Q064..3E_dump.bin
...
MBA62, serial from firmware: C17xxxxxxxG085
LBSN: C024174xxxxxxY5CAE BD: 1404xx1404xx Firmware MAC: 0c:4d:xx:xx:xx:ea
hwc: G085 son: MD760D/
Fsys: 0 overrides, 1 override-version, 2 kcal, 3 ssn, 4 hwc, 5 son, 6 EOF
...
Thanks, however we know for sure that other data cannot be related because it isn't used in the request to Apple.maybe it helps, listing the data points a Mac makes unique. All are in the firmware. Read with the Dumper (the test_nvram cli tool lists all, when called via the Dumper it hides some, preventing people posting screenshots).
Thanks, however we know for sure that other data cannot be related because it isn't used in the request to Apple.
The only data sent to Apple's servers is:
...
[*]The board serial number (also sometimes called the "MLB".)
...
nvram_mlb="$(nvram 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB)"; nvram_mlb="${nvram_mlb##*$'\t'}"
4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:MLB
and 4D1EDE05-38C7-4A6A-9CC6-4BCCA8B38C14:ROM
are not stored inside the NVRAM physically.As I dont find it in a dump,
DarwinDumper
finds them, but as a UEFI firmware variable.cid
: client session ID, randomly generated (likely for anti-replay purposes)sn
: the MLB, uniquely identifyingbid
: the board IDk
k
is the hash ofcid
sid
: server session ID (likely included here for anti-replay purposes)CCCCCCCCCCCCCCCCCCCC
k
will fail the response, so Apple is validating the value somehow. The only way Apple could be doing this is if they are computing k
themselves. This hash cannot be precomputed, as it covers cid
, which we know is randomly generated, so this must be occurring at request time.cid
is random so it must have no bearing on the validation. sid
is provided by the servers so it can't have any impact on deciding whether a machine is real or not either. Likewise, the CCCCCCCCCCCCCCCCCCCC
constant is a constant, so that leaves the ROM and the hash of MLB and the board ID.k
does not match the computed value.) But if I swap the serial to something generated from macserial, I get a 403 back. The MLB format is fairly well known at this point, so I doubt that it's an issue with the serials themselves. So, there must be some kind of database lookup before the ROM validation step, and if we peer into the binary, there is a codepath for 403 that results in logging "Machine not in database, falling back to app store..."
- Option-Shift-Command-R: Start up from macOS Recovery over the internet. Use this key combination to reinstall the version of macOS that came with your Mac or the closest version that’s still available.
Why didn't Apple use it for validation for iMessage registration regardless? Like, whether it's derived or looked up in a database, if that database exists Apple could check it before allowing iMessage registration.Additionally, if it was derivable, why didn't Apple use it for validation for iMessage registration?
The other hypothesis I have is that maybe it's some sort of TOFU (trust on first use) kind of thing, where instead of having a lookup table for all factory serial numbers, the first time the machine phones home to apple it gets recorded somewhere.
Why would they be used? The only reason I see to use the values is hackintoshing, and iMessage/FaceTime (iCloud and the rest work already) are already a solved problem there.The question is let's assume there are real values. The moment they get out in the wild they will be used to make iCloud work and multiple requests will most definitely make Apple block them. So these identifiers should be obfuscated to the general public.
I doubt it, as serials in Check Coverage stay invalid even if a hackintosh is using them, but I'll find some values to check with.The other hypothesis I have is that maybe it's some sort of TOFU (trust on first use) kind of thing, where instead of having a lookup table for all factory serial numbers, the first time the machine phones home to apple it gets recorded somewhere. It'd be easy to test this by using the values from a hackintosh that has been actually set up properly and has logged into apple id at least once.
What is even weirder is that board ID is used by macrecovery.py to download BigSur recovery partition:...what's even more strange is that the Macbook Pro 11,3 was released in June 2014.
It 100% should have shipped with Mavericks. Yosemite did not exist yet. WTF?
Big Sur
./macrecovery.py -b Mac-2BD1B31983FE1663 -m 00000000000000000
- Option-Shift-Command-R: Start up from macOS Recovery over the internet. Use this key combination to reinstall the version of macOS that came with your Mac or the closest version that’s still available.
Just a note, as I said above—I have had one case where this was literally not true for me. But I recognize this is not a common experience.I doubt it, as serials in Check Coverage stay invalid even if a hackintosh is using them
Some configurations of the 11,3 were shipped until May 19, 2015, according to EveryMac. Thats a comfortable ~7 months after Yosemite was released, which could indicate that Apple updated their internal information (tied to MLB serial?) to start sending out the updated internet recovery for machines shipped after Yosemite was released. You could probably check this by finding the manufacture date of the machine using something like macserial.It 100% should have shipped with Mavericks. Yosemite did not exist yet. WTF?
Fair point.Why didn't Apple use it for validation for iMessage registration regardless? Like, whether it's derived or looked up in a database, if that database exists Apple could check it before allowing iMessage registration.
I've also had a Hackintosh experience that would support this. Apple's website says a serial number which is definitely not real is real, and that the computer was purchased on the same day as when I first booted that Hackintosh.
How is the serial not real? Unless you previously checked the state beforehand and it was invalid, or if the manufacturing date is after when Apple stopped producing the device, I see no reason why it couldn't be a coincidence. On the other hand, I am pretty sure that Apple Support can make previously invalid serials come up as valid.Just a note, as I said above—I have had one case where this was literally not true for me. But I recognize this is not a common experience.
The returned OS is known to change based on the MLB and is likely correlated to when it was manufactured.So @startergo very kindly sent me the MLB/ROM combination from a Macbook Pro 11,3 he had, in case that would work. Interestingly, when I plugged those values into my shell script, they worked, but the script downloaded Yosemite instead of Mavericks.
So this data is actually being used by Apple to determine the correct OS to send, it's not purely about validation.
The recovery endpoint has various quirks, one of which is that it will accept invalid MLBs, but return the latest OS for them. See macrecovery.What is even weirder is that board ID is used by macrecovery.py to download BigSur recovery partition:
Code:Big Sur ./macrecovery.py -b Mac-2BD1B31983FE1663 -m 00000000000000000
The serial was previously invalid. In addition, the purchase date was listed as the first day I installed Hackintosh on this particular computer. I suppose it's possible that could be a coincidence, but it's a pretty big one.How is the serial not real? Unless you previously checked the state beforehand and it was invalid, or if the manufacturing date is after when Apple stopped producing the device, I see no reason why it couldn't be a coincidence. On the other hand, I am pretty sure that Apple Support can make previously invalid serials come up as valid.
#!/bin/sh
BOARD_SERIAL_NUMBER="C02XXXXXXXXXXXXXX"
BOARD_ID="Mac-35C1E88140C3E6CF"
ROM="XXXXXXXXXXXX"
hex_to_bin() {
printf "$(echo "$1" | sed 's/\(..\)/\\x\1/g')"
}
generate_random_hex() {
dd if=/dev/urandom bs=$(($1 / 2)) count=1 2>/dev/null | od -An -tx1 | tr -d ' \n' | tr '[:lower:]' '[:upper:]'
}
SERVER_ID=$(curl -fs -c - http://osrecovery.apple.com/ | tail -1 | awk '{print $NF}')
if [ -z $(echo "$SERVER_ID" | tr -d '[:space:]') ]
then
echo "Error: Server did not respond with a session token." 1>&2
exit 1
fi
CLIENT_ID=$(generate_random_hex 16)
# Generate `K` based on the client ID, server ID, ROM, board serial number, and board ID.
auth_info=$(printf '%b%b%b%b%b' \
$(hex_to_bin "$CLIENT_ID") \
$(hex_to_bin $(echo $SERVER_ID | awk -F'~' '{print $2}')) \
$(hex_to_bin "$ROM") \
$(printf "%s" "${BOARD_SERIAL_NUMBER}${BOARD_ID}" | openssl dgst -sha256 -binary) \
'\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC')
# Convert auth_info to an sha256 hash. OpenSSL outputs raw binary which is then converted to uppercase hex.
K=$(printf "%s" "$auth_info" | openssl dgst -sha256 -binary | od -An -tx1 | tr -d ' \n' | tr '[:lower:]' '[:upper:]')
INSTALL_ESD_INFO=$(curl -fs 'http://osrecovery.apple.com/InstallationPayload/OSInstaller' -X POST \
-H 'Content-Type: text/plain' \
--cookie "session=$SERVER_ID" \
-d "cid=$CLIENT_ID
sn=$BOARD_SERIAL_NUMBER
bid=$BOARD_ID
k=$K
")
if [ -z $(echo "$INSTALL_ESD_INFO" | tr -d '[:space:]') ]
then
echo "Error: Server did not respond with InstallESD information." 1>&2
exit 1
fi
INSTALL_ESD_URL=$(echo "$INSTALL_ESD_INFO" | grep AU | awk -F': ' '{print $2}')
INSTALL_ESD_ASSET_TOKEN=$(echo "$INSTALL_ESD_INFO" | grep AT | awk -F': ' '{print $2}')
if [ "$INSTALL_ESD_URL" != "http://oscdn.apple.com/content/downloads/33/62/031-10295/gho4r94w66f5v4ujm0sz7k1m0hua68i6oo/OSInstaller/InstallESD.dmg" ]
then
echo "Error: Server did not provide the Mavericks InstallESD URL." 1>&2
exit 1
fi
curl "$INSTALL_ESD_URL" -H "Cookie: AssetToken=$INSTALL_ESD_ASSET_TOKEN" > InstallESD.dmg
# Because we downloaded over unencrypted HTTP, it is critical that we verify the checksum.
echo "Verifying file integrity..."
if [ $(openssl dgst -sha256 InstallESD.dmg | awk -F'= ' '{print $2}') != "c861fd59e82bf777496809a0d2a9b58f66691ee56738031f55874a3fe1d7c3ff" ]
then
rm InstallESD.dmg
echo "Error: Download failed (mismatched checksum)" 1>&2
exit 1
fi
# We successfully downloaded InstallESD. Next, download BaseSystem.dmg.
# For this request, K can be random. The Board Serial Number can be random except for certain characters.
# Refresh Server ID, which may be stale by this point.
SERVER_ID=$(curl -fs -c - http://osrecovery.apple.com/ | tail -1 | awk '{print $NF}')
BASE_SYSTEM_INFO=$(curl -fs 'http://osrecovery.apple.com/InstallationPayload/RecoveryImage' -X POST \
-H 'Content-Type: text/plain' \
-H 'User-Agent: InternetRecovery/1.0' \
--cookie "session=$SERVER_ID" \
-d "cid=$(generate_random_hex 16)
sn=C02$(generate_random_hex 8)$(echo "$BOARD_SERIAL_NUMBER" | cut -c12-15)$(generate_random_hex 2)
bid=$BOARD_ID
k=$(generate_random_hex 64)
os=default
fg=$(generate_random_hex 64)
")
if [ -z $(echo "$BASE_SYSTEM_INFO" | tr -d '[:space:]') ]
then
echo "Error: Server did not respond with RecoveryImage information." 1>&2
exit 1
fi
BASE_SYSTEM_URL=$(echo "$BASE_SYSTEM_INFO" | grep AU | awk -F': ' '{print $2}')
BASE_SYSTEM_TOKEN=$(echo "$BASE_SYSTEM_INFO" | grep AT | awk -F': ' '{print $2}')
if [ "$BASE_SYSTEM_URL" != "http://oscdn.apple.com/content/downloads/33/62/031-10295/gho4r94w66f5v4ujm0sz7k1m0hua68i6oo/RecoveryImage/RecoveryImage.dmg" ]
then
echo "Error: Server did not provide the Mavericks BaseSystem URL." 1>&2
exit 1
fi
curl "$BASE_SYSTEM_URL" -H "Cookie: AssetToken=$BASE_SYSTEM_TOKEN" > RecoveryImage.dmg
# Because we downloaded over unencrypted HTTP, it is critical that we verify the checksum.
echo "Verifying file integrity..."
if [ $(openssl dgst -sha256 BaseSystem.dmg | awk -F'= ' '{print $2}') != "4e33ed34db869189bec60dc2334573e5d5e420037fc18e7f0f4b1251a396ad6d" ]
then
rm BaseSystem.dmg
echo "Error: Download failed (mismatched checksum)" 1>&2
exit 1
fi
if [ "$(uname)" = "Darwin" ]
then
echo "Building InstallMacOSXMavericks.dmg..."
hdiutil convert "InstallESD.dmg" -format UDSP -o "InstallESD.sparseimage"
hdiutil convert "BaseSystem.dmg" -format UDSP -o "BaseSystem.sparseimage"
hdiutil resize -size 6056660992 "BaseSystem.sparseimage"
hdi_util_output=$(hdiutil attach BaseSystem.sparseimage -nobrowse)
if ! echo "$hdi_util_output" | grep "/Volumes/OS X Base System"
then
echo "Error mounting BaseSystem" 1>&2
exit 1
fi
hdi_util_output=$(hdiutil attach InstallESD.sparseimage -nobrowse)
if ! echo "$hdi_util_output" | grep "/Volumes/OS X Install ESD"
then
echo "Error mounting InstallESD" 1>&2
exit 1
fi
rm -rf "/Volumes/OS X Base System/System/Installation/Packages"
cp -R "/Volumes/OS X Install ESD/Packages" "/Volumes/OS X Base System/System/Installation/"
hdiutil detach "/Volumes/OS X Base System"
hdiutil detach "/Volumes/OS X Install ESD"
# Pause before converting so hdiutil won't fail with `hdiutil: convert failed - Resource temporarily unavailable`
sleep 2
hdiutil convert "BaseSystem.sparseimage" -format UDZO -o "InstallMacOSXMavericks.dmg"
rm InstallESD.sparseimage BaseSystem.sparseimage
echo "Successfully created InstallMacOSXMavericks.dmg!"
else
# The user will need to create the final installable image manually.
echo "Files successfully downloaded."
fi
InstallMacOSXMavericks.dmg
has a different checksum each time. This makes me a bit sad, it would be great if we could ensure everyone was getting an identical, perfect copy of Mavericks at the end.OSInstaller
endpoint only works sometimes!!!