Search code examples
javascriptjavaandroidfrida

Code for Frida to intercept what are the values of arguments passing through the function when it is called in Android


Suppose there is a function which is as below :

public String foo(String str,String str2)
{
//some code here
return str+str2;
}

What would be the Frida code(In JavaScript) to intercept the function get values of both str and str2?


Solution

  • Java.perform(function () {
    // ClassName = Name of the class you're targeting. E.g for android os 'android.app.Activity'
    
    var class2overload = Java.use("ClassName")
    
     class2overload.foo.overload('java.lang.String', 'java.lang.String').implementation =  function (arg1, arg2) {
                console.log("Params: " + arg1 + arg2);
                return this.foo(arg1, arg2);
    
            }
    
    });