0

I'm trying to get the return value of a android native function call using Frida but with no success:

Interceptor.attach(Module.getExportByName('lib.so', 'Token'), {
    onEnter: function(args) {
    },
    onLeave: function(retval) {
      console.log(retval);
    }
});

I know that the value is a bytearray but I can't find a way to read it from the native pointer.

Can anyone point me in the right direction? What should I do the get the value from retval? I already tried to use cast, but it didn't work.

thanks

3

1 Answer 1

0

I just needed to cast to array buffer:

        var b = Java.use('[B')
        var buffer = Java.cast(retval, b);
        var result = Java.array('byte', buffer);

        var str_ = "";
        for (var i=0; i < result.length; i++) {
            str_ += String.fromCharCode(result[i]);     

        }
        console.log("String: " + str_)

     }```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.