Skip to content

"Failed to attach" when using the bindings in macOS #174

@suidpit

Description

@suidpit

I have the following code:

use frida::Frida;
use frida::ScriptOption;
use lazy_static::lazy_static;

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

fn main() {
    let device_manager = frida::DeviceManager::obtain(&FRIDA);
    let local_device = device_manager.get_local_device().unwrap();
    let session = match local_device.attach(9166) {
        Ok(session) => session,
        Err(e) => {
            eprintln!("Failed to attach to process: {}", e);
            return;
        }
    };
    let mut script = session.create_script(
        "
        console.log(Process.enumerateRangesSync('rw-'))
    ", &mut ScriptOption::default(),
    ).unwrap();
    let handler = Handler;
    script.handle_message(handler).unwrap();
    script.load().unwrap();
    std::thread::sleep(std::time::Duration::from_secs(10));
}

struct Handler;

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

PID 9166 points to a process running in my system.

When running it, I get the following:

Failed to attach to process: Failed to attach

For reference, this is what happens when doing the same with the python bindings:

>>> import frida
>>> frida.get_local_device().attach(9166)
Session(pid=9166)
>>>

SIP is disabled, running on M1 Pro 14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions