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

Attaching script when spawning Android application

Open daMatz opened this issue 2 years ago • 1 comments

I am able to start an Android application and attach a script to it like this:

const device = await frida.getUsbDevice();
const pid = await device.spawn(packageName);
const session = await device.attach(pid);
const source = await fs.promises.readFile(scriptPath, { encoding: "utf8" });
const script = await session.createScript(source);
await script.load();
await device.resume(pid);

From my understanding this spawns the process and attaches the script while it's already running.

What I want to do, is the equivalent to the CLI command: frida -U --no-pause -l script.js -f com.package. Is this possible?

I already looked into SpawnOptions for spawn(), but didn't manage to utilize them (e.g. getting errors like [Error: The 'argv' option is not supported when spawning Android apps] for most).

daMatz avatar Aug 05 '22 13:08 daMatz

Hopefully related, I'd like to attach a script before Android has done a bunch of startup stuff. It seems that processes spawned by Frida used to be paused by default -- https://github.com/frida/frida/issues/2277. Is there an option to spawn a process in a paused state?

mamidon avatar Aug 18 '23 23:08 mamidon