Run a virtual iPhone on an Apple Silicon Mac.
Swift
Sign and own the restore image's daemons as the system's own
Maximilian Paß9e8332391b3d
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 981fc598..0e7fe560 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -3342,3 +3342,12 @@ it was not ("Invalid root hash", `apfs_sealvolume` exit 65 in- `createDigestAndHash` mounted the image writable only to unmount it againfor `apfs_sealvolume`, which needs the device; the mount changed the volumeafter the mtree described it. It attaches the image with `-noMount` now.++The binaries the merge patches (`launchd_cache_loader`, `mobileactivationd`)+are re-signed in Apple's ad-hoc shape (`VPhoneSignOptions.Style.appleAdHoc`),+like the stock binaries around them. The guest's TXM is stock here: it takes+an ad-hoc binary from the static trust cache the merge rebuilds, but rejected+ldid's signature (no ad-hoc flag, empty CMS blob), and launchd panicked at its+first boot task ("launchd_cache_loader - posix_spawn: 85: Bad executable").+vphoned, its launch daemon plist and the rewritten `launchd.plist` belong to+root:wheel, as the system's own; they kept the host user's owner and group.diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swiftindex 6f2350c4..5e8b294e 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherGuestPayload.swift@@ -19,10 +19,15 @@ extension CryptexFilesystemPatcher {identifier: String? = nil,entitlements: URL? = nil,) throws -> VPhoneSignOptions {+ // Apple's ad-hoc shape, as the stock binaries around them: the guest's+ // TXM is not patched here, and it takes an ad-hoc binary from the+ // static trust cache but rejects ldid's signature, which has no+ // ad-hoc flag and an empty CMS blob ("Bad executable").try VPhoneSignOptions(identifier: identifier,entitlements: entitlements.map { try Data(contentsOf: $0, options: .mappedIfSafe) },mergesExisting: true,+ style: .appleAdHoc,)}@@ -55,10 +60,14 @@ extension CryptexFilesystemPatcher {at: vphonedLaunchdPlist,to: target.appending(path: "System/Library/LaunchDaemons/vphoned.plist"),)+ try chownRecursively(uid: 0, gid: 0, at: target.appending(path: "System/Library/LaunchDaemons/vphoned.plist"))try CustomFirmwareDaemons.injectDaemon(into: launchdPath, name: "vphoned", from: vphonedLaunchdPlist)print(" [+] Injected vphoned")try FileManager.default.moveItem(at: launchdPath, to: launchdOgPath)try setMode(0o644, at: launchdOgPath)+ // Back as the system has it: the move went through a temporary+ // directory on the host, which left the host's group on it.+ try chownRecursively(uid: 0, gid: 0, at: launchdOgPath)}func addVphoned(targetMount: String) throws {@@ -74,6 +83,8 @@ extension CryptexFilesystemPatcher {let targetBin = target.appending(path: "/usr/bin/vphoned")try FileManager.default.copyItem(at: vphonedBin, to: targetBin)try setMode(0o755, at: targetBin)+ // The bundle's copy belongs to whoever built it.+ try chownRecursively(uid: 0, gid: 0, at: targetBin)}/// Copy in the prebuilt guest daemon.