Skip to content

Instantly share code, notes, and snippets.

@dedoussis
Created May 21, 2023 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dedoussis/3ad084a5c9a50430de520e8e165021ca to your computer and use it in GitHub Desktop.
Save dedoussis/3ad084a5c9a50430de520e8e165021ca to your computer and use it in GitHub Desktop.
Retrieve local anisette data
#!/usr/bin/env python3
import sys
import json
import typing as t
import objc
from Foundation import NSBundle, NSClassFromString, NSISO8601DateFormatter, NSDate, NSTimeZone
from AppKit import *
AOSKitBundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/AOSKit.framework')
objc.loadBundleFunctions(AOSKitBundle, globals(), [("retrieveOTPHeadersForDSID", b''), ("machineSerialNumber", b'')])
def headers() -> t.Mapping[str, str]:
aos_utils = NSClassFromString('AOSUtilities')
date_formatter = NSISO8601DateFormatter.alloc().init()
date_string = date_formatter.stringFromDate_(NSDate.alloc().init())
current_device = AKDevice.currentDevice()
otp_headers = aos_utils.retrieveOTPHeadersForDSID_("-2")
return {
'X-Apple-I-Client-Time': date_string,
'X-Apple-MD': otp_headers["X-Apple-MD"],
'X-Apple-MD-LU': current_device.localUserUUID(),
'X-Apple-MD-M': otp_headers["X-Apple-MD-M"],
'X-Apple-I-MD-RINFO': "0",
'X-Apple-I-SRL-NO': aos_utils.machineSerialNumber(),
'X-Apple-I-TimeZone': NSTimeZone.systemTimeZone().abbreviation(),
'X-Apple-Locale': current_device.locale().localeIdentifier(),
'X-MMe-Client-Info': current_device.serverFriendlyDescription(),
'X-Mme-Device-Id': current_device.uniqueDeviceIdentifier(),
}
def main() -> None:
json.dump(headers(), sys.stdout, indent=4)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment