From 1372a1477619c72f82e71ab6a2a228ded94b38ad Mon Sep 17 00:00:00 2001 From: gievano Date: Wed, 26 Aug 2026 03:31:32 +0700 Subject: [PATCH] feat: move Device Spoof into the tweak catalog as a staged tweak Replace the hidden product-type tweak and the standalone DeviceSpoofing tool page with a single catalog tile that behaves 1:1 like the Device Artwork Subtype tweak: tap toggles it, the wheel picker expands inline under its row, and the full identity blast is written through the shared staged apply flow. - Picker options derive from DeviceSpoofingManager.targets so the list never drifts; index 0 keeps the real identity. - GestaltStore.apply routes the devicespoof tweak to DeviceSpoofingManager after the generic pass (its write-set spans ~20 CacheExtra keys plus ArtworkDevice entries that plain modifications cannot express) and runs before any disk write, so manager failures abort loudly. - New tweak id avoids mis-mapping stale persisted picker indices from the old 11-option ProductType picker. - Remove DeviceSpoofingView and dead manager helpers (changedKeyCount, currentTarget, realMachineIdentifier, verify, clearDeviceNames). --- CHANGELOG.md | 1 + .../Gestalt/DeviceSpoofingManager.swift | 83 ------------ WorkPlot/Models/GestaltStore.swift | 59 +++----- WorkPlot/Models/Tweak.swift | 3 + WorkPlot/Models/Tweaks/DeviceTweaks.swift | 34 ++--- WorkPlot/UI/DeviceSpoofingView.swift | 126 ------------------ WorkPlot/Views/HomeView.swift | 5 +- 7 files changed, 33 insertions(+), 278 deletions(-) delete mode 100644 WorkPlot/UI/DeviceSpoofingView.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ee323..453c552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to WorkPlot. Newest first. ### Changed - ๐Ÿ› ๏ธ Every screen is now English only, and status/error messages render properly instead of placeholder strings like "Common Failprefix". - ๐Ÿ“ฑ Device Spoof: tapping the card expands the wheel picker inline, matching the subtype tweak configuration style. +- ๐Ÿ“ฑ Device Spoof now lives in the tweak catalog as a tile โ€” tap to toggle, wheel picker inline, applied with the staged batch (full identity blast unchanged). - ๐Ÿงพ Credits trimmed: dropped the 3105 entry after its feature was removed; FilzaSlop is now credited as class-13 research only. ### Removed diff --git a/WorkPlot/Features/Gestalt/DeviceSpoofingManager.swift b/WorkPlot/Features/Gestalt/DeviceSpoofingManager.swift index ca6cc01..fa4585f 100644 --- a/WorkPlot/Features/Gestalt/DeviceSpoofingManager.swift +++ b/WorkPlot/Features/Gestalt/DeviceSpoofingManager.swift @@ -109,46 +109,6 @@ enum DeviceSpoofingManager { "j9Th5smJpdztHwc+i39zIg" ] - /// Number of CacheExtra keys this target would change on the given - /// plist (artwork subkeys count individually). Used for the UI summary. - static func changedKeyCount(in plist: [String: Any], target: SpoofTarget) -> Int { - guard let cacheExtra = plist["CacheExtra"] as? [String: Any] else { return 0 } - var count = 0 - - func countsChange(_ key: String, _ value: String) { - if cacheExtra[key] as? String != value { count += 1 } - } - - for key in productTypeKeys { countsChange(key, target.productType) } - for key in hwModelKeys { countsChange(key, target.hwModel) } - for key in deviceNameKeys where cacheExtra[key] != nil { - countsChange(key, target.marketingName) - } - - if let artwork = cacheExtra[GestaltArtwork.artworkKey] as? [String: Any] { - if artwork["CompatibleDeviceFallback"] as? String != target.productType { count += 1 } - if artwork["ArtworkDeviceProductDescription"] as? String != target.marketingName { count += 1 } - } - - return count - } - - /// Real hardware identity from sysctl, deliberately ignoring any - /// spoofed CacheExtra ProductType. - static var realMachineIdentifier: String { - DeviceCapability.machineIdentifier - } - - /// Returns the currently spoofed target by matching any ProductType key, - /// or nil when no ProductType matches a known spoof entry. - static func currentTarget(in plist: [String: Any]) -> SpoofTarget? { - let cacheExtra = plist["CacheExtra"] as? [String: Any] ?? [:] - let values = Set( - productTypeKeys.compactMap { cacheExtra[$0] as? String } - ) - return targets.first { values.contains($0.productType) } - } - /// Rewrites every model-related key to the target device at once. /// Owner rule (enforced by Support/check-feature.ps1): the ArtworkDevice /// dictionary must already exist - a device without it cannot render the @@ -186,47 +146,4 @@ enum DeviceSpoofingManager { plist["CacheExtra"] = cacheExtra } - - /// Read-back verification: how many of the spoof's identity keys now - /// carry exactly the target value on disk. Distinguishes a write the - /// system dropped from one that genuinely landed (the OS may still - /// choose to ignore CacheExtra on builds where CacheData is authoritative). - static func verify(target: SpoofTarget, in plist: [String: Any]) -> (matched: Int, total: Int) { - guard let cacheExtra = plist["CacheExtra"] as? [String: Any] else { return (0, 0) } - var matched = 0 - var total = 0 - - func counts(_ key: String, _ value: String) { - total += 1 - if cacheExtra[key] as? String == value { matched += 1 } - } - - for key in productTypeKeys { counts(key, target.productType) } - for key in hwModelKeys { counts(key, target.hwModel) } - for key in deviceNameKeys where cacheExtra[key] != nil { - counts(key, target.marketingName) - } - - if let artwork = cacheExtra[GestaltArtwork.artworkKey] as? [String: Any] { - counts("CompatibleDeviceFallback-artwork", "") - total -= 1 - if artwork["CompatibleDeviceFallback"] as? String == target.productType { matched += 1 } - total += 1 - if artwork["ArtworkDeviceProductDescription"] as? String == target.marketingName { matched += 1 } - } - - return (matched, total) - } - - /// Restoring the genuine identity requires a pre-spoof backup โ€” restore - /// it from the Backups tab and every key above reverts atomically with - /// the whole plist. This helper only clears the spoofed name overrides, - /// leaving identifier keys untouched. - @discardableResult - static func clearDeviceNames(in plist: inout [String: Any]) -> Bool { - guard var cacheExtra = plist["CacheExtra"] as? [String: Any] else { return false } - for key in deviceNameKeys { cacheExtra.removeValue(forKey: key) } - plist["CacheExtra"] = cacheExtra - return true - } } diff --git a/WorkPlot/Models/GestaltStore.swift b/WorkPlot/Models/GestaltStore.swift index 3327fbd..45d629b 100644 --- a/WorkPlot/Models/GestaltStore.swift +++ b/WorkPlot/Models/GestaltStore.swift @@ -251,7 +251,7 @@ final class GestaltStore: ObservableObject { var applied = 0 var warnings: [String] = [] - for tweak in tweaks where tweak.isEnabled && (ids == nil || ids!.contains(tweak.id)) { + for tweak in tweaks where tweak.isEnabled && (ids == nil || ids!.contains(tweak.id)) && tweak.id != Tweak.deviceSpoofTweakID { do { var mods = tweak.modifications if let detail = tweak.detail { @@ -329,6 +329,21 @@ final class GestaltStore: ObservableObject { plist["CacheExtra"] = cacheExtra + // Full-identity device spoof โ€” runs after the generic pass above so + // its CacheExtra writes aren't clobbered by the stale local copy. + // Index 0 ("None") is a no-op; the manager refuses loudly (throws) + // when CacheExtra/ArtworkDevice is missing, aborting before any + // disk write happens. + for tweak in tweaks where tweak.isEnabled && (ids == nil || ids!.contains(tweak.id)) && tweak.id == Tweak.deviceSpoofTweakID { + let index = tweak.selectedIndex + guard index > 0, index - 1 < DeviceSpoofingManager.targets.count else { + warnings.append("\(tweak.title): invalid picker selection, skipped.") + continue + } + try DeviceSpoofingManager.apply(DeviceSpoofingManager.targets[index - 1], to: &plist) + applied += 1 + } + // Optional binary patch (iPadOS). var binaryPatch = false if tweaks.contains(where: { $0.isEnabled && $0.requiresCacheDataPatch && (ids == nil || ids!.contains($0.id)) }) { @@ -475,48 +490,6 @@ final class GestaltStore: ObservableObject { return result } - /// Spoof seluruh identitas perangkat (ProductType, HWModel, CPU, nama - /// pemasaran) ke target terpilih melalui `DeviceSpoofingManager`, pakai - /// engine baca/tulis/backup yang sama dengan `apply()`. - func applyDeviceSpoof(_ target: SpoofTarget) async throws { - guard !isBusy else { throw ApplyError.busy } - isBusy = true - defer { isBusy = false } - - let access = MobileGestaltAccess() - guard (try? access.activate()) != nil else { throw ApplyError.activationFailed } - defer { access.deactivate() } - guard let path = access.mobileGestaltPath else { throw ApplyError.missingPath } - let url = URL(fileURLWithPath: path) - - let current = try Data(contentsOf: url) - let hadBackup = backup.hasBackup - try backup.ensureBackup(from: current) - guard var plist = try PropertyListSerialization.propertyList( - from: current, format: nil) as? [String: Any] - else { throw ApplyError.badPlist } - - try DeviceSpoofingManager.apply(target, to: &plist) - - let newData = try PropertyListSerialization.data( - fromPropertyList: plist, format: .binary, options: 0) - do { - try newData.write(to: url, options: []) - } catch { - try? backup.restoreData().write(to: url, options: []) - throw ApplyError.writeFailed - } - guard let readback = try? Data(contentsOf: url), readback == newData else { - try? backup.restoreData().write(to: url, options: []) - throw ApplyError.writeVerificationFailed - } - isDeviceSpoofed = true - lastApply = ApplyResult( - appliedCount: 1, warnings: [], binaryPatchApplied: false, - backedUpFirstTime: !hadBackup) - lastError = nil - } - /// Reverses whatever `applyAIRegion()` changed โ€” restores every AI /// region key to the value `snapshotAIRegionKeyIfNeeded` saved before /// WorkPlot first touched it (removing keys that didn't exist before), diff --git a/WorkPlot/Models/Tweak.swift b/WorkPlot/Models/Tweak.swift index 14f52e2..93c5374 100644 --- a/WorkPlot/Models/Tweak.swift +++ b/WorkPlot/Models/Tweak.swift @@ -88,6 +88,9 @@ enum TextFieldKind: Equatable { // MARK: - Tweak struct Tweak: Identifiable, Equatable { + /// Applied via DeviceSpoofingManager instead of plain modifications. + static let deviceSpoofTweakID = "devicespoof" + let id: String let title: String let subtitle: String diff --git a/WorkPlot/Models/Tweaks/DeviceTweaks.swift b/WorkPlot/Models/Tweaks/DeviceTweaks.swift index 4000321..24bdfab 100644 --- a/WorkPlot/Models/Tweaks/DeviceTweaks.swift +++ b/WorkPlot/Models/Tweaks/DeviceTweaks.swift @@ -43,33 +43,21 @@ enum DeviceTweaks { value: .keepCurrent, isPicker: true) ] ), + // Full-identity spoof routed through DeviceSpoofingManager in + // GestaltStore.apply() โ€” its write-set spans ~20 CacheExtra keys and + // name keys that only overwrite when already cached, which plain + // GestaltModifications can't express. Tweak( - id: "product-type", - title: "Device Spoof (ProductType)", + id: Tweak.deviceSpoofTweakID, + title: "Device Spoof", subtitle: "Spoof the reported model for Apple Intelligence eligibility.", category: .device, - symbol: "cpu", + symbol: "iphone.and.arrow.forward", isRisky: true, - notes: "Spoof to an AI-capable model, back, then to your final model โ€” the AI icon appears in Settings. Don't re-enter Apple Intelligence & Siri settings after un-spoofing. May break Face ID if you keep the spoof.", - detail: .picker(options: [ - "Default (real model)", - "iPhone 15 Pro", - "iPhone 15 Pro Max", - "iPhone 16", - "iPhone 16 Plus", - "iPhone 16 Pro", - "iPhone 16 Pro Max", - "iPhone 17", - "iPhone 17 Pro", - "iPhone 17 Pro Max", - "iPhone Air", - ]), - pickerValues: [.remove, .string("iPhone16,1"), .string("iPhone16,2"), .string("iPhone17,3"), .string("iPhone17,4"), .string("iPhone17,1"), .string("iPhone17,2"), .string("iPhone18,3"), .string("iPhone18,1"), .string("iPhone18,2"), .string("iPhone18,4")], - modifications: [ - GestaltModification(key: "h9jDsbgj7xIVeIQ8S3/X3Q", - subkey: nil, - value: .remove, isPicker: true) - ] + notes: "Spoofs every model-identity key at once (ProductType, board, marketing name). May break Face ID until reverted โ€” restore the pristine backup to undo. 'None' keeps your real identity.", + detail: .picker(options: + ["None (Real Identity)"] + DeviceSpoofingManager.targets.map(\.marketingName)), + modifications: [] ), ] } diff --git a/WorkPlot/UI/DeviceSpoofingView.swift b/WorkPlot/UI/DeviceSpoofingView.swift deleted file mode 100644 index ce3f1c2..0000000 --- a/WorkPlot/UI/DeviceSpoofingView.swift +++ /dev/null @@ -1,126 +0,0 @@ -import SwiftUI - -struct DeviceSpoofingView: View { - @EnvironmentObject private var store: GestaltStore - @State private var selected: SpoofTarget? - @State private var isConfiguring = false - @State private var isBusy = false - @State private var message: String? - @State private var errorText: String? - - private var allTargets: [SpoofTarget?] { - [nil] + DeviceSpoofingManager.targets - } - - private var selectionBinding: Binding { - Binding( - get: { allTargets.firstIndex { $0?.id == selected?.id } ?? 0 }, - set: { selected = allTargets[$0] } - ) - } - - /// Same caption contract as TweakCatalogTile: open panel reads - /// "Configuring"; otherwise show state or the current target. - private var spoofCaption: String { - if isConfiguring { return "Configuring" } - if store.isDeviceSpoofed { return "Spoofed" } - return selected?.marketingName ?? "None" - } - - private func toggleConfiguration() { - withAnimation(.snappy) { isConfiguring.toggle() } - } - - var body: some View { - ScrollView { - VStack(alignment: .leading, spacing: 16) { - if store.isDeviceSpoofed { - Label("Currently spoofed", systemImage: "cpu") - .font(.caption.weight(.medium)) - .foregroundStyle(Theme.caution) - } - - Button { toggleConfiguration() } label: { - // Mirrors TweakCatalogTile 1:1 so the spoof card reads - // exactly like a configurable tweak tile. - VStack(alignment: .leading, spacing: 14) { - HStack { - Image(systemName: "iphone.and.arrow.forward") - .font(.body.weight(.medium)) - .foregroundStyle(isConfiguring ? .white : .secondary) - Spacer() - Image(systemName: store.isDeviceSpoofed ? "checkmark.circle.fill" : "circle") - .font(.caption) - .foregroundStyle(isConfiguring ? .white : Color(uiColor: .tertiaryLabel)) - } - Spacer(minLength: 8) - Text("Device Spoof") - .font(.subheadline.weight(.semibold)) - .foregroundStyle(.primary) - .lineLimit(2) - .frame(maxWidth: .infinity, alignment: .leading) - Text(spoofCaption) - .font(.caption) - .foregroundStyle(isConfiguring ? .white : .secondary) - .lineLimit(2) - } - .frame(maxWidth: .infinity, minHeight: 142, maxHeight: .infinity, alignment: .leading) - .padding(16) - .background(isConfiguring ? .white.opacity(0.14) : .clear, in: RoundedRectangle(cornerRadius: 22, style: .continuous)) - .liquidGlass(cornerRadius: 22) - } - .buttonStyle(.plain) - - if isConfiguring { - VStack(alignment: .leading, spacing: 12) { - SectionHeader("Configure Device Spoof") - - Picker("Option", selection: selectionBinding) { - ForEach(Array(allTargets.enumerated()), id: \.offset) { index, target in - Text(target?.marketingName ?? "None").tag(index) - } - } - .pickerStyle(.wheel) - .frame(height: 138) - .liquidGlass() - - Label("Changes the reported device identity. Some spoof targets may break Face ID until reverted, so keep a snapshot handy. 'None' keeps the device's real identity.", systemImage: "exclamationmark.triangle") - .font(.footnote) - .foregroundStyle(.secondary) - } - .transition(.opacity.combined(with: .move(edge: .top))) - } - - ActionButton(title: "Apply Spoof") { - Task { await apply() } - } - .disabled(isBusy || selected == nil) - - if let message { - Text(message) - .font(.caption) - .foregroundStyle(.secondary) - .padding(.horizontal, 4) - } - } - .padding() - } - .navigationTitle("Device Spoof") - .wpGlassContainer() - .alert("Error", isPresented: .constant(errorText != nil)) { - Button("OK") { errorText = nil } - } message: { Text(errorText ?? "") } - } - - private func apply() async { - guard let target = selected else { return } - isBusy = true - defer { isBusy = false } - do { - try await store.applyDeviceSpoof(target) - message = "Spoofed to \(target.marketingName). Respring to apply." - } catch { - errorText = error.localizedDescription - } - } -} diff --git a/WorkPlot/Views/HomeView.swift b/WorkPlot/Views/HomeView.swift index 41bb73a..f23ebf0 100644 --- a/WorkPlot/Views/HomeView.swift +++ b/WorkPlot/Views/HomeView.swift @@ -127,7 +127,7 @@ struct HomeView: View { /// "All" selected: one flat sequential list โ€” tweaks and tools interleaved, /// no category grouping. private var flatCatalog: some View { - let tweaks = store.tweaks.filter { $0.id != "product-type" && $0.category != .ai && matchesSearch($0.title) } + let tweaks = store.tweaks.filter { $0.category != .ai && matchesSearch($0.title) } let tools = toolDefs.filter { $0.id != "respring" && matchesSearch($0.title) } var cells: [FlatCell] = [] var ti = 0, to = 0 @@ -172,7 +172,7 @@ struct HomeView: View { } private func categorySection(_ cat: TweakCategory) -> some View { - let tweaks = store.tweaks.filter { $0.category == cat && $0.id != "product-type" && matchesSearch($0.title) } + let tweaks = store.tweaks.filter { $0.category == cat && matchesSearch($0.title) } let tools = toolDefs.filter { $0.category == cat && $0.id != "respring" && matchesSearch($0.title) } // Tools flow into the last half-empty tweak row instead of starting // their own group, so an odd tweak count leaves no gap mid-catalog. @@ -214,7 +214,6 @@ struct HomeView: View { ToolDef(id: "carplay", title: "CarPlay Wallpaper", subtitle: "Change the CarPlay wallpaper", symbol: "car", category: .display, destination: { AnyView(CarPlayWallpaperView()) }), ToolDef(id: "rdarfix", title: "RDARFix", subtitle: "Edit screen resolution via the canvas exploit", symbol: "wand.and.stars", category: .display, destination: { AnyView(RDARFixView()) }), ToolDef(id: "respring", title: "Respring", subtitle: "Restart SpringBoard without rebooting", symbol: "arrow.clockwise", category: .system, action: { RespringHelper.shared.trigger() }), - ToolDef(id: "devicespoof", title: "Device Spoof", subtitle: "Spoof the device identity", symbol: "iphone.and.arrow.forward", category: .system, destination: { AnyView(DeviceSpoofingView()) }), ToolDef(id: "gestalteditor", title: "Gestalt Field Editor", subtitle: "Edit cache MobileGestalt", symbol: "slider.horizontal.3", category: .gestalt, destination: { AnyView(GestaltFieldEditorView()) }), ToolDef(id: "presetlab", title: "Preset Lab", subtitle: "Build & save Gestalt presets", symbol: "flask", category: .gestalt, destination: { AnyView(PresetLabView()) }), ToolDef(id: "sessionlog", title: "Session Log", subtitle: "View exploit session debug logs", symbol: "doc.plaintext", category: .info, destination: { AnyView(SessionLogView()) }),