frida/frida-node

Attaching script when spawning Android application

daMatz opened this issue · 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).

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 -- frida/frida#2277. Is there an option to spawn a process in a paused state?