frida / frida-node

Frida Node.js bindings
277 stars 65 forks source link

Attaching script when spawning Android application #75

Open daMatz opened 2 years ago

daMatz commented 2 years ago

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).

mamidon commented 1 year ago

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?