frida框架hook获取方法输出参数(常用于简单的so输出参数获取,快速开发)

一.模板

function douyinencode(data) {
    var result = {};
    Java.perform(function () {
        try {
            var Test = Java.use("类名");
            result = Test.方法名(入参);
            result = {"code": 0, "value":result};
        } catch (e) {
            result = {"code": 1, "value": e.toString()};
        }
    });
    return result
};

二.结合flask

from flask import Flask,jsonify,request

import frida

app =Flask(__name__)


js ='''function Fun(args){
    Java.perform(function () {
        var result;
        var Test = Java.use("类名");  
        result = Test.方法名(args);  //入参
        result = {"code": 0, "value": result};
    });
    return result
    
}'''
def show(message,data):
    print(message)
rdev = frida.get_remote_device()
session = rdev.attach("com.lianjia.beike")  #app包名
script = session.create_script(js)
script.on("message",show)
# 加载脚本
script.load()

@app.route("/test")
def index():
    args = request.args['args']
    res = script.exports.Fun(args)  #script.exports.js文件方法名,入参
    return res

if __name__ == '__main__':
    app.run()
posted @ 2020-09-01 19:55  小小咸鱼YwY  阅读(3743)  评论(0编辑  收藏  举报