6个版本
0.1.7 | 2022年10月24日 |
---|---|
0.1.6 | 2022年9月16日 |
0.1.2 | 2022年7月7日 |
#637 in 加密学
1MB
21K SLoC
rusty_libimobiledevice
Rusty Libimobiledevice - 一个用于与iOS设备通信的人性化库。
测试等级:0.00% - 通过战斗测试方法来为此库做出贡献!所有函数都应该经过测试以确保没有段错误和内存泄露。
如果你看到 Verified: False
,这意味着该函数需要你的帮助以确保其安全性。提交一个包含你的测试代码的PR以更改函数的状态。
构建
构建并安装以下包
注意:包管理器不提供静态库,所以如果你需要编译静态库,需要自己构建。
要交叉编译此crate,可以使用vendored
功能,构建脚本将尝试克隆并构建指定的目标。
使用
将crate和路径添加到你的cargo.toml中,并在功能列表中添加static
或dynamic
。这将确定库的链接方式。默认情况下这是动态的。你也可以使用vendored
功能在编译时构建libimobiledevice。
查看工具目录以获取如何使用此库的完整示例。它包含许多常见用例。
要列出由usbmuxd守护进程检测到的设备,可以使用以下示例。
// Include the idevice module. Will be needed in most scenarios.
use rusty_libimobiledevice::idevice;
fn main() {
// Get all devices attatched from the usbmuxd daemon
let devices = match idevice::get_devices() {
Ok(devices) => devices,
Err(e) => {
// If the daemon is not running or does not behave as expected, this returns an error
println!("Error getting devices: {:?}", e);
return;
}
};
// Devices support the display trait and can be viewed as such
println!("Devices found: {:?}", devices);
}
更复杂的代码可以跳过从usbmuxd获取设备并直接连接到网络设备。
服务
此库实现了iOS设备的一些服务的方法。这些方法可以用于操作设备上的功能。例如,你可以使用以下示例获取设备上安装的应用程序列表
use rusty_libimobiledevice::idevice;
fn print_apps(udid: String) {
// Get the device from usbmuxd using the given UDID
let device = match idevice::get_device(udid.to_string()) {
Ok(device) => device,
Err(e) => {
println!("Error: Could not find device: {:?}", e);
return;
}
};
// Start an instproxy service on the device
let instproxy_client = match device.new_instproxy_client("idevicelistapps".to_string()) {
Ok(instproxy) => {
println!("Successfully started instproxy");
instproxy
}
Err(e) => {
println!("Error starting instproxy: {:?}", e);
return;
}
};
// Create a request to be sent using the service
let mut client_opts = InstProxyClient::options_new();
InstProxyClient::options_add(
&mut client_opts,
vec![("ApplicationType".to_string(), Plist::new_string("Any"))],
);
InstProxyClient::options_set_return_attributes(
&mut client_opts,
vec![
"CFBundleIdentifier".to_string(),
"CFBundleExecutable".to_string(),
"Container".to_string(),
],
);
// Send the request and get the lookup results as a plist
let lookup_results = match instproxy_client.lookup(vec![], client_opts) {
Ok(apps) => {
println!("Successfully looked up apps");
apps
}
Err(e) => {
println!("Error looking up apps: {:?}", e);
return;
}
};
println!("{}", lookup_results.to_string());
}
依赖
~2.2–5.5MB
~113K SLoC