I'm learning frida and trying to hook a function that looks like:

`.method public final fn()[B`

It returns a byte array. Here's my code:

Java.perform(function () {
    var test = Java.use("com...");
    test.fn.overload().implementation = function () {
        var ret = this.fn();
        console.log("how to write here?");
        return ret;

How to print the ret variable returned by the function? It's a byte[]. I tried console.log but it only prints a [object], and hexdump complains 'expected a pointer'. How can I print the array?



var ret = this.fn();
var buffer = Java.array('byte', ret);
var result = "";
for(var i = 0; i < buffer.length; ++i){
    result+= (String.fromCharCode(buffer[i]));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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