john
john

Reputation: 2544

Frida - Print static variable of a class

I have the following class (got this code via jadx)

package e.u.e.a.c;

public final class a implements AnalyticsConfig {

    public static final String f21227a;
    public static String f21231e;

    //.......
}

and I want to get the values of theses two static variables using Frida.

I have tried this

Java.perform(function x() { 

        var Test = Java.use("e.u.e.a.c.a");
        console.log( Test.f21227a.value );

});

but getting the following error.

TypeError: cannot read property 'value' of undefined

Edit:

I used this script to get the methods and class fields and that worked fine. I got the name of variables as

public static final java.lang.String e.u.e.a.c.a.a
public static java.lang.String e.u.e.a.c.a.d

but still I can't figure out how to get the actual runtime value of those variables.

Upvotes: 1

Views: 9941

Answers (1)

Maxim Sagaydachny
Maxim Sagaydachny

Reputation: 2218

jadx deobfuscates variable names to make code readable. You have to use original name of member to access it.

So you need to use names "a" and "d" to access those variables:

Java.perform(function x() { 
        var Test = Java.use("e.u.e.a.c.a");
        console.log( Test.a.value );
        console.log( Test.d.value );
});

and If we have methods with the same name as class field, then we need _ before variable name to get its value

Java.perform(function x() { 
        var Test = Java.use("e.u.e.a.c.a");
        console.log( Test._a.value );
        console.log( Test._d.value );
});

Upvotes: 11

Related Questions