资源共享吧|易语言论坛|逆向破解教程|辅助开发教程|网络安全教程|www.zygx8.com|我的开发技术随记

 找回密码
 注册成为正式会员
查看: 1075|回复: 1

[安卓逆向] firda Hook类的所有方法,遇到的重载问题

[复制链接]

3

主题

19

帖子

0

精华

终身高级VIP会员

Rank: 7Rank: 7Rank: 7

资源币
9
积分
21
贡献
0
在线时间
6 小时
注册时间
2021-2-21
最后登录
2021-4-28

终身VIP会员

发表于 2021-2-24 15:41:26 | 显示全部楼层 |阅读模式
1资源币
在练习用frida hook java类所有方法时,遇到如下问题,请高手指点,怎么改?

Error: setName(): argument types do not match any of:
        .overload('java.lang.String')
    at ge (frida/node_modules/frida-java-bridge/lib/class-factory.js:584)
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:996
    at je (frida/node_modules/frida-java-bridge/lib/class-factory.js:633)
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:616



hook代码如下:

//获取所有方法,Hook
function HookAllMethod() {
    var student=Java.use('com.example.encrptiondemo.Person');
    var methods=student.class.getDeclaredMethods();
    for (var i=0;i<methods.length;i++){
        var methodName=methods.getName();
        console.log(methodName);
        //多个重载
        for(var k=0;k<student[methodName].overloads.length;k++){
            student[methodName].overloads[k].implementation=function() {
                 console.log("arguments:",JSON.stringify(arguments));
            //多个参数
            for (var j=0;j<arguments.length;j++){
                  console.log(arguments[j]);
            }

            return this[methodName].apply(this,arguments);
            }
        }

    }

}

android源码如下:package com.example.encrptiondemo;

public class Person {
    private String name;
    private int age;

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public Person(Student student){
        this.name=student.getName();
        this.age=student.getAge();
    }
    public void print(){
        System.out.println(serialize());
    }
    public String serialize(){
        return this.name+","+this.age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}



回复

使用道具 举报

2

主题

120

帖子

0

精华

终身高级VIP会员

Rank: 7Rank: 7Rank: 7

资源币
88
积分
124
贡献
0
在线时间
34 小时
注册时间
2019-8-31
最后登录
2023-4-27

终身VIP会员

发表于 2021-3-3 23:28:51 | 显示全部楼层
函数名.overload("数据类型")
回复

使用道具 举报

 点击右侧快捷回复  

本版积分规则

小黑屋|资源共享吧 ( 琼ICP备2021005790号-1 )

GMT+8, 2024-3-29 01:14 , Processed in 0.044813 second(s), 11 queries , MemCached On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表