Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook到了一个方法,但是afterHookedMethod之后又提示这个方法找不到? #39

Closed
f111fei opened this issue Mar 24, 2018 · 19 comments
Labels

Comments

@f111fei
Copy link

f111fei commented Mar 24, 2018

以下是我的hook代码,我要hook,com.ss.android.common.applog.UserInfo这个类的initUser方法,这是个native的方法。

Class UserInfo;
try {
    UserInfo = loadPackageParam.classLoader.loadClass("com.ss.android.common.applog.UserInfo");
} catch (Exception e) {
    XposedBridge.log("找不到类com.ss.android.common.applog.UserInfo");
    return;
}

XposedHelpers.findAndHookMethod(UserInfo, "initUser", String.class, new XC_MethodHook() {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
    }

    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        super.afterHookedMethod(param);
        if (!Server.started) {
            String address = Server.start(8080);
            XposedBridge.log("服务器已启动: " + address);
        }
    }
});

以上在afterHookedMethod里面打印服务器已启动说明已经hook成功,但是还是报了下面的错误。

....
03-24 11:45:11.557 I/Xposed  (23854): 服务器已启动: 172.16.11.68:8080
03-24 11:45:11.572 I/VApp    (23854): uncaught :Thread[main,5,main]
03-24 11:45:11.572 I/VApp    (23854): java.lang.UnsatisfiedLinkError: No implementation found for int com.ss.android.common.applog.UserInfo.initUser(java.lang.String) (tried Java_com_ss_android_common_applog_UserInfo_initUser and Java_com_ss_android_common_applog_UserInfo_initUser__Ljava_lang_String_2)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.common.applog.UserInfo.initUser(Native Method)
03-24 11:45:11.572 I/VApp    (23854): 	at java.lang.reflect.Method.invoke(Native Method)
03-24 11:45:11.572 I/VApp    (23854): 	at me.weishu.epic.art.method.ArtMethod.invoke(Unknown Source)
03-24 11:45:11.572 I/VApp    (23854): 	at de.robv.android.xposed.DexposedBridge.handleHookedArtMethod(Unknown Source)
03-24 11:45:11.572 I/VApp    (23854): 	at me.weishu.epic.art.entry.Entry.onHookInt(Unknown Source)
03-24 11:45:11.572 I/VApp    (23854): 	at me.weishu.epic.art.entry.Entry.referenceBridge(Unknown Source)
03-24 11:45:11.572 I/VApp    (23854): 	at me.weishu.epic.art.entry.Entry.intBridge(Unknown Source)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.common.applog.c.updateEstr(Anticheat.java:58)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.common.applog.c.init(Anticheat.java:48)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.ugc.live.initialization.task.d.d.execute(IESApiTask.java:64)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.ugc.live.initialization.task.a.run(BaseTask.java:46)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.ugc.live.initialization.b.onApplicationCreate(InitializationManager.java:105)
03-24 11:45:11.572 I/VApp    (23854): 	at com.ss.android.ugc.live.

java.lang.UnsatisfiedLinkError: No implementation found for int com.ss.android.common.applog.UserInfo.initUser
说找不到这个类方法的实现。

我尝试把这个插件放到官方Xposed里面没有报这个错,这个是我的问题还是VirtualXposed的问题?


Update

后来我改为hook其他非静态非native的方法,就不报错了。

猜测VirtualXposed对hook static或者native的方法存在bug。

Thanks

@tiann
Copy link
Member

tiann commented Mar 24, 2018

谢谢反馈,这是一个native方法,报错说的是 native方法对应的jni方法没有找到。
能否透漏一下具体你hook的是哪个应用?可能在load so的时候确实是有问题的,我看一下具体什么原因。

@f111fei
Copy link
Author

f111fei commented Mar 24, 2018

火山小视频

@tiann
Copy link
Member

tiann commented Mar 24, 2018

好的,我看下

@firesunCN
Copy link

firesunCN commented Mar 28, 2018

遇到了一个同样问题,不过是static方法的
使用https://github.com/veryyoung/DingDingLuckyMoney 这个项目的钉钉防撤回功能,官方Xposed里面使用正常,在VirtualXposed就不正常,通过打日志的方式发现并没有hook住方法,用于防撤回的关键方法是static的,同样猜测VirtualXposed对hook static方法存在bug。

@tiann
Copy link
Member

tiann commented Mar 28, 2018

@firesunCN 具体是哪个方法,哪个版本的钉钉?我看一下

@firesunCN
Copy link

@tiann 我刚给作者提了一个pr支持钉钉4.3.2,目前他的项目是支持钉钉4.3.1
在他项目的me.veryyoung.dingding.luckymoney.PreventRecallHook类里hook了钉钉的defpackage.gbf类的b方法
如果是4.3.1就是hook钉钉的defpackage.fzv类的b方法
这个类是钉钉操作数据库的类

@tiann
Copy link
Member

tiann commented Mar 28, 2018

@firesunCN 好的,多谢

@IamHuskar
Copy link

这个bug修了吗?同遇到问题了

@tiann
Copy link
Member

tiann commented May 10, 2018

@IamHuskar 能否说明下你遇到的详细情况?上述case我测了一下没有复现,于是就放下了。有一些初步的猜测,但是没法验证。

@IamHuskar
Copy link

IamHuskar commented May 10, 2018

@tiann 对于抖音小视频 HOOK com.ss.android.common.applog.UserInfo 类的GetUserInfo 想给你gmail发邮件。被当成垃圾邮件返回了。

05-10 11:32:22.884 17239 17967 E art     : No implementation found for java.lang.String com.ss.android.common.applog.UserInfo.getUserInfo(int, java.lang.String, java.lang.String[], java.lang.String) (tried Java_com_ss_android_common_applog_UserInfo_getUserInfo and Java_com_ss_android_common_applog_UserInfo_getUserInfo__ILjava_lang_String_2_3Ljava_lang_String_2Ljava_lang_String_2)
05-10 11:32:22.885 17239 17967 W System.err: java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String com.ss.android.common.applog.UserInfo.getUserInfo(int, java.lang.String, java.lang.String[], java.lang.String) (tried Java_com_ss_android_common_applog_UserInfo_getUserInfo and Java_com_ss_android_common_applog_UserInfo_getUserInfo__ILjava_lang_String_2_3Ljava_lang_String_2Ljava_lang_String_2)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.applog.UserInfo.getUserInfo(Native Method)
05-10 11:32:22.886 17239 17967 W System.err: 	at java.lang.reflect.Method.invoke(Native Method)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.method.ArtMethod.invoke(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at de.robv.android.xposed.DexposedBridge.handleHookedArtMethod(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.entry.Entry.onHookObject(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.entry.Entry.referenceBridge(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.ugc.aweme.app.b.b.a(AwemeMainProcessApplication.java:25621)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.ugc.aweme.app.b.b$5.a(AwemeMainProcessApplication.java:560)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePostRetry(NetworkUtils.java:1072)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost(NetworkUtils.java:1042)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost$___twin___(NetworkUtils.java:1117)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.access$000(NetworkUtils.java)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.f.a(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost(NetworkUtils.java)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.newmedia.e.c.a(AppLogNetworkClient.java:63)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.bytedance.common.utility.i.b(NetworkClient.java:65)
05-10 11:32:22.887 17239 17967 W System.err: 	at com.ss.android.newmedia.message.i$3.doInBackground(PushRegisterResultHandler.java:228)
05-10 11:32:22.887 17239 17967 W System.err: 	at android.os.AsyncTask$2.call(AsyncTask.java:295)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.lang.Thread.run(Thread.java:818)

@IamHuskar
Copy link

IamHuskar commented May 10, 2018

@tiann

Method[] all_method=null;
        try
        {
            Class<?> cls=XposedHelpers.findClass("com.ss.android.common.applog.UserInfo",loadPackageParam.classLoader);
            if(cls!=null)
            {
                all_method= cls.getDeclaredMethods();
                for (Method method : all_method)
                {
                    String name=method.getName();
                    Class<?>[] parameterTypes= method.getParameterTypes();
                    int argnum=0;
                    for (Class<?> clas : parameterTypes)
                    {
                        argnum++;
                    }
                    if(name.equals("getUserInfo")&&argnum==4)
                    {
                        XC_MethodHook.Unhook uh=XposedBridge.hookMethod(method, new XC_MethodHook() {
                            @Override
                            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                                super.beforeHookedMethod(param);
                            }
                            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                                super.beforeHookedMethod(param);
                            }
                        });
                        break;
                    }
                }
            }
            else
            {
                XposedBridge.log("can't find class ");
            }

        }
        catch (Exception e)
        {
            XposedBridge.log("error hook "+e);
        }

@IamHuskar
Copy link

当然。也是否有可能是app做了一些保护措施

@tiann
Copy link
Member

tiann commented May 10, 2018

抖音确实有Xposed检测,但是不确定是否是这个引起的。抖音版本号是多少?

@IamHuskar
Copy link

IamHuskar commented May 10, 2018

@tiann version 1.8.1 我估计可能有保护处理了。弄得看起来像是VirtualXposed的bug.而且并不是每次都BUG。中途有时候多测试几次。又可能不会爆这个错误,但是正常的情况较少。

@tiann
Copy link
Member

tiann commented May 10, 2018

看起来像是vxp的问题,我先研究下

@f111fei
Copy link
Author

f111fei commented May 10, 2018

@IamHuskar 麻烦不要把issue评论区当聊天室

@tiann
Copy link
Member

tiann commented May 15, 2018

JNI方法的entry point有问题,与so load的先后有关。
如果native方法是手动注册的,尝试先load so可以解决问题。如果是自动注册的,需要先reslove方法。

不过目前没有时间修复这个,先记录一下。

@tiann
Copy link
Member

tiann commented Sep 8, 2018

这是 epic 的缺陷,已经确认无法修复;但是可以用如下方法规避:

  1. hook native 方法之前,先手动加载对应的so。
  2. hook static 方法时,如果方法所在的类存在 static block,建议更换hook点;否则会带来未知的副作用。

@Soares1
Copy link

Soares1 commented Feb 2, 2020

@tiann 对于抖音小视频 HOOK com.ss.android.common.applog.UserInfo 类的GetUserInfo 想给你gmail发邮件。被当成垃圾邮件返回了。

05-10 11:32:22.884 17239 17967 E art     : No implementation found for java.lang.String com.ss.android.common.applog.UserInfo.getUserInfo(int, java.lang.String, java.lang.String[], java.lang.String) (tried Java_com_ss_android_common_applog_UserInfo_getUserInfo and Java_com_ss_android_common_applog_UserInfo_getUserInfo__ILjava_lang_String_2_3Ljava_lang_String_2Ljava_lang_String_2)
05-10 11:32:22.885 17239 17967 W System.err: java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String com.ss.android.common.applog.UserInfo.getUserInfo(int, java.lang.String, java.lang.String[], java.lang.String) (tried Java_com_ss_android_common_applog_UserInfo_getUserInfo and Java_com_ss_android_common_applog_UserInfo_getUserInfo__ILjava_lang_String_2_3Ljava_lang_String_2Ljava_lang_String_2)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.applog.UserInfo.getUserInfo(Native Method)
05-10 11:32:22.886 17239 17967 W System.err: 	at java.lang.reflect.Method.invoke(Native Method)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.method.ArtMethod.invoke(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at de.robv.android.xposed.DexposedBridge.handleHookedArtMethod(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.entry.Entry.onHookObject(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at me.weishu.epic.art.entry.Entry.referenceBridge(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.ugc.aweme.app.b.b.a(AwemeMainProcessApplication.java:25621)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.ugc.aweme.app.b.b$5.a(AwemeMainProcessApplication.java:560)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePostRetry(NetworkUtils.java:1072)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost(NetworkUtils.java:1042)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost$___twin___(NetworkUtils.java:1117)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.access$000(NetworkUtils.java)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.f.a(Unknown Source)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.common.util.NetworkUtils.executePost(NetworkUtils.java)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.ss.android.newmedia.e.c.a(AppLogNetworkClient.java:63)
05-10 11:32:22.886 17239 17967 W System.err: 	at com.bytedance.common.utility.i.b(NetworkClient.java:65)
05-10 11:32:22.887 17239 17967 W System.err: 	at com.ss.android.newmedia.message.i$3.doInBackground(PushRegisterResultHandler.java:228)
05-10 11:32:22.887 17239 17967 W System.err: 	at android.os.AsyncTask$2.call(AsyncTask.java:295)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
05-10 11:32:22.887 17239 17967 W System.err: 	at java.lang.Thread.run(Thread.java:818)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants