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

session.create_script(path) fails when importing from node_modules #78

Open
Myles1 opened this issue Jun 22, 2023 · 1 comment
Open

Comments

@Myles1
Copy link

Myles1 commented Jun 22, 2023

I'm using typescript for a frida module that's being loaded on Android.

Reproduction steps:
git clone https://github.com/oleavr/frida-agent-example.git
cd frida-agent-example
npm install
npm run build

Create this python file:

import frida
import pathlib
process_name: str = "My android app"
def main():
    device: frida.core.Device = frida.get_usb_device()
    sess: frida.core.Session
    sess = device.attach(process_name)
    script_path: pathlib.Path = pathlib.Path("_agent.js")
    assert script_path.exists()
    script: frida.core.Script = sess.create_script(script_path.read_text())
    script.load()
if __name__ == "__main__":
    main()

That all works, but when I add a package:
npm install --save rxjs
Then import that package in index.ts:

import {Observable} from "rxjs";
let observable = new Observable();

Then build again npm run build
The build step completes, but when I try to load the script through python I'm getting this error:

Traceback (most recent call last):
  File "/home/myles/frida-agent-example/frida-gadget-main.py", line 13, in <module>
    main()
  File "/home/myles/frida-agent-example/frida-gadget-main.py", line 10, in main
    script: frida.core.Script = sess.create_script(script_path.read_text())
  File "/home/myles/frida-agent-example/venv/lib/python3.10/site-packages/frida/core.py", line 86, in wrapper
    return f(*args, **kwargs)
  File "/home/myles/frida-agent-example/venv/lib/python3.10/site-packages/frida/core.py", line 628, in create_script
    return Script(self._impl.create_script(source, **kwargs))  # type: ignore
frida.InvalidArgumentError: could not load module '/node_modules/rxjs/dist/esm5/internal/Observable'

Any ideas on what I'm doing wrong here? How can I get it to pick up imports from node_modules?

@Myles1
Copy link
Author

Myles1 commented Jun 22, 2023

Side-note, esbuild seems to work correctly as a replacement in this case

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