mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Implement diagnosticsservice
This commit is contained in:
@@ -105,6 +105,10 @@ path = "src/diagnostics.rs"
|
||||
name = "mobilebackup2"
|
||||
path = "src/mobilebackup2.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "diagnosticsservice"
|
||||
path = "src/diagnosticsservice.rs"
|
||||
|
||||
[dependencies]
|
||||
idevice = { path = "../idevice", features = ["full"], default-features = false }
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
@@ -117,6 +121,7 @@ clap = { version = "4.5" }
|
||||
plist = { version = "1.7" }
|
||||
ns-keyed-archive = "0.1.2"
|
||||
uuid = "1.16"
|
||||
futures-util = { version = "0.3" }
|
||||
|
||||
[features]
|
||||
default = ["aws-lc"]
|
||||
|
||||
106
tools/src/diagnosticsservice.rs
Normal file
106
tools/src/diagnosticsservice.rs
Normal file
@@ -0,0 +1,106 @@
|
||||
// Jackson Coxson
|
||||
|
||||
use clap::{Arg, Command};
|
||||
use futures_util::StreamExt;
|
||||
use idevice::{
|
||||
IdeviceService, RsdService, core_device::DiagnostisServiceClient,
|
||||
core_device_proxy::CoreDeviceProxy, rsd::RsdHandshake,
|
||||
};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
mod common;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let matches = Command::new("remotexpc")
|
||||
.about("Gets a sysdiagnose")
|
||||
.arg(
|
||||
Arg::new("host")
|
||||
.long("host")
|
||||
.value_name("HOST")
|
||||
.help("IP address of the device"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("pairing_file")
|
||||
.long("pairing-file")
|
||||
.value_name("PATH")
|
||||
.help("Path to the pairing file"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("udid")
|
||||
.value_name("UDID")
|
||||
.help("UDID of the device (overrides host/pairing file)")
|
||||
.index(1),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("tunneld")
|
||||
.long("tunneld")
|
||||
.help("Use tunneld")
|
||||
.action(clap::ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("about")
|
||||
.long("about")
|
||||
.help("Show about information")
|
||||
.action(clap::ArgAction::SetTrue),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if matches.get_flag("about") {
|
||||
println!("debug_proxy - connect to the debug proxy and run commands");
|
||||
println!("Copyright (c) 2025 Jackson Coxson");
|
||||
return;
|
||||
}
|
||||
|
||||
let udid = matches.get_one::<String>("udid");
|
||||
let pairing_file = matches.get_one::<String>("pairing_file");
|
||||
let host = matches.get_one::<String>("host");
|
||||
|
||||
let provider =
|
||||
match common::get_provider(udid, host, pairing_file, "diagnosticsservice-jkcoxson").await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let proxy = CoreDeviceProxy::connect(&*provider)
|
||||
.await
|
||||
.expect("no core proxy");
|
||||
let rsd_port = proxy.handshake.server_rsd_port;
|
||||
|
||||
let adapter = proxy.create_software_tunnel().expect("no software tunnel");
|
||||
let mut adapter = adapter.to_async_handle();
|
||||
|
||||
let stream = adapter.connect(rsd_port).await.expect("no RSD connect");
|
||||
|
||||
// Make the connection to RemoteXPC
|
||||
let mut handshake = RsdHandshake::new(stream).await.unwrap();
|
||||
|
||||
let mut dsc = DiagnostisServiceClient::connect_rsd(&mut adapter, &mut handshake)
|
||||
.await
|
||||
.expect("no connect");
|
||||
|
||||
println!("Getting sysdiagnose, this takes a while! iOS is slow...");
|
||||
let mut res = dsc
|
||||
.capture_sysdiagnose(false)
|
||||
.await
|
||||
.expect("no sysdiagnose");
|
||||
println!("Got sysdaignose! Saving to file");
|
||||
|
||||
let mut written = 0usize;
|
||||
let mut out = tokio::fs::File::create(&res.preferred_filename)
|
||||
.await
|
||||
.expect("no file?");
|
||||
while let Some(chunk) = res.stream.next().await {
|
||||
let buf = chunk.expect("stream stopped?");
|
||||
if !buf.is_empty() {
|
||||
out.write_all(&buf).await.expect("no write all?");
|
||||
written += buf.len();
|
||||
}
|
||||
println!("wrote {written}/{} bytes", res.expected_length);
|
||||
}
|
||||
println!("Done! Saved to {}", res.preferred_filename);
|
||||
}
|
||||
Reference in New Issue
Block a user