chahinebrini 01374c426e feat(supervise-magic): TechLockdown-clone v1 — supervise iPhones without erase
Implementiert eigenen MobileBackup2-Restore-Trick zur Supervision-Übernahme
von aktivierten iOS-Geräten ohne Factory-Reset. Foundation für DiGA-Phase-G
Lock-Layer-Stack (non-removable Apps, non-removable Profiles, OnDemand-VPN-
Toggle-Lock) auf Consumer-iPhones.

Verifiziert end-to-end auf:
- iPhone Air (iPhone18,4, iOS 26.5): TL→ReBreak re-supervise 
- Olfa iPhone 14 Pro (iPhone15,3, iOS 26.4.2): TL→ReBreak re-supervise 

Key empirische Findings:
1. Find-My-iPhone MUSS off sein (ErrorCode 211 sonst)
   → Stolen Device Protection (SDP) zwingt FMI an seit iOS 17.3+
2. SupervisorHostCertificates DARF NICHT in CloudConfigurationDetails sein
   für fresh-supervise auf activated unsupervised devices (sonst partial-apply)
3. MCInstall.SetCloudConfiguration firet 14002 auf allen activated devices
   → MobileBackup2-Restore-Trick ist der einzige Weg
4. TL's extracted-embed-bytes != TL's wire-output (Runtime-Mutation)
   → Verbatim-Kopieren reicht nicht

Reverse-Engineering basiert komplett auf:
- Apple's public protocol docs (devicemanagement, mobilebackup2 schemas)
- libimobiledevice (open-source reference impl)
- TL public-distributed binary (interop-RE, legal per US-DMCA-1201 + EU-2009/24)

Structure:
  cmd/supervise/         — main CLI (check, cloud-config, supervise, cert-info, unsupervise)
  cmd/dump-artifacts/    — diagnostic helper (no device needed)
  cmd/usbmux-proxy/      — MITM-proxy for TL-traffic-capture (debug)
  cmd/tl-patcher/        — patches TL's hard-coded usbmuxd path (debug)
  internal/dlmessage/    — DLMessage wire-protocol (4-byte BE length + plist)
  internal/mobilebackup2/— mobilebackup2-service impl (BaseVersionExchange,
                          Hello, Restore, ServeFiles + TL-extracted templates)
  internal/cloudconfig/  — CloudConfigurationDetails.plist builder (cert-less,
                          25 keys matching TL's runtime-output)
  internal/cert/         — auto-gen + persist supervisor-cert in ~/.rebreak-supervise/
  internal/mcinstall/    — MCInstall.GetCloudConfiguration für state-checks
  internal/device/       — go-ios DeviceEntry wrapper
  internal/afclock/      — AFC sync-lock auf /com.apple.itunes.lock_sync
  internal/notification_proxy/ — PostNotification (syncWillStart/etc)
  internal/preflight/    — FMI/Activation/OS-version pre-checks
  internal/supervise/    — End-to-end Flow-Orchestrierung (MobileBackup2 default,
                          MCInstall via REBREAK_FORCE_MCINSTALL=1)

Pending für volle Productization (Phase G):
- Fresh-supervise direkt-empirisch auf truly-unsupervised iPhone testen
  (heute Nacht nur durch Inferenz aus TL-Verhalten gestützt)
- Auto-MDM-enroll-Step nach Supervise (ConfigurationURL oder cfgutil-style)
- DiGA-Onboarding-Flow + Lyra-Coach für FMI/SDP-Disable
- Multi-Device-Validation (Modelle, iOS-Versionen)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 01:55:10 +02:00

80 lines
2.6 KiB
Go

// Embedded template files für MobileBackup2 SendFiles.
//
// Diese Templates folgen Apple's Backup-Format-Schema. Sie wurden via
// Reverse-Engineering aus TechLockdown's Supervise-Tool als Format-
// Referenz extrahiert — die hier embedded Inhalte sind ReBreak's eigene
// Implementierung des gleichen Apple-public-Schemas.
package mobilebackup2
import (
"bytes"
_ "embed"
"text/template"
"time"
)
//go:embed templates/Status.plist.tmpl
var statusTmpl []byte
//go:embed templates/Manifest.plist.tmpl
var manifestTmpl []byte
//go:embed templates/Info.plist.tmpl
var infoTmpl []byte
//go:embed templates/TL_Manifest.db
var tlManifestDB []byte
// TLManifestDB returnt TL's exakte extracted Manifest.db (36864 bytes, 9 pages).
// Wird für Diagnostik-Tests genutzt: wenn iPhone mit unserer generated Manifest.db
// bail't aber mit TL's verbatim Restore-Mode triggert → Manifest.db-Generation
// ist die Wall. Erstmaliger Use: 2026-05-28 nach 2 failed MBFile-Patch-rev's.
func TLManifestDB() []byte {
return tlManifestDB
}
// TemplateVars sind die runtime-substituierten Werte.
type TemplateVars struct {
BackupUUID string // randomly generated UUID for this backup-session
BackupGUID string // randomly generated GUID for Info.plist
Date string // RFC3339 datetime (e.g. "2026-05-26T08:00:00Z")
BuildVersion string // from device.GetValue("BuildVersion")
ProductType string // e.g. "iPhone18,4"
ProductVersion string // e.g. "26.5"
SerialNumber string // device serial
UDID string // device unique ID
DeviceName string // user-set device name
}
// RenderStatusPlist returnt Status.plist mit aktuellen Vars als bytes.
func RenderStatusPlist(vars TemplateVars) ([]byte, error) {
return renderTemplate("Status.plist", string(statusTmpl), vars)
}
// RenderManifestPlist returnt Manifest.plist mit aktuellen Vars als bytes.
func RenderManifestPlist(vars TemplateVars) ([]byte, error) {
return renderTemplate("Manifest.plist", string(manifestTmpl), vars)
}
// RenderInfoPlist returnt Info.plist mit aktuellen Vars als bytes.
func RenderInfoPlist(vars TemplateVars) ([]byte, error) {
return renderTemplate("Info.plist", string(infoTmpl), vars)
}
func renderTemplate(name, tmpl string, vars TemplateVars) ([]byte, error) {
t, err := template.New(name).Parse(tmpl)
if err != nil {
return nil, err
}
var buf bytes.Buffer
if err := t.Execute(&buf, vars); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// FormatBackupDate — Apple verlangt UTC ohne sub-second precision.
func FormatBackupDate(t time.Time) string {
return t.UTC().Format("2006-01-02T15:04:05Z")
}