From e972352cd0fe3dc32849cd4cb94f47c14428647b Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Wed, 30 Apr 2025 08:51:59 -0600 Subject: [PATCH] Use device MAC, not host --- Cargo.lock | 1 - idevice/src/lockdown.rs | 12 +++++++++--- tools/Cargo.toml | 1 - tools/src/pair.rs | 7 +------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea0f51a..e0c83c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1236,7 +1236,6 @@ dependencies = [ "env_logger 0.11.8", "idevice", "log", - "mac_address", "ns-keyed-archive", "plist", "sha2", diff --git a/idevice/src/lockdown.rs b/idevice/src/lockdown.rs index 4dd2d2e..d9f8d14 100644 --- a/idevice/src/lockdown.rs +++ b/idevice/src/lockdown.rs @@ -258,7 +258,6 @@ impl LockdownClient { /// /// # Arguments /// * `host_id` - The host ID, in the form of a UUID. Typically generated from the host name - /// * `wifi_mac` - The MAC address of the WiFi interface. Does not affect anything. /// * `system_buid` - UUID fetched from usbmuxd. Doesn't appear to affect function. /// /// # Returns @@ -270,11 +269,9 @@ impl LockdownClient { pub async fn pair( &mut self, host_id: impl Into, - wifi_mac: impl Into, system_buid: impl Into, ) -> Result { let host_id = host_id.into(); - let wifi_mac = wifi_mac.into(); let system_buid = system_buid.into(); let pub_key = self.get_value("DevicePublicKey", None).await?; @@ -286,6 +283,15 @@ impl LockdownClient { } }; + let wifi_mac = self.get_value("WiFiAddress", None).await?; + let wifi_mac = match wifi_mac.as_string() { + Some(w) => w, + None => { + log::warn!("Did not get WiFiAddress string"); + return Err(IdeviceError::UnexpectedResponse); + } + }; + let ca = crate::ca::generate_certificates(&pub_key, None).unwrap(); let mut pair_record = plist::Dictionary::new(); pair_record.insert("DevicePublicKey".into(), plist::Value::Data(pub_key)); diff --git a/tools/Cargo.toml b/tools/Cargo.toml index 5012a64..a55b815 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -81,7 +81,6 @@ clap = { version = "4.5" } plist = { version = "1.7" } ns-keyed-archive = "0.1.2" uuid = "1.16" -mac_address = "1.1" # When testing the pair binary, creating certificates takes forever [profile.dev.package.idevice] diff --git a/tools/src/pair.rs b/tools/src/pair.rs index a0d0bc2..19f16df 100644 --- a/tools/src/pair.rs +++ b/tools/src/pair.rs @@ -6,7 +6,6 @@ use idevice::{ usbmuxd::{Connection, UsbmuxdAddr, UsbmuxdConnection}, IdeviceService, }; -use mac_address::get_mac_address; mod common; @@ -63,14 +62,10 @@ async fn main() { return; } }; - let mac_address = get_mac_address() - .expect("Failed to get MAC") - .expect("No MAC??") - .to_string(); let id = uuid::Uuid::new_v4().to_string().to_uppercase(); let mut pairing_file = lockdown_client - .pair(id, mac_address, u.get_buid().await.unwrap()) + .pair(id, u.get_buid().await.unwrap()) .await .expect("Failed to pair");