Let's say I have a native method which address is expfunction.address. I tried to intercept the function call and get its arguments, general idea:

Interceptor.attach(expfunction.address, {
    onEnter(args) {
        console.log("\n-----\n[*] Function is called!);
        for(let i in args) {    
            ... read value of args[i] ...
        }
        
    },
    onLeave(retval) {
        console.log("\t\n-----\n[*] Function returns");
        console.log("\t[+] Returns:", retval);
    }
})

The function's arguments can be any datatype such as jboolean, jstring, jobject, etc. So how to get exactly the datatype of args[i] and properly read the value of it.

By the way, Is for(let i in args) { ... } a correct way to enumerate args array? Since trying to get args.length raises RangeError: invalid array index.

What I have tried so far (and they all return blank):

  • Failed 1

    onEnter(args) {
      for(let i in args) {    
            var tmp = new NativePointer(args[i]);
            console.log(tmp.readPointer());
        }     
    }
    
  • Failed 2

    function getType(value) {
      return Object.prototype.toString.call(value).toLowerCase();
    }
    ...
    onEnter(args) {
      for(let i in args) {    
            var tmp = new NativePointer(args[i]);
            console.log("Type:", getType(tmp));
        }     
    }
    

Thank you for reading to this point :)

0

There are 0 best solutions below