SiriusED
SiriusED

Reputation: 11

Getting weird types on hooking native method with Frida

I'm trying to hook some function in an class it works fine but I want to view one argumant that is an class instance and this class has field that is String type, but when I try to get this field I get some really weird type instead of the string

Here is the code: var someclass = Java.use('com.myapp.classes.someclass.a');

// String (Object, String, Boolean)
someclass.getData.overload('com.myapp.classes.ClassContext', 
        'java.lang.String', 'java.lang.Boolean').implementation = function (a, b, c) {

    console.log('com.myapp.classes.ClassContext.stringify: ', 
        JSON.stringify(a.fieldWithStringData), '\r\n');
}

But instead of string I get some weird object when I used JSON.stringify on this object I got string like this (pretty printed for this question):

{
    "_p": ["<instance: com.myapp.classes.ClassContext>", 2, {
            "className": "java.lang.String",
            "name": "Ljava/lang/String;",
            "type": "pointer",
            "size": 1,
            "defaultValue": "0x0"
        }, "0xa3144614", "0xc2aaa8b0", "0xc2aace70"]
}

What is this object and how to get actual string from it, can some one help?

Upvotes: 1

Views: 1023

Answers (1)

Serhat
Serhat

Reputation: 396

You can use like this: a.fieldWithStringData.value

Upvotes: 1

Related Questions