mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Merge branch 'master' into rppairing
This commit is contained in:
@@ -129,6 +129,19 @@ path = "src/pcapd.rs"
|
||||
name = "preboard"
|
||||
path = "src/preboard.rs"
|
||||
|
||||
|
||||
[[bin]]
|
||||
name = "screenshot"
|
||||
path = "src/screenshot.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "activation"
|
||||
path = "src/activation.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "notifications"
|
||||
path = "src/notifications.rs"
|
||||
|
||||
[dependencies]
|
||||
idevice = { path = "../idevice", features = ["full"], default-features = false }
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
|
||||
113
tools/src/activation.rs
Normal file
113
tools/src/activation.rs
Normal file
@@ -0,0 +1,113 @@
|
||||
// Jackson Coxson
|
||||
|
||||
use clap::{Arg, Command};
|
||||
use idevice::{
|
||||
IdeviceService, lockdown::LockdownClient, mobileactivationd::MobileActivationdClient,
|
||||
};
|
||||
|
||||
mod common;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let matches = Command::new("activation")
|
||||
.about("mobileactivationd")
|
||||
.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("about")
|
||||
.long("about")
|
||||
.help("Show about information")
|
||||
.action(clap::ArgAction::SetTrue),
|
||||
)
|
||||
.subcommand(Command::new("state").about("Gets the activation state"))
|
||||
.subcommand(Command::new("deactivate").about("Deactivates the device"))
|
||||
.get_matches();
|
||||
|
||||
if matches.get_flag("about") {
|
||||
println!("activation - activate the device");
|
||||
println!("Copyright (c) 2025 Jackson Coxson");
|
||||
return;
|
||||
}
|
||||
|
||||
let udid = matches.get_one::<String>("udid");
|
||||
let host = matches.get_one::<String>("host");
|
||||
let pairing_file = matches.get_one::<String>("pairing_file");
|
||||
|
||||
let provider = match common::get_provider(udid, host, pairing_file, "activation-jkcoxson").await
|
||||
{
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let activation_client = MobileActivationdClient::new(&*provider);
|
||||
let mut lc = LockdownClient::connect(&*provider)
|
||||
.await
|
||||
.expect("no lockdown");
|
||||
lc.start_session(&provider.get_pairing_file().await.unwrap())
|
||||
.await
|
||||
.expect("no TLS");
|
||||
let udid = lc
|
||||
.get_value(Some("UniqueDeviceID"), None)
|
||||
.await
|
||||
.expect("no udid")
|
||||
.into_string()
|
||||
.unwrap();
|
||||
|
||||
if matches.subcommand_matches("state").is_some() {
|
||||
let s = activation_client.state().await.expect("no state");
|
||||
println!("Activation State: {s}");
|
||||
} else if matches.subcommand_matches("deactivate").is_some() {
|
||||
println!("CAUTION: You are deactivating {udid}, press enter to continue.");
|
||||
let mut input = String::new();
|
||||
std::io::stdin().read_line(&mut input).ok();
|
||||
activation_client.deactivate().await.expect("no deactivate");
|
||||
// } else if matches.subcommand_matches("accept").is_some() {
|
||||
// amfi_client
|
||||
// .accept_developer_mode()
|
||||
// .await
|
||||
// .expect("Failed to show");
|
||||
// } else if matches.subcommand_matches("status").is_some() {
|
||||
// let status = amfi_client
|
||||
// .get_developer_mode_status()
|
||||
// .await
|
||||
// .expect("Failed to get status");
|
||||
// println!("Enabled: {status}");
|
||||
// } else if let Some(matches) = matches.subcommand_matches("state") {
|
||||
// let uuid: &String = match matches.get_one("uuid") {
|
||||
// Some(u) => u,
|
||||
// None => {
|
||||
// eprintln!("No UUID passed. Invalid usage, pass -h for help");
|
||||
// return;
|
||||
// }
|
||||
// };
|
||||
// let status = amfi_client
|
||||
// .trust_app_signer(uuid)
|
||||
// .await
|
||||
// .expect("Failed to get state");
|
||||
// println!("Enabled: {status}");
|
||||
} else {
|
||||
eprintln!("Invalid usage, pass -h for help");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
use clap::{Arg, Command};
|
||||
use idevice::{IdeviceService, RsdService, core_device_proxy::CoreDeviceProxy, rsd::RsdHandshake};
|
||||
|
||||
use idevice::dvt::location_simulation::LocationSimulationClient;
|
||||
use idevice::services::simulate_location::LocationSimulationService;
|
||||
mod common;
|
||||
|
||||
#[tokio::main]
|
||||
@@ -63,65 +65,103 @@ async fn main() {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let proxy = CoreDeviceProxy::connect(&*provider)
|
||||
|
||||
if let Ok(proxy) = CoreDeviceProxy::connect(&*provider).await {
|
||||
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 ls_client = idevice::dvt::remote_server::RemoteServerClient::connect_rsd(
|
||||
&mut adapter,
|
||||
&mut handshake,
|
||||
)
|
||||
.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 ls_client =
|
||||
idevice::dvt::remote_server::RemoteServerClient::connect_rsd(&mut adapter, &mut handshake)
|
||||
.await
|
||||
.expect("Failed to connect");
|
||||
ls_client.read_message(0).await.expect("no read??");
|
||||
|
||||
let mut ls_client =
|
||||
idevice::dvt::location_simulation::LocationSimulationClient::new(&mut ls_client)
|
||||
.expect("Failed to connect");
|
||||
ls_client.read_message(0).await.expect("no read??");
|
||||
let mut ls_client = LocationSimulationClient::new(&mut ls_client)
|
||||
.await
|
||||
.expect("Unable to get channel for location simulation");
|
||||
|
||||
if matches.subcommand_matches("clear").is_some() {
|
||||
ls_client.clear().await.expect("Unable to clear");
|
||||
println!("Location cleared!");
|
||||
} else if let Some(matches) = matches.subcommand_matches("set") {
|
||||
let latitude: &String = match matches.get_one("latitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No latitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let latitude: f64 = latitude.parse().expect("Failed to parse as float");
|
||||
let longitude: &String = match matches.get_one("longitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No longitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let longitude: f64 = longitude.parse().expect("Failed to parse as float");
|
||||
ls_client
|
||||
.set(latitude, longitude)
|
||||
.await
|
||||
.expect("Failed to set location");
|
||||
|
||||
println!("Location set!");
|
||||
println!("Press ctrl-c to stop");
|
||||
loop {
|
||||
if matches.subcommand_matches("clear").is_some() {
|
||||
ls_client.clear().await.expect("Unable to clear");
|
||||
println!("Location cleared!");
|
||||
} else if let Some(matches) = matches.subcommand_matches("set") {
|
||||
let latitude: &String = match matches.get_one("latitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No latitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let latitude: f64 = latitude.parse().expect("Failed to parse as float");
|
||||
let longitude: &String = match matches.get_one("longitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No longitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let longitude: f64 = longitude.parse().expect("Failed to parse as float");
|
||||
ls_client
|
||||
.set(latitude, longitude)
|
||||
.await
|
||||
.expect("Failed to set location");
|
||||
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
||||
|
||||
println!("Location set!");
|
||||
println!("Press ctrl-c to stop");
|
||||
loop {
|
||||
ls_client
|
||||
.set(latitude, longitude)
|
||||
.await
|
||||
.expect("Failed to set location");
|
||||
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
||||
}
|
||||
} else {
|
||||
eprintln!("Invalid usage, pass -h for help");
|
||||
}
|
||||
} else {
|
||||
eprintln!("Invalid usage, pass -h for help");
|
||||
}
|
||||
let mut location_client = match LocationSimulationService::connect(&*provider).await {
|
||||
Ok(client) => client,
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"Unable to connect to simulate_location service: {e} Ensure Developer Disk Image is mounted."
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
if matches.subcommand_matches("clear").is_some() {
|
||||
location_client.clear().await.expect("Unable to clear");
|
||||
println!("Location cleared!");
|
||||
} else if let Some(matches) = matches.subcommand_matches("set") {
|
||||
let latitude: &String = match matches.get_one("latitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No latitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let longitude: &String = match matches.get_one("longitude") {
|
||||
Some(l) => l,
|
||||
None => {
|
||||
eprintln!("No longitude passed! Pass -h for help");
|
||||
return;
|
||||
}
|
||||
};
|
||||
location_client
|
||||
.set(latitude, longitude)
|
||||
.await
|
||||
.expect("Failed to set location");
|
||||
|
||||
println!("Location set!");
|
||||
} else {
|
||||
eprintln!("Invalid usage, pass -h for help");
|
||||
}
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
101
tools/src/notifications.rs
Normal file
101
tools/src/notifications.rs
Normal file
@@ -0,0 +1,101 @@
|
||||
// Monitor memory and app notifications
|
||||
|
||||
use clap::{Arg, Command};
|
||||
use idevice::{IdeviceService, RsdService, core_device_proxy::CoreDeviceProxy, rsd::RsdHandshake};
|
||||
mod common;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
let matches = Command::new("notifications")
|
||||
.about("start notifications")
|
||||
.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("about")
|
||||
.long("about")
|
||||
.help("Show about information")
|
||||
.action(clap::ArgAction::SetTrue),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if matches.get_flag("about") {
|
||||
print!("notifications - start notifications to ios device");
|
||||
println!("Copyright (c) 2025 Jackson Coxson");
|
||||
return;
|
||||
}
|
||||
|
||||
let udid = matches.get_one::<String>("udid");
|
||||
let host = matches.get_one::<String>("host");
|
||||
let pairing_file = matches.get_one::<String>("pairing_file");
|
||||
|
||||
let provider =
|
||||
match common::get_provider(udid, host, pairing_file, "notifications-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 ts_client =
|
||||
idevice::dvt::remote_server::RemoteServerClient::connect_rsd(&mut adapter, &mut handshake)
|
||||
.await
|
||||
.expect("Failed to connect");
|
||||
ts_client.read_message(0).await.expect("no read??");
|
||||
let mut notification_client =
|
||||
idevice::dvt::notifications::NotificationsClient::new(&mut ts_client)
|
||||
.await
|
||||
.expect("Unable to get channel for notifications");
|
||||
notification_client
|
||||
.start_notifications()
|
||||
.await
|
||||
.expect("Failed to start notifications");
|
||||
|
||||
// Handle Ctrl+C gracefully
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
println!("\nShutdown signal received, exiting.");
|
||||
break;
|
||||
}
|
||||
|
||||
// Branch 2: Wait for the next batch of notifications.
|
||||
result = notification_client.get_notification() => {
|
||||
if let Err(e) = result {
|
||||
eprintln!("Failed to get notifications: {}", e);
|
||||
} else {
|
||||
println!("Received notifications: {:#?}", result.unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use idevice::{
|
||||
};
|
||||
|
||||
mod common;
|
||||
mod pcap;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
||||
109
tools/src/screenshot.rs
Normal file
109
tools/src/screenshot.rs
Normal file
@@ -0,0 +1,109 @@
|
||||
use clap::{Arg, Command};
|
||||
use idevice::{IdeviceService, RsdService, core_device_proxy::CoreDeviceProxy, rsd::RsdHandshake};
|
||||
use std::fs;
|
||||
|
||||
use idevice::screenshotr::ScreenshotService;
|
||||
|
||||
mod common;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
let matches = Command::new("screen_shot")
|
||||
.about("take screenshot")
|
||||
.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("output")
|
||||
.short('o')
|
||||
.long("output")
|
||||
.value_name("FILE")
|
||||
.help("Output file path for the screenshot (default: ./screenshot.png)")
|
||||
.default_value("screenshot.png"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("about")
|
||||
.long("about")
|
||||
.help("Show about information")
|
||||
.action(clap::ArgAction::SetTrue),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if matches.get_flag("about") {
|
||||
print!("screen_shot - take screenshot from ios device");
|
||||
println!("Copyright (c) 2025 Jackson Coxson");
|
||||
return;
|
||||
}
|
||||
|
||||
let udid = matches.get_one::<String>("udid");
|
||||
let host = matches.get_one::<String>("host");
|
||||
let pairing_file = matches.get_one::<String>("pairing_file");
|
||||
let output_path = matches.get_one::<String>("output").unwrap();
|
||||
|
||||
let provider =
|
||||
match common::get_provider(udid, host, pairing_file, "take_screenshot-jkcoxson").await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let res = if let Ok(proxy) = CoreDeviceProxy::connect(&*provider).await {
|
||||
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 ts_client = idevice::dvt::remote_server::RemoteServerClient::connect_rsd(
|
||||
&mut adapter,
|
||||
&mut handshake,
|
||||
)
|
||||
.await
|
||||
.expect("Failed to connect");
|
||||
ts_client.read_message(0).await.expect("no read??");
|
||||
|
||||
let mut ts_client = idevice::dvt::screenshot::ScreenshotClient::new(&mut ts_client)
|
||||
.await
|
||||
.expect("Unable to get channel for take screenshot");
|
||||
ts_client
|
||||
.take_screenshot()
|
||||
.await
|
||||
.expect("Failed to take screenshot")
|
||||
} else {
|
||||
let mut screenshot_client = match ScreenshotService::connect(&*provider).await {
|
||||
Ok(client) => client,
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
"Unable to connect to screenshotr service: {e} Ensure Developer Disk Image is mounted."
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
screenshot_client.take_screenshot().await.unwrap()
|
||||
};
|
||||
|
||||
match fs::write(output_path, res) {
|
||||
Ok(_) => println!("Screenshot saved to: {}", output_path),
|
||||
Err(e) => eprintln!("Failed to write screenshot to file: {}", e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user