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" when using the bindings in macOS #174

Open
suidpit opened this issue Nov 4, 2024 · 0 comments
Open

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

suidpit opened this issue Nov 4, 2024 · 0 comments

Comments

@suidpit
Copy link

suidpit commented Nov 4, 2024

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

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

1 participant