frida模拟用户点击按钮

demo app 代码:

package com.zhuotong.myapplication2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void doLogin(View view) {
        Toast.makeText(this,"hello,guys!",Toast.LENGTH_LONG).show();
    }
}

运行图:

%title插图%num

frida 模拟点击的js代码:

function clickMe() {
    Java.perform(function () {
        Java.scheduleOnMainThread(function () {
            let main = "com.zhuotong.myapplication2.MainActivity";
            Java.choose(main,{
                onMatch: function (instance) {
                    console.log("已进入onMatch");
                    let view = Java.use("android.view.View");
                    let v = view.$new();
                    instance.doLogin(v);
                },
                onComplete: function() {

                }
            });
        });
    })
}

clickMe()

pycharm中的运行结果:

%title插图%num
模拟器中的demo app的按钮被点击了的效果:
%title插图%num

发表回复