Cannot access variables in scripts in the interactive shell
Apeng7364 opened this issue · comments
apeng commented
After upgrade to frida-tools 11.0.0, cannot access variables in scripts in the interactive shell
script:
var a = 0;
console.log(a);
run frida and print variable a
in the interactive shell:
❯ frida -f ./a -l ./a.js
____
/ _ | Frida 15.2.2 - A world-class dynamic instrumentation toolkit
| (_| |
> _ | Commands:
/_/ |_| help -> Displays the help system
. . . . object? -> Display information about 'object'
. . . . exit/quit -> Exit
. . . .
. . . . More info at https://frida.re/docs/home/
. . . .
. . . . Connected to Local System (id=local)
Spawning `./a`...
0
Spawned `./a`. Use %resume to let the main thread start executing!
[Local::a ]-> a
ReferenceError: 'a' is not defined
Ole André Vadla Ravnås commented
This is now accomplished by explicitly adding properties to globalThis
. E.g. to expose a function as a
:
globalThis.a = function () {
};
And to expose more than one with minimal boilerplate you can do something like:
function a() {
}
function b() {
}
Object.assign(globalThis, { a, b });