frida框架hook参数获取方法入参模板

python脚本

# -*- coding: utf-8 -*-
import logging
import frida
import sys

logging.basicConfig(level=logging.DEBUG)


def on_message(message, data):
    if message['type'] == 'send':
        print("[*] {0}".format(message['payload']))
    else:
        print(message)


with open('java.js', 'r', encoding='utf-8') as f:
    sta = ''.join(f.readlines())

rdev = frida.get_remote_device()

session = rdev.attach("com.hnzycfc.zyxj")  #app包名
print(session)
script = session.create_script(sta)
print(script)
def show(message,data):
    print(message)
script.on("message",show)

# 加载脚本
script.load()
sys.stdin.read()

hookjs脚本

Java.perform(function () {
    encrypt = Java.use("com.shizhuang.duapp.modules.web.handlers.defaults.GetPlatformInfo");  //对象名
    //其中a为方法名,overload为重加载 ,"android.content.Context", "java.util.Map"为方法入参的数据类型
    encrypt.a.overload("android.content.Context", "java.util.Map").implementation = function (args, args2) {
        console.log("args1", args)
        console.log("args2", args2)
        // console.log("args3", args3)
        // console.log("args4", args4)
        args = this.a(args,args2)
        console.log("args", args)
        return args
    }
});

posted @ 2020-07-29 17:15  小小咸鱼YwY  阅读(3190)  评论(0编辑  收藏  举报