Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to Attach on usb device #162

Open
chihaamin opened this issue Sep 24, 2024 · 5 comments
Open

Failed to Attach on usb device #162

chihaamin opened this issue Sep 24, 2024 · 5 comments

Comments

@chihaamin
Copy link

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

@s1341
Copy link
Contributor

s1341 commented Sep 24, 2024

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

@chihaamin
Copy link
Author

android

@s1341
Copy link
Contributor

s1341 commented Sep 25, 2024

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

@chihaamin
Copy link
Author

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

@s1341
Copy link
Contributor

s1341 commented Sep 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants