nhujasf
nhujasf

Reputation: 33

Frida hook override method of anonymous class?

package com.test.testapplication;

import android.content.Context;
import android.webkit.ValueCallback;
import android.webkit.WebView;

public abstract class TXOut extends WebView {
    public TXOut(Context context) {
        super(context);
    }

    private class TXIn implements Runnable {
        String a;
        ValueCallback b;

        TXIn(String str) {
            this.a = str;
        }

        private void b() {
            TXOut.this.evaluateJavascript(
                    "(function() { return ('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>'); })();",
                    new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String html) {
                            // code here
                        }
                    });
        }

        public void run() {}
    }
}

How could I hook TXOut ---> TXIn ---> b ---> new ValueCallback() ---> onReceiveValue using frida?

I want to get this method's html argument

Upvotes: 2

Views: 3135

Answers (1)

Robert
Robert

Reputation: 42585

Anonymous inner classes are getting a generated class name using the following scheme:

<outer class name>$<number>

Where number starts at 1 and for each anonymous inner class it is just incremented by one.

Therefore in your case most likely it will be com.test.testapplication.TXOut.TXIn$1.

It seems like you are practicing using Frida, because usually you don't have the source code of an app. Therefore the common way is to use the compiled APK file and decompile it using e.g. apktool or Jadx.

Using apktool in the generated smali sources you can easily identify the inner class you are looking for you just have to replace / with . to convert the smali class name back to a regular Java class name.

In Jadx the original class name is added as comment.

Upvotes: 2

Related Questions