|
Download docs/PROTOCOL_GUIDE.md from meccatronis/iosdiag: direct link, hf CLI and curl.
- Browser
- Download file 6.43 kB
-
https://huggingface.co/meccatronis/iosdiag/resolve/main/docs/PROTOCOL_GUIDE.md
- Command line
-
hf download hf://meccatronis/iosdiag/docs/PROTOCOL_GUIDE.md
-
curl -L -o PROTOCOL_GUIDE.md https://huggingface.co/meccatronis/iosdiag/resolve/main/docs/PROTOCOL_GUIDE.md
6.43 kB
iOS Protocol Guide
Overview
This document describes the iOS protocols used by iOSDiag for device communication and diagnostics.
USBMUX Protocol
Purpose
Direct USB communication with iOS devices via the usbmuxd daemon.
Connection Flow
- Connect to usbmuxd socket (typically
/var/run/usbmuxd) - Send HELLO message
- Receive HELLO response
- Send LISTEN message to monitor device events
- Receive DEVICE_ATTACHED/DETACHED messages
- Send CONNECT message to establish device connection
- Receive RESULT message with status
Message Format
Header (16 bytes):
- Length (4 bytes, little-endian)
- Version (4 bytes, little-endian)
- Message Type (4 bytes, little-endian)
- Tag (4 bytes, little-endian)
Payload:
- Variable length based on message type
Message Types
HELLO(1): Initial handshakeDEVICE_ATTACHED(2): Device connectedDEVICE_DETACHED(3): Device disconnectedRESULT(4): Operation resultLISTEN(5): Listen for device eventsCONNECT(6): Connect to deviceLISTEN_PAIR(7): Listen for pairing eventsPAIR_RECORD(8): Pairing record
Lockdown Protocol
Purpose
Device configuration, service management, and pairing.
Connection Flow
- Establish USBMUX connection to port 62078
- Send StartSession request
- Receive StartSession response with session ID
- Send service requests (GetValue, SetValue, StartService, etc.)
- Receive responses
Message Format
Plist-based messages over SSL/TLS:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Request</key>
<string>GetValue</string>
<key>Domain</key>
<string>com.apple.mobile.battery</string>
<key>Key</key>
<string>BatteryCurrentCapacity</string>
</dict>
</plist>
Common Requests
GetValue: Retrieve device propertySetValue: Set device propertyStartService: Start a serviceStartSession: Begin sessionStopSession: End sessionPair: Establish pairingValidatePair: Verify pairing
Common Domains
com.apple.mobile.battery: Battery informationcom.apple.mobile.device_name: Device namecom.apple.mobile.firmware: Firmware versioncom.apple.mobile.hardware: Hardware informationcom.apple.mobile.system_services: System services
DiagnosticsRelay Protocol
Purpose
Access hardware diagnostics and system information.
Connection Flow
- Establish Lockdown connection
- Request DiagnosticsRelay service
- Send diagnostic requests
- Receive diagnostic responses
Message Format
Plist-based messages:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Request</key>
<string>Query</string>
<key>Diagnostics</key>
<array>
<string>com.apple.mobile.battery</string>
<string>com.apple.mobile.thermal</string>
</array>
</dict>
</plist>
Common Diagnostics
com.apple.mobile.battery: Battery metricscom.apple.mobile.thermal: Thermal informationcom.apple.mobile.nand: Storage healthcom.apple.mobile.wifi: Wi-Fi diagnosticscom.apple.mobile.power: Power information
CrashReport Protocol
Purpose
Retrieve crash logs and panic information.
Connection Flow
- Establish Lockdown connection
- Request CrashReportCopy service
- Send file list request
- Receive file list
- Request individual files
- Receive file contents
File Locations
/var/mobile/Library/Logs/CrashReporter/: Crash logs/var/mobile/Library/Logs/panic.log: Panic logs/var/mobile/Library/Logs/system.log: System logs
Syslog Protocol
Purpose
Stream system logs in real-time.
Connection Flow
- Establish Lockdown connection
- Request Syslog service
- Receive log messages as they occur
- Parse and process messages
Message Format
Text-based log entries:
<timestamp> <hostname> <process>[<pid>]: <message>
CoreDevice Protocol
Purpose
Network-based communication for newer iOS versions.
Connection Flow
- Establish network connection to device
- Send CoreDevice handshake
- Establish secure tunnel
- Send requests through tunnel
- Receive responses
Advantages
- Network-based (no USB required)
- Supports multiple simultaneous connections
- Lower latency for repeated operations
Pairing Process
Overview
Devices must be paired before accessing sensitive services.
Pairing Flow
- User accepts pairing prompt on device
- Device generates certificate
- Host generates certificate
- Certificates are exchanged
- Pair record is stored locally
- Future connections use stored pair record
Pair Record Format
{
"DeviceCertificate": "base64-encoded-certificate",
"HostCertificate": "base64-encoded-certificate",
"HostPrivateKey": "base64-encoded-private-key",
"HostID": "unique-host-identifier",
"RootPrivateKey": "base64-encoded-root-key",
"RootCertificate": "base64-encoded-root-certificate",
"SystemBUID": "device-unique-identifier"
}
Error Handling
Common Errors
InvalidRequest: Malformed requestInvalidResponse: Unexpected response formatServiceNotAvailable: Service not runningInvalidService: Service doesn't existPermissionDenied: Insufficient permissionsDeviceNotFound: Device disconnectedPairingRequired: Device not paired
Retry Strategy
- Exponential backoff: 100ms, 200ms, 400ms, 800ms, 1600ms
- Maximum retries: 5
- Timeout: 30 seconds per request
Security Considerations
SSL/TLS
- Lockdown uses SSL/TLS for encryption
- Certificate pinning for device verification
- Mutual authentication
Cryptography
- RSA-2048 for key exchange
- AES-128-CBC for encryption
- SHA-256 for hashing
Authentication
- Pairing-based authentication
- Session tokens
- Request signing
Performance Optimization
Connection Pooling
- Reuse connections when possible
- Lazy connection establishment
- Connection timeout management
Pipelining
- Send multiple requests without waiting for responses
- Batch operations
- Parallel service access
Caching
- Cache device properties
- Cache service availability
- Cache pair records
Last Updated: 2026-02-10
Version: 1.0.0