Search code examples
javaandroidfrida

expected return value compatible with java.lang.Boolean


I'm trying to bypass rootDetection in an android app using Frida.

I've found the class and method which is checking if the device is rooted or not and tried to change the return value of this method, but I'm getting a confusing error :

Error: Implementation for isDeviceRooted expected return value compatible with java.lang.Boolean

My script is simple :

var hook = Java.use("app.name.someClasses.RootUtils");
hook.isDeviceRooted.overload().implementation = function() {
   return false;
}

I tried to googling but I don't understand what's the difference between Boolean(false) and false, it's just a wrapper and seriously what should I return here to be compatible with the main method return value?!


Solution

  • If you just return true or false this is the primitive type boolean. Modern Java compilers automatically convert between boolean and java.lang.Boolean but Frida does not.

    Therefore you have to create a java.lang.Boolean instance and return it:

    var hook = Java.use("app.name.someClasses.RootUtils");
    hook.isDeviceRooted.overload().implementation = function() {
       return Java.use("java.lang.Boolean").$new(false);
    }