Print class data member with Frida

。_饼干妹妹 提交于 2019-12-25 01:18:37

问题


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]"


回答1:


I would try the following:

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

        Java.perform(function () {
            var Activity = Java.use("com.app.network.AuthResponse2$Data");
            Activity.getAuthToken.overload().implementation = function () {
                var mAuthToken = this.getAuthToken(); // use `call` if there are other overloads
                console.log(mAuthToken);
                return mAuthToken;
            };
        });

})

This keeps the old method intact (returning a value) and uses the return value of the original method for printing to console.

I think your original code makes problem because you don't write this.mAuthToken when accessing class members.




回答2:


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



来源:https://stackoverflow.com/questions/48772800/print-class-data-member-with-frida

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!