Netimobiledevice is a pure C# implementation for working with iOS devices (iPhone, iPad, iPod).
- Backup an iOS device in the normal iTunes way or as customised as you like.
- Device discovery and connection via Usbmux.
- Interact with iOS services using Lockdownd or Remoted
- Handle all property lists files (.plist) whether they are in XML or Binary format
- Use remoted Apples new framework for working with iOS devices. This uses the RemoteXPC protocol and you can read more about it here
To install Netimobiledevice, you can use the following command in the Package Manager Console:
Install-Package Netimobiledevice
Alternatively, you can use the .NET CLI:
dotnet add package Netimobiledevice
A few examples of how to use Netimobiledevice are below.
Get a list of all currently connected devices using:
using Netimobiledevice.Usbmuxd;
List<UsbmuxdDevice> devices = Usbmux.GetDeviceList();
Console.WriteLine($"There's {devices.Count} devices connected");
foreach (UsbmuxdDevice device in devices) {
Console.WriteLine($"Device found: {device.DeviceId} - {device.Serial}");
}
Listen to connection events:
Usbmux.Subscribe(SubscriptionCallback);
private static void SubscriptionCallback(UsbmuxdDevice device, UsbmuxdConnectionEventType connectionEvent)
{
Console.WriteLine("NewCallbackExecuted");
Console.WriteLine($"Connection event: {connectionEvent}");
Console.WriteLine($"Device: {device.DeviceId} - {device.Serial}");
}
Get the app icon displayed on the home screen as a PNG:
using (UsbmuxLockdownClient lockdown = MobileDevice.CreateUsingUsbmux("60653a518d33eb53b3ca2322de3f44e162a42069"))
{
SpringBoardServicesService springBoard = new SpringBoardServicesService(lockdown);
PropertyNode png = springBoard.GetIconPNGData("net.whatsapp.WhatsApp");
}
Create an iTunes backup:
using (UsbmuxLockdownClient lockdown = MobileDevice.CreateUsingUsbmux("60653a518d33eb53b3ca2322de3f44e162a42069")) {
using (Mobilebackup2Service mb2 = new Mobilebackup2Service(lockdown)) {
mb2.BeforeReceivingFile += BackupJob_BeforeReceivingFile;
mb2.Completed += BackupJob_Completed;
mb2.Error += BackupJob_Error;
mb2.FileReceived += BackupJob_FileReceived;
mb2.FileReceiving += BackupJob_FileReceiving;
mb2.FileTransferError += BackupJob_FileTransferError;
mb2.PasscodeRequiredForBackup += BackupJob_PasscodeRequiredForBackup;
mb2.Progress += BackupJob_Progress;
mb2.Status += BackupJob_Status;
mb2.Started += BackupJob_Started;
await mb2.Backup(true, "backups", tokenSource.Token);
}
}
Pair an iOS device asyncronously:
using (UsbmuxLockdownClient lockdown = MobileDevice.CreateUsingUsbmux(testDevice?.Serial ?? string.Empty)) {
Progress<PairingState> progress = new();
progress.ProgressChanged += Progress_ProgressChanged;
await lockdown.PairAsync(progress);
}
private void Progress_ProgressChanged(object? sender, PairingState e)
{
Console.WriteLine($"Pair Progress Changed: {e}");
}
Get structured logging information using the logger of your choice (provided it can interact with Microsoft.Extentions.Logging ILogger):
using Microsoft.Extensions.Logging;
using ILoggerFactory factory = LoggerFactory.Create(builder => builder.SetMinimumLevel(LogLevel.Debug).AddConsole());
using (LockdownClient lockdown = MobileDevice.CreateUsingUsbmux(testDevice?.Serial ?? string.Empty, logger: factory.CreateLogger("Netimobiledevice"))) {
using (DeviceBackup backupJob = new DeviceBackup(lockdown, path)) {
await backupJob.Start(tokenSource.Token);
}
}
The list of all the services from lockdownd which have been implemented and the functions available for each one. Clicking on the service name will take you to it's implementation, to learn more about it.
- com.apple.afc
- Interact with the publicly available directories and files
- com.apple.mobile.heartbeat
- A regular ping to used to keep an active connection with lockdownd
- com.apple.misagent
- Management for provisioning profiles
- com.apple.mobile.diagnostics_relay
- Query MobileGestalt & IORegistry keys.
- Reboot, shutdown or put the device in sleep mode.
- com.apple.mobile.installation_proxy
- Browse installed applications
- Manage applications (install/uninstall/update)
- com.apple.mobile.notification_proxy & com.apple.mobile.insecure_notification_proxy
- Send and receive notifications from the device for example informing a backup sync is about to occur.
- com.apple.mobilebackup2
- Backup Creation
- Restore a backup to the iOS device
- Communication with the Backup service
- com.apple.os_trace_relay
- Get pid list
- More structural syslog lines.
- com.apple.springboardservices
- Get icons from the installed apps on the device.
- com.apple.syslog_relay
- Stream raw syslog lines from the device.
This project is licensed under the MIT LICENSE.
Contributions are welcome. Please submit a pull request or create an issue to discuss your proposed changes.
This library was based on the following repositories with either some refactoring or in the case of libraries such as libusbmuxd translating from C to C#.
- BitConverter: Provides a big-endian and little-endian BitConverter that convert base data types to an array of bytes, and an array of bytes to base data types, regardless of machine architecture.
- libimobiledevice: A cross-platform protocol library to communicate with iOS devices
- libusbmuxd: A client library for applications to handle usbmux protocol connections with iOS devices.
- MobileDeviceSharp: A C# object oriented wrapper around Libimobiledevice
- PList-Net: .Net Library for working with Apple *.plist Files.
- pymobiledevice3: A pure python3 implementation to work with iOS devices.
- UniversalTunTapDriver: A driver for TUN/TAP devices to support basic operations on both linux and windows platform.