Print class data member with Frida

Arya picture Arya · Feb 13, 2018 · Viewed 7.1k times · Source

I can successfully hook into this getAuthToken method

public class AuthResponse2 extends DataResponse<Data> {
    public static class Data {
        private String mAuthToken;

        public String getAuthToken() {
            return this.mAuthToken;
        }
    }
}

This is my Frida JS script

setImmediate(function() {
    console.log("[*] Starting script");

        Java.perform(function () {
            var Activity = Java.use("com.app.network.AuthResponse2$Data");
            Activity.getAuthToken.overload().implementation = function () {
                console.log(mAuthToken);
                console.log(mAuthToken.toString());
            };
        });

})

But I can't get mAuthToken printed. Not sure what kind of syntax I need to use.

I've tried

this.mAuthToken too, and the following gets printed

"[object Object]"

Answer

island foxy picture island foxy · Sep 13, 2018

Use .value property to access fields. I often forget this too.