5

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?!

Mahdi
  • 144
  • 2
  • 13

2 Answers2

5

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);
}
Robert
  • 39,162
  • 17
  • 99
  • 152
1
  • Boolean(false) will return object Boolean. It can be null instead of true/false
  • false will return primitive type. It just is true/false
Mark
  • 15
  • 3
  • So, what should I use here to be compatible with java.lang.Boolean ? I tried Boolean(false) and false, both returns the same error. – Mahdi Jul 28 '21 at 22:23
  • ``return new Boolen(false);`` – NomadMaker Jul 29 '21 at 09:56
  • @NomadMaker The code you posted is Java code, but here we are in a JavaScript based Frida code that generates Java objects, therefore your code does not work. – Robert Jul 29 '21 at 10:29
  • Sorry, but I assumed java code was desired because there was no javascript tag on the question. I don't know anything about frida. – NomadMaker Jul 29 '21 at 10:37
  • @NomadMaker When answering a comment that was not created by the user created the post the comments belong to (in this case the answer by Mark) please always use the @ so the user you write the comment to is getting notified. – Robert Jul 29 '21 at 13:26