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 abi3 wheels are published for:

  • Linux x86_64 (x86_64-unknown-linux-gnu)
  • Linux aarch64 (aarch64-unknown-linux-gnu)
  • macOS Apple Silicon (aarch64-apple-darwin)
  • Windows x86_64 (x86_64-pc-windows-msvc)

A source distribution is also available for other targets via pip install --no-binary rust-ios-device-tunnel rust-ios-device-tunnel.

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.7.tar.gz (327.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.7-cp39-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

rust_ios_device_tunnel-0.1.7-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.7-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.7-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.7.tar.gz.

File metadata

  • Download URL: rust_ios_device_tunnel-0.1.7.tar.gz
  • Upload date:
  • Size: 327.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.7.tar.gz
Algorithm Hash digest
SHA256 603a5c5987211be8494074e3d5192e24ae2e4cde6df913e84afd84432152d92f
MD5 7463f38b5825dc008e0604f27be680b4
BLAKE2b-256 d726bcbeb4e30c301604297d5135d5f31e4aa83679d3fd45e127cdb838afd94a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.7-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ac5191c0c30f78cfb9bc0b67352dc1c80cc43117bfd5e0419cd8ac247f8abbd8
MD5 0b514a24cc1ee646b7cabdfaba16a6d2
BLAKE2b-256 768d0c1b5d44af851f2e49519420323e7a4025234ce9abe065c43de1e34e71cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.7-cp39-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 083c515baa09a9523600d86ce90f88d6fd30006b5b9970a99b9138441b42ffb9
MD5 987204d35f7725c6aee29b16a45d5654
BLAKE2b-256 66d84281b70ef0d6bd6c02702e1879ac535cb920ab8faaa91bc1c5b64912649e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.7-cp39-abi3-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 a0213022a0348f69557d4477a396757e6ec379a38d4aed72d147c5eda49a39de
MD5 f7ea890b452bb87c0a2c883494b31b19
BLAKE2b-256 ed5da6b95c0eb7bbc70da19b8531c4599df9e8508ea6ae44b171343fffec5005

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rust_ios_device_tunnel-0.1.7-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5558994b1d57d59749c8de4f04e4466639c4f0ca832f7a8b4824ee925e608bf2
MD5 c0356e3b236e53c186258043c7450dca
BLAKE2b-256 986a69273d54b7dd2f2068907b3a4182b457c409d5cb00d5aac9e9d5d87b2d2a

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