Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions AltServer/Anisette Data/RemoteAnisetteDataFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,34 @@ private extension RemoteAnisetteDataFetcher
guard !response.clientInfo.isEmpty, !response.clientInfo.contains("\r"), !response.clientInfo.contains("\n"),
!response.userAgent.isEmpty, !response.userAgent.contains("\r"), !response.userAgent.contains("\n")
else { throw AnisetteError.remoteServerInvalidResponse(serverURL: serverURL, debugDescription: "The server must supply a client_info and a user_agent.") }

// Public anisette servers identify as macOS 10.12, which accounts with Advanced Data Protection can't sign in from
// (the 2FA code never arrives, and manually generated codes are rejected). Apple accepts their anisette data
// with a current client info, so identify as this Mac instead.
if !UserDefaults.standard.usesAnisetteServerClientInfo, let currentMac = self.currentMacClientInfo()
{
return currentMac
}

return (response.clientInfo, response.userAgent)
}

func currentMacClientInfo() -> (clientInfo: String, userAgent: String)?
{
guard let deviceModel = ProcessInfo.processInfo.deviceModel,
let buildVersion = ProcessInfo.processInfo.operatingSystemBuildVersion,
let cfNetworkVersion = Bundle(identifier: "com.apple.CFNetwork")?.infoDictionary?["CFBundleVersion"] as? String
else { return nil }

var systemInfo = utsname()
uname(&systemInfo)
let darwinVersion = withUnsafeBytes(of: &systemInfo.release) { String(decoding: $0.prefix(while: { $0 != 0 }), as: UTF8.self) }

let osVersion = ProcessInfo.processInfo.operatingSystemVersion.stringValue
let clientInfo = "<\(deviceModel)> <macOS;\(osVersion);\(buildVersion)> <com.apple.AuthKit/1 (com.apple.akd/1.0)>"
let userAgent = "akd/1.0 CFNetwork/\(cfNetworkVersion) Darwin/\(darwinVersion)"
return (clientInfo, userAgent)
}

enum HeadersResult
{
Expand Down
6 changes: 6 additions & 0 deletions AltServer/Extensions/UserDefaults+AltServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ extension UserDefaults
{
private static let altJITTimeoutKey = "JITTimeout"
private static let anisetteServerURLKey = "RemoteAltServerURL"
private static let usesAnisetteServerClientInfoKey = "UseAnisetteServerClientInfo"

var altJITTimeout: TimeInterval? {
let timeout = self.double(forKey: UserDefaults.altJITTimeoutKey) // Coerces strings into doubles.
Expand All @@ -71,4 +72,9 @@ extension UserDefaults
var anisetteServerURLOverride: URL? {
return self.string(forKey: UserDefaults.anisetteServerURLKey).flatMap { URL(string: $0) }
}

// Opts out of identifying as this Mac, and uses the anisette server's (outdated) client info instead.
var usesAnisetteServerClientInfo: Bool {
return self.bool(forKey: UserDefaults.usesAnisetteServerClientInfoKey)
}
}