0

I wrote a script to bypass root detection in an android app. I run the following command to access the script frida -U --runtime=v8 -f com.app.example -l "C:\Users\rosha\frida.js" but get the following error

ReferenceError: require is not defined
    at C:\Users\obb\frida.js:2:13
    at /frida/repl-2.js:1:8

Below is my script `

var Frida = require("frida");
var Process = Frida.Process;

function bypassRootDetection() {
  var RootDetectorClass = Java.use("com.axisidp.mobile.setOnSwipeItemClickListener");
  Device.setTargetElevation.implementation = function() {
    return false;
  }
}

Process.enumerateModules()
  .then(function(modules) {
    var targetModule = modules.find(function(m) {
      return m.name === "cris.icms.ntes";
    });
  
    return Process.attach(targetModule.pid);
  })
  .then(function(process) {
    Frida.getScript(bypassRootDetection)
      .then(function(script) {
        script.load();
      })
      .catch(function(error) {
        console.error("Error injecting script:", error);
      });
  })
  .catch(function(error) {
    console.error("Error attaching to process:", error);
  });

Please guide.

The script should bypass the root detection.

  • Require is AFAIK a keywords for including node.js modules. But Frida does not use node.js. You have to use plain JavaScript. – Robert Dec 20 '22 at 09:50
  • For a more detailed description what `require` is see https://stackoverflow.com/a/9901097/150978 – Robert Dec 22 '22 at 08:15
  • I'm sorry for the late reply @Robert. Thanks a ton. This helped me to understand what was causing the issue. – peacelover007 Dec 23 '22 at 09:35

0 Answers0