Back

frida - 对于已有的android方法进行改写

发布时间: 2021-11-13 07:43:00

安装好之后, 在android 设备上运行 frida-server, 然后在PC端 frida-ps -U ,可以看到内容,就说明可以使用了.

直接运行下面的脚本即可:

python3 the_script.py

内容如下:

import frida, sys, time

def on_message(message, data):
    print("=== in on_message")
    print(message)
    print(data)

jscode = """
Java.perform(function () {
//  var target_class = Java.use('com.hizhg.utilslibrary.retrofit.b');
  var target_class = Java.use('com.hizhg.utilslibrary.mvp.view.BaseActivity');

  var the_method = target_class.showToast;
 // checkServerTrusted.implementation = function (a, b) {
  the_method.implementation = function (a) {
//    send('===== checking SSL....');
//    return true

    // 这个console是输出在PC端
    console.info('====@@@ a: ', a);

    this.showToast("lueluelueleu")
  };
});
"""

#process = frida.get_usb_device().attach('com.hizhg.tong')
#script = process.create_script(jscode)

device = frida.get_usb_device()
pid = device.spawn(["com.hizhg.tong"])
device.resume(pid)
time.sleep(1)

script = device.attach(pid).create_script(jscode)

script.on('message', on_message)
print('==== script start ...')
script.load()
sys.stdin.read()

Back