ios

package
v1.0.166 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 38 Imported by: 9

Documentation

Index

Constants

View Source
const Lockdownport uint16 = 32498

Lockdownport is the port of the always running lockdownd on the iOS device.

Variables

This section is empty.

Functions

func ByteCountDecimal added in v1.0.84

func ByteCountDecimal(b int64) string

func CheckRoot added in v1.0.122

func CheckRoot() error

CheckRoot checks if the current user is root or has elevated privileges on Windows.

func ConnectTUNDevice added in v1.0.129

func ConnectTUNDevice(remoteIp string, port int, d DeviceEntry) (*net.TCPConn, error)

ConnectTUNDevice creates a *net.TCPConn to the device at the given address and port. If the device is a userspaceTUN device provided by go-ios agent, it will connect to this automatically. Otherwise it will try a operating system level TUN device.

func ConnectToXpcServiceTunnelIface added in v1.0.122

func ConnectToXpcServiceTunnelIface(device DeviceEntry, serviceName string) (*xpc.Connection, error)

ConnectToServiceTunnelIface connects to a service on an iOS17+ device using a XPC over HTTP2 connection It returns a new xpc.Connection

func CreateXpcConnection added in v1.0.122

func CreateXpcConnection(h *http.HttpConnection) (*xpc.Connection, error)

func FindDeviceInterfaceAddress added in v1.0.122

func FindDeviceInterfaceAddress(ctx context.Context, device DeviceEntry) (string, error)

FindDeviceInterfaceAddress tries to find the address of the device by browsing through all network interfaces. It uses mDNS to discover the "_remoted._tcp" service on the local. domain. Then tries to connect to the RemoteServiceDiscovery and checks if the udid of the device matches the udid of the device we are looking for.

func FixWindowsPaths added in v1.0.40

func FixWindowsPaths(path string) string

FixWindowsPaths replaces backslashes with forward slashes and removes the X: style windows drive letters

func GenericSliceToType added in v1.0.122

func GenericSliceToType[T any](input []interface{}) ([]T, error)

GenericSliceToType tries to convert a slice of interfaces to a slice of the given type. It returns an error if the conversion fails but will not panic. Example: var b []bool; b, err = GenericSliceToType[bool]([]interface{}{true, false})

func GetAssistiveTouch added in v1.0.78

func GetAssistiveTouch(device DeviceEntry) (bool, error)

func GetProductVersion added in v1.0.30

func GetProductVersion(device DeviceEntry) (*semver.Version, error)

GetProductVersion gets the iOS version of a device

func GetSocketTypeAndAddress added in v1.0.106

func GetSocketTypeAndAddress(socketAddress string) (string, string)

func GetUsbmuxdSocket added in v1.0.106

func GetUsbmuxdSocket() string

GetUsbmuxdSocket this is the default socket address for the platform to connect to.

func GetUses24HourClock added in v1.0.116

func GetUses24HourClock(device DeviceEntry) (bool, error)

func GetValuesPlist added in v1.0.4

func GetValuesPlist(device DeviceEntry) (map[string]interface{}, error)

GetValuesPlist returns the full lockdown values response as a map, so it can be converted to JSON easily.

func GetVoiceOver added in v1.0.113

func GetVoiceOver(device DeviceEntry) (bool, error)

func GetWifiMac added in v1.0.48

func GetWifiMac(device DeviceEntry) (string, error)

GetWifiMac gets the static MAC address of the device WiFi. note: this does not report the dynamic MAC if you enable the "automatic WiFi address" feature.

func GetZoomTouch added in v1.0.113

func GetZoomTouch(device DeviceEntry) (bool, error)

func HttpApiHost added in v1.0.158

func HttpApiHost() string

DefaultHttpApiHost is the host on which the HTTP-Server runs, by default it is 127.0.0.1 if GO_IOS_AGENT_HOST is set, we use that host. Otherwise we use the default host

func HttpApiPort added in v1.0.129

func HttpApiPort() int

DefaultHttpApiPort is the port on which we start the HTTP-Server for exposing started tunnels if GO_IOS_AGENT_PORT is set, we use that port. Otherwise we use the default port 60106. 60-105 is leetspeek for go-ios :-D

func IOS11 added in v1.0.78

func IOS11() *semver.Version

func IOS12 added in v1.0.38

func IOS12() *semver.Version

func IOS14 added in v1.0.38

func IOS14() *semver.Version

func IOS17 added in v1.0.122

func IOS17() *semver.Version

func InterfaceToStringSlice added in v1.0.107

func InterfaceToStringSlice(intfSlice interface{}) []string

InterfaceToStringSlice casts an interface{} to []interface{} and then converts each entry to a string. It returns an empty slice in case of an error.

func Listen added in v1.0.85

func Listen() (func() (AttachedMessage, error), func() error, error)

func Ntohs

func Ntohs(port uint16) uint16

Ntohs is a re-implementation of the C function Ntohs. it means networkorder to host oder and basically swaps the endianness of the given int. It returns port converted to little endian.

func Pair added in v1.0.9

func Pair(device DeviceEntry) error

Pair tries to pair with a device. The first time usually fails because the user has to accept a trust pop up on the iOS device. What you have to do to pair is: 1. run the Pair() function 2. accept the trust pop up on the device 3. run the Pair() function a second time

func PairSupervised added in v1.0.25

func PairSupervised(device DeviceEntry, p12bytes []byte, p12Password string) error

PairSupervised uses an organization id from apple configurator so you can pair a supervised device without the need for user interaction (the trust popup) Arguments are the device, the p12 files raw contents and the password used for the p12 file. I basically got this from cfgutil: https://configautomation.com/cfgutil-man-page.html here is how to turn a p12 into crt and key: openssl pkcs12 -in organization.p12 -out organization.pem -nodes -password pass:a openssl x509 -outform DER -out organization.crt -in organization.pem openssl rsa -outform DER -out organization.key -in organization.pem then you can run: cfgutil -K organization.key -C organization.crt pair

func ParsePlist

func ParsePlist(data []byte) (map[string]interface{}, error)

ParsePlist tries to parse the given bytes, which should be a Plist, into a map[string]interface. It returns the map or an error if the decoding step fails.

func PathExists added in v1.0.24

func PathExists(path string) (bool, error)

PathExists is used to determine whether the path folder exists True if it exists, false otherwise

func RsdCheckin added in v1.0.122

func RsdCheckin(rw io.ReadWriter) error

RsdCheckin sends a plist encoded message with the request 'RSDCheckin' to the device. The device is expected to reply with two plist encoded messages. The first message is the response for the checkin itself, and the second message contains a 'StartService' request, which does not need any action from the host side

func SetAssistiveTouch added in v1.0.78

func SetAssistiveTouch(device DeviceEntry, enabled bool) error

EnableAssistiveTouch creates a new lockdown session for the device and enables or disables AssistiveTouch (the on-screen software home button), by using the special key AssistiveTouchEnabledByiTunes. Setting to true will enable AssistiveTouch Setting to false will disable AssistiveTouch, regardless of whether it was previously-enabled through a non-iTunes-related method.

func SetLanguage

func SetLanguage(device DeviceEntry, config LanguageConfiguration) error

SetLanguage creates a new lockdown session for the device and sets a new language and locale. Changes will only be made when the value is not an empty string. To change only the locale, set language to "" and vice versa. If both are empty, nothing is changed. NOTE: Changing a language is an async operation that takes a long time. Springboard will be restarted automatically by the device. If you need to wait for this happen use notificationproxy.WaitUntilSpringboardStarted().

func SetSystemTime added in v1.0.107

func SetSystemTime(device DeviceEntry) error

func SetTime added in v1.0.107

func SetTime(device DeviceEntry, timeZone string, time int64) error

func SetUses24HourClock added in v1.0.116

func SetUses24HourClock(device DeviceEntry, enabled bool) error

Enable24HourClock creates a new lockdown session for the device and enables or disables 24HourClock, by using the special key Uses24HourClock. Setting to true will enable 24Hour Clock Setting to false will disable 24Hour Clock, regardless of whether it was previously-enabled through a non-iTunes-related method.

func SetVoiceOver added in v1.0.113

func SetVoiceOver(device DeviceEntry, enabled bool) error

EnableVoiceOver creates a new lockdown session for the device and enables or disables VoiceOver (the on-screen software home button), by using the special key VoiceOverTouchEnabledByiTunes. Setting to true will enable VoiceOver Setting to false will disable VoiceOver, regardless of whether it was previously-enabled through a non-iTunes-related method.

func SetZoomTouch added in v1.0.113

func SetZoomTouch(device DeviceEntry, enabled bool) error

EnableZoomTouch creates a new lockdown session for the device and enables or disables ZoomTouch (the on-screen software home button), by using the special key ZoomTouchEnabledByiTunes. Setting to true will enable ZoomTouch Setting to false will disable ZoomTouch, regardless of whether it was previously-enabled through a non-iTunes-related method.

func Sign added in v1.0.57

func Sign(challengeBytes []byte, cert *x509.Certificate, supervisedPrivateKey interface{}) ([]byte, error)

func ToBinPlistBytes added in v1.0.107

func ToBinPlistBytes(data interface{}) []byte

func ToPlist

func ToPlist(data interface{}) string

ToPlist converts a given struct to a Plist using the github.com/DHowett/go-plist library. Make sure your struct is exported. It returns a string containing the plist.

func ToPlistBytes

func ToPlistBytes(data interface{}) []byte

ToPlistBytes converts a given struct to a Plist using the github.com/DHowett/go-plist library. Make sure your struct is exported. It returns a byte slice containing the plist.

func ToUnixSocketPath added in v1.0.106

func ToUnixSocketPath(socketAddress string) string

func Unzip added in v1.0.124

func Unzip(src string, dest string) ([]string, uint64, error)

Unzip is code I copied from https://golangcode.com/unzip-files-in-go/ thank you guys for the cool helpful code examples :-D

func UseHttpProxy added in v1.0.136

func UseHttpProxy(proxyUrl string) error

UseHttpProxy sets the default http transport to use the given proxy url. If the proxyUrl is empty, it will try to use the HTTP_PROXY or HTTPS_PROXY environment variables. If the environment variables are not set, it will not set a proxy. If the proxyUrl is invalid, it will return an error.

Types

type AllValuesType

type AllValuesType struct {
	ActivationState                             string
	ActivationStateAcknowledged                 bool
	BasebandActivationTicketVersion             string
	BasebandCertID                              int `plist:"BasebandCertId"`
	BasebandChipID                              int
	BasebandKeyHashInformation                  BasebandKeyHashInformationType
	BasebandMasterKeyHash                       string
	BasebandRegionSKU                           []byte
	BasebandSerialNumber                        []byte
	BasebandStatus                              string
	BasebandVersion                             string
	BluetoothAddress                            string
	BoardID                                     int `plist:"BoardId"`
	BrickState                                  bool
	BuildVersion                                string
	CPUArchitecture                             string
	CarrierBundleInfoArray                      []interface{}
	CertID                                      int
	ChipID                                      int
	ChipSerialNo                                []byte
	DeviceClass                                 string
	DeviceColor                                 string
	DeviceName                                  string
	DieID                                       int
	EthernetAddress                             string
	FirmwareVersion                             string
	FusingStatus                                int
	HardwareModel                               string
	HardwarePlatform                            string
	HasSiDP                                     bool
	HostAttached                                bool
	InternationalMobileEquipmentIdentity        string
	MLBSerialNumber                             string
	MobileEquipmentIdentifier                   string
	MobileSubscriberCountryCode                 string
	MobileSubscriberNetworkCode                 string
	ModelNumber                                 string
	NonVolatileRAM                              NonVolatileRAMType
	PartitionType                               string
	PasswordProtected                           bool
	PkHash                                      []byte
	ProductName                                 string
	ProductType                                 string
	ProductVersion                              string
	ProductionSOC                               bool
	ProtocolVersion                             string
	ProximitySensorCalibration                  []byte
	RegionInfo                                  string
	SBLockdownEverRegisteredKey                 bool
	SIMStatus                                   string
	SIMTrayStatus                               string
	SerialNumber                                string
	SoftwareBehavior                            []byte
	SoftwareBundleVersion                       string
	SupportedDeviceFamilies                     []int
	TelephonyCapability                         bool
	TimeIntervalSince1970                       float64
	TimeZone                                    string
	TimeZoneOffsetFromUTC                       float64
	TrustedHostAttached                         bool
	UniqueChipID                                uint64
	UniqueDeviceID                              string
	UseRaptorCerts                              bool
	Uses24HourClock                             bool
	WiFiAddress                                 string
	WirelessBoardSerialNumber                   string
	KCTPostponementInfoPRIVersion               string `plist:"kCTPostponementInfoPRIVersion"`
	KCTPostponementInfoPRLName                  int    `plist:"kCTPostponementInfoPRLName"`
	KCTPostponementInfoServiceProvisioningState bool   `plist:"kCTPostponementInfoServiceProvisioningState"`
	KCTPostponementStatus                       string `plist:"kCTPostponementStatus"`
}

AllValuesType contains all possible values that can be requested from LockDown

type AttachedMessage

type AttachedMessage struct {
	MessageType string
	DeviceID    int
	Properties  DeviceProperties
}

AttachedMessage contains some info about when iOS devices are connected or disconnected from the host

func (AttachedMessage) DeviceAttached

func (msg AttachedMessage) DeviceAttached() bool

DeviceAttached checks if the attached message is about a newly added device

func (AttachedMessage) DeviceDetached

func (msg AttachedMessage) DeviceDetached() bool

DeviceDetached checks if the attachedMessage is about a disconnected device

func (AttachedMessage) DeviceEntry added in v1.0.35

func (a AttachedMessage) DeviceEntry() DeviceEntry

type BasebandKeyHashInformationType

type BasebandKeyHashInformationType struct {
	AKeyStatus int
	SKeyHash   []byte
	SKeyStatus int
}

BasebandKeyHashInformationType containing some baseband related data directly from the ios device

type BatteryInfo added in v1.0.108

type BatteryInfo struct {
	BatteryCurrentCapacity uint64
	BatteryIsCharging      bool
	ExternalChargeCapable  bool
	ExternalConnected      bool
	FullyCharged           bool
	GasGaugeCapability     bool
	HasBattery             bool
}

func GetBatteryDiagnostics added in v1.0.108

func GetBatteryDiagnostics(device DeviceEntry) (BatteryInfo, error)

type CaCertificate added in v1.0.107

type CaCertificate struct {
	CertDER       []byte
	PrivateKeyDER []byte
	Csr           string
	CertPEM       []byte
	PrivateKeyPEM []byte
}

CaCertificate is a simple struct to hold a x509 cert and privateKey in DER and PEM formats as well as the CER should you need it.

func CreateDERFormattedSupervisionCert added in v1.0.107

func CreateDERFormattedSupervisionCert() (*CaCertificate, error)

CreateDERFormattedSupervisionCert is a convenience function to generate DER and PEM formatted private key and cert to be used for device supervision. It basically does the same as these openSSL commands:

openssl genrsa -des3 -out domain.key 2048
openssl req -key domain.key -new -out domain.csr
openssl x509 -signkey domain.key -in domain.csr -req -days 365 -out domain.crt
openssl x509 -in domain.crt -outform der -out domain.der
and returns the resulting certs in a CaCertificate struct.

If you need p12 files, please save the PEMs to files and run this: openssl pkcs12 -export -inkey supervision-private-key.pem -in supervision-cert.pem -out certificate.p12 -password pass:a

type Connection added in v1.0.108

type Connection struct {
	// contains filtered or unexported fields
}

type DeviceConnection

type DeviceConnection struct {
	// contains filtered or unexported fields
}

DeviceConnection wraps the net.Conn to the ios Device and has support for switching Codecs and enabling SSL

func NewDeviceConnection

func NewDeviceConnection(socketToConnectTo string) (*DeviceConnection, error)

NewDeviceConnection creates a new DeviceConnection pointing to the given socket waiting for a call to Connect()

func NewDeviceConnectionWithConn

func NewDeviceConnectionWithConn(conn net.Conn) *DeviceConnection

NewDeviceConnectionWithConn create a DeviceConnection with a already connected network conn.

func (*DeviceConnection) Close

func (conn *DeviceConnection) Close() error

Close closes the network connection

func (*DeviceConnection) Conn added in v1.0.24

func (conn *DeviceConnection) Conn() net.Conn

func (*DeviceConnection) DisableSessionSSL

func (conn *DeviceConnection) DisableSessionSSL()

DisableSessionSSL is a hack to go back from SSL to an unencrypted conn without closing the connection. It is only used for the debug proxy because certain MAC applications actually disable SSL, use the connection to send unencrypted messages just to then enable SSL again without closing the connection

func (*DeviceConnection) EnableSessionSsl

func (conn *DeviceConnection) EnableSessionSsl(pairRecord PairRecord) error

EnableSessionSsl wraps the underlying net.Conn in a client tls.Conn using the pairRecord.

func (*DeviceConnection) EnableSessionSslHandshakeOnly

func (conn *DeviceConnection) EnableSessionSslHandshakeOnly(pairRecord PairRecord) error

EnableSessionSslHandshakeOnly enables SSL only for the Handshake and then falls back to plaintext DTX based services do that currently

func (*DeviceConnection) EnableSessionSslServerMode

func (conn *DeviceConnection) EnableSessionSslServerMode(pairRecord PairRecord) error

EnableSessionSslServerMode wraps the underlying net.Conn in a server tls.Conn using the pairRecord.

func (*DeviceConnection) EnableSessionSslServerModeHandshakeOnly

func (conn *DeviceConnection) EnableSessionSslServerModeHandshakeOnly(pairRecord PairRecord) error

EnableSessionSslServerModeHandshakeOnly enables SSL only for the Handshake and then falls back to plaintext DTX based services do that currently. Server mode is needed only in the debugproxy.

func (*DeviceConnection) Read added in v1.0.122

func (conn *DeviceConnection) Read(p []byte) (n int, err error)

Read reads incoming data from the connection to the device

func (*DeviceConnection) Reader

func (conn *DeviceConnection) Reader() io.Reader

Reader exposes the underlying net.Conn as io.Reader

func (*DeviceConnection) Send

func (conn *DeviceConnection) Send(bytes []byte) error

Send sends a message

func (*DeviceConnection) Write added in v1.0.122

func (conn *DeviceConnection) Write(p []byte) (n int, err error)

Write writes data on the connection to the device

func (*DeviceConnection) Writer

func (conn *DeviceConnection) Writer() io.Writer

Writer exposes the underlying net.Conn as io.Writer

type DeviceConnectionInterface

type DeviceConnectionInterface interface {
	Close() error
	Send(message []byte) error
	Reader() io.Reader
	Writer() io.Writer
	EnableSessionSsl(pairRecord PairRecord) error
	EnableSessionSslServerMode(pairRecord PairRecord) error
	EnableSessionSslHandshakeOnly(pairRecord PairRecord) error
	EnableSessionSslServerModeHandshakeOnly(pairRecord PairRecord) error
	DisableSessionSSL()
	Conn() net.Conn
	io.ReadWriteCloser
}

DeviceConnectionInterface contains a physical network connection to a usbmuxd socket.

func ConnectToService

func ConnectToService(device DeviceEntry, serviceName string) (DeviceConnectionInterface, error)

func ConnectToServiceTunnelIface added in v1.0.122

func ConnectToServiceTunnelIface(device DeviceEntry, serviceName string) (DeviceConnectionInterface, error)

func ConnectToShimService added in v1.0.122

func ConnectToShimService(device DeviceEntry, service string) (DeviceConnectionInterface, error)

ConnectToShimService opens a new connection of the tunnel interface of the provided device to the provided service. The 'RSDCheckin' required by shim services is also executed before returning the connection to the caller

func NewDeviceConnectionWithRWC added in v1.0.129

func NewDeviceConnectionWithRWC(rwc io.ReadWriteCloser) DeviceConnectionInterface

type DeviceConnectionRWC added in v1.0.129

type DeviceConnectionRWC struct {
	// contains filtered or unexported fields
}

TODO: remove the need for this with some refactoring in a follow up PR

func (*DeviceConnectionRWC) Close added in v1.0.129

func (conn *DeviceConnectionRWC) Close() error

func (*DeviceConnectionRWC) Conn added in v1.0.129

func (conn *DeviceConnectionRWC) Conn() net.Conn

Conn implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) DisableSessionSSL added in v1.0.129

func (conn *DeviceConnectionRWC) DisableSessionSSL()

DisableSessionSSL implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) EnableSessionSsl added in v1.0.129

func (conn *DeviceConnectionRWC) EnableSessionSsl(pairRecord PairRecord) error

EnableSessionSsl implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) EnableSessionSslHandshakeOnly added in v1.0.129

func (conn *DeviceConnectionRWC) EnableSessionSslHandshakeOnly(pairRecord PairRecord) error

EnableSessionSslHandshakeOnly implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) EnableSessionSslServerMode added in v1.0.129

func (conn *DeviceConnectionRWC) EnableSessionSslServerMode(pairRecord PairRecord) error

EnableSessionSslServerMode implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) EnableSessionSslServerModeHandshakeOnly added in v1.0.129

func (conn *DeviceConnectionRWC) EnableSessionSslServerModeHandshakeOnly(pairRecord PairRecord) error

EnableSessionSslServerModeHandshakeOnly implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) Read added in v1.0.129

func (conn *DeviceConnectionRWC) Read(p []byte) (n int, err error)

Read implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) Reader added in v1.0.129

func (conn *DeviceConnectionRWC) Reader() io.Reader

Reader implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) Send added in v1.0.129

func (conn *DeviceConnectionRWC) Send(message []byte) error

Send implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) Write added in v1.0.129

func (conn *DeviceConnectionRWC) Write(p []byte) (n int, err error)

Write implements DeviceConnectionInterface.

func (*DeviceConnectionRWC) Writer added in v1.0.129

func (conn *DeviceConnectionRWC) Writer() io.Writer

Writer implements DeviceConnectionInterface.

type DeviceEntry

type DeviceEntry struct {
	DeviceID         int
	MessageType      string
	Properties       DeviceProperties
	Address          string
	Rsd              RsdPortProvider
	UserspaceTUN     bool
	UserspaceTUNHost string
	UserspaceTUNPort int
}

DeviceEntry contains the DeviceID with is sometimes needed f.ex. to enable LockdownSSL. More importantly it contains DeviceProperties where the udid is stored.

func GetDevice

func GetDevice(udid string) (DeviceEntry, error)

GetDevice returns: the device for the udid if a valid udid is provided. if the env variable 'udid' is specified, the device with that udid otherwise it returns the first device in the list.

func GetDeviceWithAddress added in v1.0.122

func GetDeviceWithAddress(udid string, address string, provider RsdPortProvider) (DeviceEntry, error)

func (*DeviceEntry) SupportsRsd added in v1.0.122

func (device *DeviceEntry) SupportsRsd() bool

SupportsRsd checks if the device supports RSD (Remote Service Discovery). It returns true if the device has RSD capability, otherwise false.

type DeviceList

type DeviceList struct {
	DeviceList []DeviceEntry
}

DeviceList is a simple wrapper for a array of DeviceEntry

func DeviceListfromBytes

func DeviceListfromBytes(plistBytes []byte) DeviceList

DeviceListfromBytes parses a DeviceList from a byte array

func ListDevices

func ListDevices() (DeviceList, error)

ListDevices returns a DeviceList containing data about all currently connected iOS devices using a new UsbMuxConnection

func (DeviceList) CreateMapForJSONConverter

func (deviceList DeviceList) CreateMapForJSONConverter() map[string]interface{}

CreateMapForJSONConverter creates a simple json ready map containing all UDIDs

func (DeviceList) String

func (deviceList DeviceList) String() string

String returns a list of all udids in a formatted string

type DeviceProperties

type DeviceProperties struct {
	ConnectionSpeed int
	ConnectionType  string
	DeviceID        int
	LocationID      int
	ProductID       int
	SerialNumber    string
}

DeviceProperties contains important device related info like the udid which is named SerialNumber here

type FullPairRecordData added in v1.0.9

type FullPairRecordData struct {
	DeviceCertificate []byte
	HostCertificate   []byte
	RootCertificate   []byte
	SystemBUID        string
	HostID            string
}

type GetAllValuesResponse

type GetAllValuesResponse struct {
	Request string
	Value   AllValuesType
}

GetAllValuesResponse just the wrapper for AllValuesType

func GetValues

func GetValues(device DeviceEntry) (GetAllValuesResponse, error)

GetValues returns all values of deviceInformation from lockdown

type LanguageConfiguration

type LanguageConfiguration struct {
	Language           string
	Locale             string
	SupportedLocales   []string
	SupportedLanguages []string
}

LanguageConfiguration is a simple struct encapsulating a language and locale string

func GetLanguage

func GetLanguage(device DeviceEntry) (LanguageConfiguration, error)

GetLanguage creates a new lockdown session for the device and retrieves the current language and locale as well as a list of all supported locales and languages. It returns a LanguageConfiguration or an error.

type ListenType

type ListenType struct {
	MessageType         string
	ProgName            string
	ClientVersionString string
	ConnType            int
	// contains filtered or unexported fields
}

ListenType contains infos for creating a LISTEN message for USBMUX

func NewListen

func NewListen() ListenType

NewListen creates a new Listen Message for USBMUX

type LockDownConnection

type LockDownConnection struct {
	// contains filtered or unexported fields
}

LockDownConnection allows you to interact with the Lockdown service on the phone. You can use this to grab basic info from the device and start other services on the phone.

func ConnectLockdownWithSession

func ConnectLockdownWithSession(device DeviceEntry) (*LockDownConnection, error)

func NewLockDownConnection

func NewLockDownConnection(dev DeviceConnectionInterface) *LockDownConnection

NewLockDownConnection creates a new LockDownConnection with empty sessionId and a PlistCodec.

func (*LockDownConnection) Close

func (lockDownConn *LockDownConnection) Close()

Close closes the underlying DeviceConnection

func (*LockDownConnection) Conn added in v1.0.24

func (lockDownConn *LockDownConnection) Conn() net.Conn

func (LockDownConnection) DisableSessionSSL

func (lockDownConn LockDownConnection) DisableSessionSSL()

DisableSessionSSL see documentation in DeviceConnection

func (LockDownConnection) EnableSessionSsl

func (lockDownConn LockDownConnection) EnableSessionSsl(pairRecord PairRecord) error

EnableSessionSsl see documentation in DeviceConnection

func (LockDownConnection) EnableSessionSslServerMode

func (lockDownConn LockDownConnection) EnableSessionSslServerMode(pairRecord PairRecord) error

EnableSessionSslServerMode see documentation in DeviceConnection

func (*LockDownConnection) GetProductVersion

func (lockDownConn *LockDownConnection) GetProductVersion() (string, error)

GetProductVersion returns the ProductVersion of the device f.ex. "10.3"

func (*LockDownConnection) GetValue

func (lockDownConn *LockDownConnection) GetValue(key string) (interface{}, error)

GetValue gets and returns the string value for the lockdown key

func (*LockDownConnection) GetValueForDomain

func (lockDownConn *LockDownConnection) GetValueForDomain(key string, domain string) (interface{}, error)

GetValueForDomain gets and returns the string value for the lockdown key and domain

func (*LockDownConnection) GetValues

func (lockDownConn *LockDownConnection) GetValues() (GetAllValuesResponse, error)

GetValues retrieves a GetAllValuesResponse containing all values lockdown returns

func (*LockDownConnection) ReadMessage

func (lockDownConn *LockDownConnection) ReadMessage() ([]byte, error)

ReadMessage grabs the next LockDown Message using the PlistDecoder from the underlying DeviceConnection and returns the Plist as a byte slice.

func (LockDownConnection) Send

func (lockDownConn LockDownConnection) Send(msg interface{}) error

Send takes a go struct, converts it to a PLIST and sends it with a 4 byte length field.

func (*LockDownConnection) SetValueForDomain

func (lockDownConn *LockDownConnection) SetValueForDomain(key string, domain string, value interface{}) error

SetValueForDomain sets the string value for the lockdown key and domain. If the device returns an error it will be returned as a go error.

func (*LockDownConnection) StartService

func (lockDownConn *LockDownConnection) StartService(serviceName string) (StartServiceResponse, error)

StartService sends a StartServiceRequest using the provided serviceName and returns the Port of the services in a BigEndian Integer. This port cann be used with a new UsbMuxClient and the Connect call.

func (*LockDownConnection) StartSession

func (lockDownConn *LockDownConnection) StartSession(pairRecord PairRecord) (StartSessionResponse, error)

StartSession will send a StartSession Request to Lockdown, wait for the response and enable SSL on the underlying connection if necessary. The devices usually always requests to enable SSL. It returns a StartSessionResponse

func (*LockDownConnection) StopSession

func (lockDownConn *LockDownConnection) StopSession()

StopSession sends a Lockdown StopSessionRequest to the device

type LockDownPairRequest added in v1.0.9

type LockDownPairRequest struct {
	Label           string
	PairRecord      FullPairRecordData
	Request         string
	ProtocolVersion string
	PairingOptions  PairingOptions
}

type LockdownPairResponse added in v1.0.9

type LockdownPairResponse struct {
	Error     string
	Request   string
	EscrowBag []byte
}

type MuxResponse

type MuxResponse struct {
	MessageType string
	Number      uint32
}

MuxResponse is a generic response message sent by usbmuxd it contains a Number response code

func MuxResponsefromBytes

func MuxResponsefromBytes(plistBytes []byte) MuxResponse

MuxResponsefromBytes parses a MuxResponse struct from bytes

func (MuxResponse) IsSuccessFull

func (u MuxResponse) IsSuccessFull() bool

IsSuccessFull returns UsbMuxResponse.Number==0

type NonVolatileRAMType

type NonVolatileRAMType struct {
	AutoBoot              []byte `plist:"auto-boot"`
	BacklightLevel        []byte `plist:"backlight-level"`
	BootArgs              string `plist:"boot-args"`
	Bootdelay             []byte `plist:"bootdelay"`
	ComAppleSystemTz0Size []byte `plist:"com.apple.System.tz0-size"`
	OblitBegins           []byte `plist:"oblit-begins"`
	Obliteration          []byte `plist:"obliteration"`
}

NonVolatileRAMType contains some internal device info and can be retrieved by getting all values

type PairRecord

type PairRecord struct {
	HostID            string
	SystemBUID        string
	HostCertificate   []byte
	HostPrivateKey    []byte
	DeviceCertificate []byte
	EscrowBag         []byte
	WiFiMACAddress    string
	RootCertificate   []byte
	RootPrivateKey    []byte
}

PairRecord contains the HostID string, the SystemBUID string, the HostCertificate []byte and the HostPrivateKey []byte. It is needed for enabling SSL Connections over Lockdown

func PairRecordfromBytes

func PairRecordfromBytes(plistBytes []byte) PairRecord

PairRecordfromBytes parsed a plist into a PairRecord

func ReadPairRecord

func ReadPairRecord(udid string) (PairRecord, error)

ReadPairRecord creates a new USBMuxConnection just to read the pair record and closes it right after than.

type PairRecordData

type PairRecordData struct {
	PairRecordData []byte
}

PairRecordData only holds a []byte containing the PairRecord data as a serialized Plist.

type PairingOptions added in v1.0.9

type PairingOptions struct {
	ExtendedPairingErrors bool
}

type PlistCodec

type PlistCodec struct{}

PlistCodec is a codec for PLIST based services with [4 byte big endian length][plist-payload] based messages

func NewPlistCodec

func NewPlistCodec() PlistCodec

NewPlistCodec create a codec for PLIST based services with [4 byte big endian length][plist-payload] based messages

func (PlistCodec) Decode

func (plistCodec PlistCodec) Decode(r io.Reader) ([]byte, error)

Decode reads a Lockdown Message from the provided reader and sends it to the ResponseChannel

func (PlistCodec) Encode

func (plistCodec PlistCodec) Encode(message interface{}) ([]byte, error)

Encode encodes a LockDown Struct to a byte[] with the lockdown plist format. It returns a byte array that contains a 4 byte length unsigned big endian integer followed by the plist as a string

type PlistCodecReadWriter added in v1.0.121

type PlistCodecReadWriter struct {
	// contains filtered or unexported fields
}

PlistCodecReadWriter handles length encoded plist messages Each message starts with an uint32 value representing the length of the encoded payload followed by the binary encoded plist data

func NewPlistCodecReadWriter added in v1.0.121

func NewPlistCodecReadWriter(r io.Reader, w io.Writer) PlistCodecReadWriter

NewPlistCodecReadWriter creates a new PlistCodecReadWriter

func (PlistCodecReadWriter) Read added in v1.0.121

func (p PlistCodecReadWriter) Read(v interface{}) error

Read reads and decodes a length encoded plist message from the reader of PlistCodecReadWriter

func (PlistCodecReadWriter) Write added in v1.0.121

func (p PlistCodecReadWriter) Write(m interface{}) error

Write encodes the passed value m into a binary plist and writes the length of this encoded data followed by the actual data.

type ReadDevicesType

type ReadDevicesType struct {
	MessageType         string
	ProgName            string
	ClientVersionString string
}

ReadDevicesType contains all the data necessary to request a DeviceList from usbmuxd. Can be created with newReadDevices

func NewReadDevices

func NewReadDevices() ReadDevicesType

NewReadDevices creates a struct containing a request for a device list that can be sent to UsbMuxD.

type ReadPair

type ReadPair struct {
	BundleID            string
	ClientVersionString string
	MessageType         string
	ProgName            string
	LibUSBMuxVersion    uint32 `plist:"kLibUSBMuxVersion"`
	PairRecordID        string
}

ReadPair contains all the Infos necessary to request a PairRecord from usbmuxd. use newReadPair(udid string) to create one.

type RsdHandshakeResponse added in v1.0.122

type RsdHandshakeResponse struct {
	Udid     string
	Services map[string]RsdServiceEntry
}

RsdHandshakeResponse is the response to the RSDCheckin request and contains the UDID and the services available on the device.

func (RsdHandshakeResponse) GetPort added in v1.0.122

func (r RsdHandshakeResponse) GetPort(service string) int

GetPort returns the port for the given service.

func (RsdHandshakeResponse) GetService added in v1.0.122

func (r RsdHandshakeResponse) GetService(p int) string

GetService returns the service name for the given port.

func (RsdHandshakeResponse) GetServices added in v1.0.138

func (r RsdHandshakeResponse) GetServices() map[string]RsdServiceEntry

type RsdPortProvider added in v1.0.122

type RsdPortProvider interface {
	GetPort(service string) int
	GetService(p int) string
	GetServices() map[string]RsdServiceEntry
}

RsdPortProvider is an interface to get a port for a service, or a service for a port from the Remote Service Discovery on the device. Used in iOS17+

type RsdPortProviderJson added in v1.0.122

type RsdPortProviderJson map[string]service

func NewRsdPortProvider added in v1.0.122

func NewRsdPortProvider(input io.Reader) (RsdPortProviderJson, error)

func (RsdPortProviderJson) GetPort added in v1.0.122

func (r RsdPortProviderJson) GetPort(service string) int

func (RsdPortProviderJson) GetService added in v1.0.122

func (r RsdPortProviderJson) GetService(p int) string

func (RsdPortProviderJson) GetServices added in v1.0.138

func (r RsdPortProviderJson) GetServices() (services map[string]RsdServiceEntry)

type RsdService added in v1.0.122

type RsdService struct {
	// contains filtered or unexported fields
}

func NewWithAddrDevice added in v1.0.139

func NewWithAddrDevice(addr string, d DeviceEntry) (RsdService, error)

NewWithAddrDevice creates a new RsdService with the given address and port 58783 using a HTTP2 based XPC connection.

func NewWithAddrPort added in v1.0.122

func NewWithAddrPort(addr string, port int) (RsdService, error)

NewWithAddrPort creates a new RsdService with the given address and port 58783 using a HTTP2 based XPC connection, connecting to an operating system level TUN device.

func NewWithAddrPortDevice added in v1.0.139

func NewWithAddrPortDevice(addr string, port int, d DeviceEntry) (RsdService, error)

NewWithAddrPortDevice creates a new RsdService with the given address and port using a HTTP2 based XPC connection.

func (RsdService) Close added in v1.0.122

func (s RsdService) Close() error

func (RsdService) Handshake added in v1.0.122

func (s RsdService) Handshake() (RsdHandshakeResponse, error)

Handshake sends a handshake request to the device and returns the RsdHandshakeResponse which contains the UDID and the services available on the device.

type RsdServiceEntry added in v1.0.122

type RsdServiceEntry struct {
	Port uint32
}

type SavePair added in v1.0.9

type SavePair struct {
	BundleID            string
	ClientVersionString string
	MessageType         string
	ProgName            string
	LibUSBMuxVersion    uint32 `plist:"kLibUSBMuxVersion"`
	PairRecordID        string
	PairRecordData      []byte
}

type StartServiceResponse

type StartServiceResponse struct {
	Port             uint16
	Request          string
	Service          string
	EnableServiceSSL bool
	Error            string
}

StartServiceResponse is sent by the phone after starting a service, it contains servicename, port and tells us whether we should enable SSL or not.

func StartService

func StartService(device DeviceEntry, serviceName string) (StartServiceResponse, error)

StartService conveniently starts a service on a device and cleans up the used UsbMuxconnection. It returns the service port as a uint16 in BigEndian byte order.

type StartSessionResponse

type StartSessionResponse struct {
	EnableSessionSSL bool
	Request          string
	SessionID        string
	Error            string
}

StartSessionResponse contains the information sent by the device as a response to a StartSessionRequest.

type UsbMuxConnection

type UsbMuxConnection struct {
	// contains filtered or unexported fields
}

UsbMuxConnection can send and read messages to the usbmuxd process to manage pairrecors, listen for device changes and connect to services on the phone. Usually messages follow a request-response pattern. there is a tag integer in the message header, that is increased with every sent message.

func NewUsbMuxConnection

func NewUsbMuxConnection(deviceConn DeviceConnectionInterface) *UsbMuxConnection

NewUsbMuxConnection creates a new UsbMuxConnection from an already initialized DeviceConnectionInterface

func NewUsbMuxConnectionSimple added in v1.0.8

func NewUsbMuxConnectionSimple() (*UsbMuxConnection, error)

NewUsbMuxConnectionSimple creates a new UsbMuxConnection with a connection to /var/run/usbmuxd

func (*UsbMuxConnection) Close added in v1.0.9

func (muxConn *UsbMuxConnection) Close() error

Close calls close on the underlying DeviceConnection

func (*UsbMuxConnection) Connect

func (muxConn *UsbMuxConnection) Connect(deviceID int, port uint16) error

Connect issues a Connect Message to UsbMuxd for the given deviceID on the given port enabling the newCodec for it. It returns an error containing the UsbMux error code should the connect fail.

func (*UsbMuxConnection) ConnectLockdown

func (muxConn *UsbMuxConnection) ConnectLockdown(deviceID int) (*LockDownConnection, error)

ConnectLockdown connects this Usbmux connection to the LockDown service that always runs on the device on the same port. The connect call needs the deviceID which can be retrieved from a DeviceList using the ListDevices function. After this function is done, the UsbMuxConnection cannot be used anymore because the same underlying network connection is used for talking to Lockdown. Sending usbmux commands would break it. It returns a new LockDownConnection.

func (*UsbMuxConnection) ListDevices

func (muxConn *UsbMuxConnection) ListDevices() (DeviceList, error)

ListDevices returns a DeviceList containing data about all currently connected iOS devices

func (*UsbMuxConnection) Listen

func (muxConn *UsbMuxConnection) Listen() (func() (AttachedMessage, error), error)

Listen will send a listen command to usbmuxd which will cause this connection to stay open indefinitely and receive messages whenever devices are connected or disconnected

func (*UsbMuxConnection) ReadBuid added in v1.0.9

func (muxConn *UsbMuxConnection) ReadBuid() (string, error)

ReadBuid requests the BUID of the host It returns the deserialized BUID as a string.

func (*UsbMuxConnection) ReadMessage

func (muxConn *UsbMuxConnection) ReadMessage() (UsbMuxMessage, error)

ReadMessage blocks until the next muxMessage is available on the underlying DeviceConnection and returns it.

func (*UsbMuxConnection) ReadPair

func (muxConn *UsbMuxConnection) ReadPair(udid string) (PairRecord, error)

ReadPair reads the PairRecord from the usbmux socket for the given udid. It returns the deserialized PairRecord.

func (*UsbMuxConnection) ReleaseDeviceConnection

func (muxConn *UsbMuxConnection) ReleaseDeviceConnection() DeviceConnectionInterface

ReleaseDeviceConnection dereferences this UsbMuxConnection from the underlying DeviceConnection and it returns the DeviceConnection for later use. This UsbMuxConnection cannot be used after calling this.

func (*UsbMuxConnection) Send

func (muxConn *UsbMuxConnection) Send(msg interface{}) error

Send sends and encodes a Plist using the usbmux Encoder. Increases the connection tag by one.

func (*UsbMuxConnection) SendMuxMessage

func (muxConn *UsbMuxConnection) SendMuxMessage(msg UsbMuxMessage) error

SendMuxMessage serializes and sends a UsbMuxMessage to the underlying DeviceConnection. This does not increase the tag on the connection. Is used mainly by the debug proxy to forward messages between device and host

type UsbMuxHeader

type UsbMuxHeader struct {
	Length  uint32
	Version uint32
	Request uint32
	Tag     uint32
}

UsbMuxHeader contains the header for plist messages for the usbmux daemon.

type UsbMuxMessage

type UsbMuxMessage struct {
	Header  UsbMuxHeader
	Payload []byte
}

UsbMuxMessage contains header and payload for a message to usbmux

type ValueResponse

type ValueResponse struct {
	Key     string
	Request string
	Error   string
	Domain  string
	Value   interface{}
}

ValueResponse contains the response for a GetValue or SetValue Request

Directories

Path Synopsis
Package appservice provides functions to Launch and Kill apps on an iOS devices for iOS17+.
Package appservice provides functions to Launch and Kill apps on an iOS devices for iOS17+.
Package openstdio is used to open a new socket connection that can be used to connect an app launched with appservice
Package openstdio is used to open a new socket connection that can be used to connect an app launched with appservice
Package tunnel implements creating a TUN interface for iOS 17 devices.
Package tunnel implements creating a TUN interface for iOS 17 devices.
Package xpc contains a connection stuct and the codec for the xpc protocol.
Package xpc contains a connection stuct and the codec for the xpc protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL