frida-rust icon indicating copy to clipboard operation
frida-rust copied to clipboard

Failed to Attach on usb device

Open chihaamin opened this issue 1 year ago • 5 comments

use frida::{Frida, ScriptHandler, ScriptOption, ScriptRuntime, SpawnOptions}; use lazy_static::lazy_static;

lazy_static! { static ref FRIDA: Frida = unsafe { Frida::obtain() }; }

fn main() { let device_manager = frida::DeviceManager::obtain(&FRIDA); let mut usb = device_manager .get_device_by_type(frida::DeviceType::USB) .unwrap();

let mut pid: u32 = 0;
// let mut so = SpawnOptions::new();
// let pid = usb.spawn("testApp", &mut so).unwrap(); -> cause inf loop
for proc in usb.enumerate_processes() {
    if proc.get_name() == String::from("testApp") {
        println!("{} {}", proc.get_name(), proc.get_pid());
        pid = proc.get_pid()
    }
}
let session = usb.attach(pid); -> doesn't attach
match session {
    Ok(_s) => {}
    Err(e) => println!("{}", e),
}

}

struct Handler;

impl Handler { fn new() -> Self { Self } }

impl ScriptHandler for Handler { fn on_message(&mut self, message: &str) { println!("{:?}", message); } }

// output testApp 6873 Failed to attach

chihaamin avatar Sep 24 '24 09:09 chihaamin

Not sure it matters, but is it an android or iOS device?

s1341 avatar Sep 24 '24 09:09 s1341

android

chihaamin avatar Sep 24 '24 21:09 chihaamin

does regular frida-tools work on this computer/device?

s1341 avatar Sep 25 '24 04:09 s1341

Yes on windows everything works fine but when I use it for usb or using tcpip it doesn't work , when I spawn a process it get spawned in the android but the pid doesn't get returned and it get stuck in an infinite loop I tried to spawn the process then grab the pid of it : for proc in usb.enumerate_processes() { if proc.get_name() == String::from("testApp") { println!("{} {}", proc.get_name(), proc.get_pid()); pid = proc.get_pid() } } it doesn't attach to it

chihaamin avatar Sep 26 '24 17:09 chihaamin

can you confirm that adb works on this computer/device combination?

s1341 avatar Sep 29 '24 10:09 s1341