frida / frida-compile

Compile a Frida script comprised of one or more Node.js modules
Other
190 stars 48 forks source link

breaks in wrong workdir: Error: Cannot find module @frida/uglifyify from build/bindings/gumjs #63

Open milahu opened 1 year ago

milahu commented 1 year ago

i get this error in frida-gum when node_modules is not in frida-gum/build/bindings/gumjs/node_modules

[120/214] Generating bindings/gumjs/gumjs-runtime with a custom command
FAILED: bindings/gumjs/gumcmodule-runtime.h bindings/gumjs/gumquickscript-runtime.h bindings/gumjs/gumquickscript-objc.h bindings/gumjs/gumquickscript-java.
h bindings/gumjs/gumv8script-runtime.h bindings/gumjs/gumv8script-objc.h bindings/gumjs/gumv8script-java.h 
/build/source/bindings/gumjs/generate-runtime.py qjs,v8 x86_64 little /build/source/bindings/gumjs /build/source/gum /nix/store/aw5yynzqi8cg4h733qjch53zcm4n
kshr-capstone-5.0-rc2/include/capstone/capstone /nix/store/rz0irj616wmqiqwwmf0zvf86ck9qn144-frida-tinycc-unstable-2022-04-01/lib/tcc/include /build/source/b
uild/bindings/gumjs/quickcompile /build/source/build/bindings/gumjs
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module '@frida/uglifyify' from '/build/source/build/bindings/gumjs'
    at /nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:146:35
    at processDirs (/nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:299:39)
    at isdir (/nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:306:32)
    at /nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:34:69
    at FSReqCallback.oncomplete (node:fs:207:21)
Emitted 'error' event on Browserify instance at:
    at /nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/browserify/index.js:375:34
    at /nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:148:17
    at processDirs (/nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/resolve/lib/async.js:299:39)
    [... lines matching original stack trace ...]
    at FSReqCallback.oncomplete (node:fs:207:21) {
  code: 'MODULE_NOT_FOUND'
}

Node.js v18.13.0
Command '[PosixPath('/nix/store/fap27a1nkgx2xxyh5h3hq333zyim0jcm-node-dependencies-frida-gum-0.0.0/lib/node_modules/.bin/frida-compile'), PosixPath('runtime/entrypoint-quickjs.js'), '-o', PosixPath('runtime-build-quick/frida.js'), '-c']' returned non-zero exit status 1.

for example, when i install frida-compile to a different prefix and patch frida_compile to some absolute path

    frida_compile = output_dir / "node_modules" / ".bin" / make_script_filename("frida-compile")

which is called with cwd=output_dir

        subprocess.run([frida_compile, runtime_reldir / "entrypoint-quickjs.js", "-o", runtime] + quick_options, cwd=output_dir, check=True)

ideally frida-compile should be workdir-independent = should work when installed globally

version: frida-compile 10.2.5