Skip to main content

Python bindings for iOS device management — tunnel, lockdown, and service access

Project description

rust-ios-device-tunnel

Python bindings for communicating with iOS devices — device discovery, CoreDevice tunnel management, and asyncio integration.

Built on top of rust-ios-device, a Rust library for iOS device interaction through usbmuxd, lockdown, and CoreDevice/RemoteXPC protocols.

Install

pip install rust-ios-device-tunnel

Requires Python 3.9+. Pre-built wheels are available for Linux (x86_64, aarch64), macOS (Apple Silicon), and Windows (x86_64).

Quick start

import ios_rs

# List connected devices
devices = ios_rs.list_devices()
for d in devices:
    print(f"{d['udid']}  {d['connection_type']}")

Tunnel usage

Start a CoreDevice tunnel to a trusted iOS device:

import ios_rs

devices = ios_rs.list_devices()
tunnel = ios_rs.start_tunnel(devices[0]["udid"], mode="userspace")

print(tunnel.server_address)   # device tunnel IPv6 address
print(tunnel.rsd_port)         # Remote Service Discovery port
print(tunnel.userspace_port)   # local TCP proxy port
print(tunnel.services)         # discovered RSD service names
print(tunnel.connect_info())   # connection summary dict

tunnel.close()

Kernel TUN mode (mode="kernel") requires root/administrator privileges. Userspace mode works without elevated permissions and is the default.

asyncio integration

The userspace tunnel includes a context manager that patches asyncio.open_connection so asyncio-based libraries can connect to the device tunnel transparently:

import asyncio
import ios_rs

devices = ios_rs.list_devices()
tunnel = ios_rs.start_tunnel(devices[0]["udid"])

with tunnel.asyncio_proxy():
    # Connections to the tunnel IPv6 address are routed
    # through the local userspace proxy automatically.
    reader, writer = asyncio.get_event_loop().run_until_complete(
        asyncio.open_connection(tunnel.server_address, tunnel.rsd_port)
    )

tunnel.close()

pymobiledevice3 interoperability

Tunnel.asyncio_proxy() can also be used as a transport bridge for asyncio-based RemoteXPC clients. For example, pymobiledevice3's RemoteServiceDiscoveryService calls asyncio.open_connection() internally, so it can run over an ios_rs userspace tunnel without requiring pymobiledevice3's own privileged tunnel startup path:

cd crates/ios-py
uvx maturin develop
uv pip install pymobiledevice3
uv run python examples/pymobiledevice3_coredevice_bridge.py --udid <UDID>

The example is read-only by default and reports RSD service presence. Add --probe-coredevice to try opening selected pymobiledevice3 CoreDevice service classes through the same tunnel; the diagnostics probe is connect-only and does not capture a full sysdiagnose.

API reference

Function / Class Description
ios_rs.list_devices() Returns a list of dicts with udid, device_id, and connection_type for each connected device.
ios_rs.start_tunnel(udid, mode="userspace") Opens a CoreDevice tunnel. Returns a Tunnel object.
Tunnel.server_address Device tunnel IPv6 address.
Tunnel.rsd_port Remote Service Discovery port.
Tunnel.userspace_port Local TCP proxy port (userspace mode only).
Tunnel.services List of discovered RSD service names.
Tunnel.connect_info() Dict summarizing connection parameters.
Tunnel.asyncio_proxy() Context manager that patches asyncio.open_connection.
Tunnel.close() Tears down the tunnel.

Requirements

  • A trusted iOS device connected via USB.
  • usbmuxd (Linux), Apple Mobile Device Support (Windows), or macOS device support components.
  • For CoreDevice tunnels: a compatible iOS version (17+) with pairing material on the host.

Links

License

Licensed under either of Apache-2.0 or MIT at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rust_ios_device_tunnel-0.1.6.tar.gz (326.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rust_ios_device_tunnel-0.1.6-cp39-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ x86-64

rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.38+ ARM64

rust_ios_device_tunnel-0.1.6-cp39-abi3-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file rust_ios_device_tunnel-0.1.6.tar.gz.

File metadata

  • Download URL: rust_ios_device_tunnel-0.1.6.tar.gz
  • Upload date:
  • Size: 326.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rust_ios_device_tunnel-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b21ce4212752a144df169638c675399b4b886a80a82787166301e169f200f212
MD5 46e526a69c2d93d567bff879e8711b72
BLAKE2b-256 5b2cbc62db02d84ded5c7ed46ec2cb31bd3ac1d219b78b177a336e0b76abf4c3

See more details on using hashes here.

File details

Details for the file rust_ios_device_tunnel-0.1.6-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 421e6a17d7c640a8bda5b7c7f24ecd4fd276451f499c5802fbe2fae23b9d7cbc
MD5 0834171e827ac14b657457716ecbbc72
BLAKE2b-256 14e5014262c47dc90fcb0097b718dff836415623a67bd399836cd76f7760e1a9

See more details on using hashes here.

File details

Details for the file rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e0d4606a8a29ee951929266bbbffc38cb86ee31fefd8b675363ed762ac7f7cfd
MD5 509b9b0544fe80a063df6f5665e669b2
BLAKE2b-256 72ecc2c4cc7525f2c2a3d78da736a8d1127ca22fc80473dd157ee195f1f377b2

See more details on using hashes here.

File details

Details for the file rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_aarch64.whl.

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.6-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 475889c04796601317693b74397c176992fe46bc4077c95a918e55e5085a42c4
MD5 2f6aa27607ea82cdb47ef5bf39c531b2
BLAKE2b-256 f8c7443c550aba0a3e9f862a8f6a63224b8c4f0375bdd9f4ea2f7d386ce61701

See more details on using hashes here.

File details

Details for the file rust_ios_device_tunnel-0.1.6-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc050f308f3322fdd2a309d6e2e53004a6dca6cde2c90dfcdc06914e3e0b10eb
MD5 b9a07391223741dac04c68a33699bf75
BLAKE2b-256 5e107ed139258a0b0e89feb281cf180c2fc7b4ca5b922bd3c3488890240fa7c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page