Add house arrest to AFC cli

This commit is contained in:
Jackson Coxson
2025-05-09 15:49:04 -06:00
parent 041899baf1
commit b60e3dc0fb
3 changed files with 40 additions and 5 deletions

View File

@@ -88,6 +88,7 @@ full = [
"debug_proxy", "debug_proxy",
"dvt", "dvt",
"heartbeat", "heartbeat",
"house_arrest",
"installation_proxy", "installation_proxy",
"misagent", "misagent",
"mobile_image_mounter", "mobile_image_mounter",

View File

@@ -90,7 +90,9 @@ impl HouseArrestClient {
self.vend(bundle_id, "VendContainer".into()).await self.vend(bundle_id, "VendContainer".into()).await
} }
/// Requests access to the app's Documents directory over AFC /// Requests access to the app's Documents directory over AFC.
/// Note that you can only access the /Documents directory. Permission will be denied
/// otherwise.
/// ///
/// # Arguments /// # Arguments
/// * `bundle_id` - The bundle identifier of the target app (e.g., "com.example.MyApp") /// * `bundle_id` - The bundle identifier of the target app (e.g., "com.example.MyApp")

View File

@@ -5,6 +5,7 @@ use std::path::PathBuf;
use clap::{value_parser, Arg, Command}; use clap::{value_parser, Arg, Command};
use idevice::{ use idevice::{
afc::{opcode::AfcFopenMode, AfcClient}, afc::{opcode::AfcFopenMode, AfcClient},
house_arrest::HouseArrestClient,
IdeviceService, IdeviceService,
}; };
@@ -15,7 +16,7 @@ async fn main() {
env_logger::init(); env_logger::init();
let matches = Command::new("afc") let matches = Command::new("afc")
.about("Start a tunnel") .about("Manage files on the device")
.arg( .arg(
Arg::new("host") Arg::new("host")
.long("host") .long("host")
@@ -33,6 +34,20 @@ async fn main() {
.value_name("UDID") .value_name("UDID")
.help("UDID of the device (overrides host/pairing file)"), .help("UDID of the device (overrides host/pairing file)"),
) )
.arg(
Arg::new("documents")
.long("documents")
.value_name("BUNDLE_ID")
.help("Read the documents from a bundle. Note that when vending documents, you can only access files in /Documents")
.global(true),
)
.arg(
Arg::new("container")
.long("container")
.value_name("BUNDLE_ID")
.help("Read the container contents of a bundle")
.global(true),
)
.arg( .arg(
Arg::new("about") Arg::new("about")
.long("about") .long("about")
@@ -101,9 +116,26 @@ async fn main() {
return; return;
} }
}; };
let mut afc_client = AfcClient::connect(&*provider)
.await let mut afc_client = if let Some(bundle_id) = matches.get_one::<String>("container") {
.expect("Unable to connect to misagent"); let h = HouseArrestClient::connect(&*provider)
.await
.expect("Failed to connect to house arrest");
h.vend_container(bundle_id)
.await
.expect("Failed to vend container")
} else if let Some(bundle_id) = matches.get_one::<String>("documents") {
let h = HouseArrestClient::connect(&*provider)
.await
.expect("Failed to connect to house arrest");
h.vend_documents(bundle_id)
.await
.expect("Failed to vend documents")
} else {
AfcClient::connect(&*provider)
.await
.expect("Unable to connect to misagent")
};
if let Some(matches) = matches.subcommand_matches("list") { if let Some(matches) = matches.subcommand_matches("list") {
let path = matches.get_one::<String>("path").expect("No path passed"); let path = matches.get_one::<String>("path").expect("No path passed");