无法Xposed在Multidex APK中挂钩一类defpackage软件包

时间:2019-06-20 02:10:21

标签: android hook android-multidex xposed

这是一个multidex APK。 我想在defpackage.bky类中挂接一个方法,如以下屏幕截图所示。

Jadx screenshot

Jadx screenshot image link

  1. 我尝试按如下方式钩挂Application.class“ attach”方法,但失败:“ java.lang.ClassNotFoundException:在路径上找不到类” defpackage.bky“。

        XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                ClassLoader cl = ((Context)param.args[0]).getClassLoader();
                Class<?> hookclass = null;
    
                try {
                    hookclass = cl.loadClass("defpackage.bky");
                } catch (Exception e) {
                    Log.e("MtwmXposed", "寻找defpackage.bky报错", e);
                    hookclass = null;
                }
                if(hookclass != null) {
                    Log.i("MtwmXposed", "寻找defpackage.bky成功");
                    XposedHelpers.findAndHookMethod(hookclass, "a",
                            JSONObject.class,
                            new XC_MethodHook() {
                                @Override
                                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                                    super.beforeHookedMethod(param);
                                    JSONObject shop_info = (JSONObject) param.args[0];
                                    Log.d("MtwmXposed", "From defpackage.bkt.a: " + shop_info.toString(2));
                                }
                            });
                }
    
    
            }
        });
    
  2. 我还尝试如下挂接ClassLoader.class“ getClass”方法,但也没有找到defpackage.bky。

       XposedHelpers.findAndHookMethod(ClassLoader.class, "loadClass", String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                if (param.hasThrowable()) return;
                Class<?> cls = (Class<?>) param.getResult();
                String name = cls.getName();
                Log.d("MtwmXposed", "class name =  " + name);
                if (name.equals("defpackage.bky")) {
                    Log.i("MtwmXposed", "寻找defpackage.bky成功");
                    XposedHelpers.findAndHookMethod(cls, "a",
                            JSONObject.class,
                            new XC_MethodHook() {
                                @Override
                                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                                    super.beforeHookedMethod(param);
                                    JSONObject shop_info = (JSONObject) param.args[0];
                                    Log.d("MtwmXposed", "From defpackage.bkt.a: " + shop_info.toString(2));
                                }
                            });
                }
    
            }
        });
    

0 个答案:

没有答案