From 926bc7159c11781f9f614365ae1a5b797198f079 Mon Sep 17 00:00:00 2001 From: wuxianlin Date: Sun, 26 Feb 2023 22:14:20 +0800 Subject: [PATCH] add NetworkCapture and NowCasting --- .../com/wuxianlin/luckyhooker/HookMain.java | 2 + .../com/wuxianlin/luckyhooker/HookUtils.java | 18 ++++ .../wuxianlin/luckyhooker/MainActivity.java | 3 + .../luckyhooker/hooks/NetworkCapture.java | 38 ++++++++ .../luckyhooker/hooks/NowCasting.java | 91 +++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 app/src/main/java/com/wuxianlin/luckyhooker/hooks/NetworkCapture.java create mode 100644 app/src/main/java/com/wuxianlin/luckyhooker/hooks/NowCasting.java diff --git a/app/src/main/java/com/wuxianlin/luckyhooker/HookMain.java b/app/src/main/java/com/wuxianlin/luckyhooker/HookMain.java index 19307e9..1f970fa 100644 --- a/app/src/main/java/com/wuxianlin/luckyhooker/HookMain.java +++ b/app/src/main/java/com/wuxianlin/luckyhooker/HookMain.java @@ -36,6 +36,8 @@ public HookMain() { hooks.add(new HaiXing()); hooks.add(new KSWEB()); hooks.add(new MxPlayer()); + hooks.add(new NetworkCapture()); + hooks.add(new NowCasting()); hooks.add(new PacketCapture()); hooks.add(new PerfectPlayer()); hooks.add(new QiYi()); diff --git a/app/src/main/java/com/wuxianlin/luckyhooker/HookUtils.java b/app/src/main/java/com/wuxianlin/luckyhooker/HookUtils.java index 1dacd8c..8a8623c 100644 --- a/app/src/main/java/com/wuxianlin/luckyhooker/HookUtils.java +++ b/app/src/main/java/com/wuxianlin/luckyhooker/HookUtils.java @@ -4,11 +4,14 @@ import android.content.Context; import android.content.pm.PackageManager; import android.os.UserHandle; +import android.text.TextUtils; import androidx.annotation.Nullable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; import de.robv.android.xposed.XposedHelpers; @@ -45,6 +48,21 @@ public static int getPackageVersionCode(String packageName) { return 0; } + public static List findMethodWithName(String className, ClassLoader classLoader, String methodName) { + List methods = new ArrayList<>(); + if (TextUtils.isEmpty(className) || TextUtils.isEmpty(methodName)) + return methods; + Class hookClass = XposedHelpers.findClassIfExists(className, classLoader); + if (hookClass == null) + return methods; + for (Method method : hookClass.getDeclaredMethods()) { + if (methodName.equals(method.getName())) { + methods.add(method); + } + } + return methods; + } + public static int getMyUserId() { try { int uid = android.os.Process.myUid(); diff --git a/app/src/main/java/com/wuxianlin/luckyhooker/MainActivity.java b/app/src/main/java/com/wuxianlin/luckyhooker/MainActivity.java index 5b0855c..aeb285d 100644 --- a/app/src/main/java/com/wuxianlin/luckyhooker/MainActivity.java +++ b/app/src/main/java/com/wuxianlin/luckyhooker/MainActivity.java @@ -72,6 +72,9 @@ public static class PrefsFragment extends PreferenceFragmentCompat { HaiXing.hookPackageName, KSWEB.hookPackageName, MxPlayer.hookPackageName, + NetworkCapture.hookPackageName, + NowCasting.hookPackageNames[0], + NowCasting.hookPackageNames[1], PacketCapture.hookPackageName, PerfectPlayer.hookPackageName, QiYi.hookPackageNames[0], diff --git a/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NetworkCapture.java b/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NetworkCapture.java new file mode 100644 index 0000000..6c6500e --- /dev/null +++ b/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NetworkCapture.java @@ -0,0 +1,38 @@ +package com.wuxianlin.luckyhooker.hooks; + +import android.content.Context; + +import com.wuxianlin.luckyhooker.Hook; + +import de.robv.android.xposed.XC_MethodReplacement; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_InitPackageResources; +import de.robv.android.xposed.callbacks.XC_LoadPackage; + +/** + * Created by wuxianlin on 2023/2/26. + */ + +public class NetworkCapture implements Hook { + + public static final String hookPackageName = "com.minhui.networkcapture"; + + @Override + public boolean canHook(String packageName) { + return hookPackageName.equals(packageName); + } + + @Override + public void startHook(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { + XposedBridge.log("start Hook Network Capture"); + XposedHelpers.findAndHookMethod("com.minhui.networkcapture.utils.ContextUtil", lpparam.classLoader, "isProVersion", Context.class, XC_MethodReplacement.returnConstant(true)); + XposedHelpers.findAndHookMethod("com.minhui.networkcapture.utils.ContextUtil", lpparam.classLoader, "hasRegister", Context.class, XC_MethodReplacement.returnConstant(true)); + XposedHelpers.findAndHookMethod("com.minhui.networkcapture.utils.ContextUtil", lpparam.classLoader, "isNoGooglePlayNoAds", Context.class, XC_MethodReplacement.returnConstant(true)); + + } + + @Override + public void startHook(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable { + } +} diff --git a/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NowCasting.java b/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NowCasting.java new file mode 100644 index 0000000..679245b --- /dev/null +++ b/app/src/main/java/com/wuxianlin/luckyhooker/hooks/NowCasting.java @@ -0,0 +1,91 @@ +package com.wuxianlin.luckyhooker.hooks; + +import com.wuxianlin.luckyhooker.Hook; +import com.wuxianlin.luckyhooker.HookUtils; + +import org.json.JSONObject; + +import java.lang.reflect.Method; +import java.util.Arrays; + +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XC_MethodReplacement; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_InitPackageResources; +import de.robv.android.xposed.callbacks.XC_LoadPackage; + +/** + * Created by wuxianlin on 2023/2/26. + */ + +public class NowCasting implements Hook { + + public static final String[] hookPackageNames = new String[]{"com.nowcasting.huawei", + "com.nowcasting.activity"}; + + @Override + public boolean canHook(String packageName) { + return Arrays.asList(hookPackageNames).contains(packageName); + } + + @Override + public void startHook(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { + XposedBridge.log("start hook NowCasting"); + if (hookPackageNames[0].equals(lpparam.packageName)) { + XposedBridge.hookAllMethods(XposedHelpers.findClass("com.huawei.android.sdk.drm.Drm", lpparam.classLoader), "check", XC_MethodReplacement.returnConstant(null)); + } + String[][] usedUserClasses = new String[][]{ + {"com.nowcasting.activity.APPCenterActivity", "setUser", "0"}, + {"com.nowcasting.view.MainActivityView", "setUser", "0"}, + {"com.nowcasting.view.MainTitleView", "setUser", "0"}, + {"com.nowcasting.viewmodel.APPCenterViewModel", "getBannerInfo", "0"}, + {"com.nowcasting.viewmodel.APPCenterViewModel", "handleBannerStrategy", "0"}, + {"com.nowcasting.viewmodel.APPCenterViewModel", "parseBannerInfo", "1"} + }; + Method userParse = null; + for (String[] usedUserClass : usedUserClasses) { + for (Method method : HookUtils.findMethodWithName(usedUserClass[0], lpparam.classLoader, + usedUserClass[1])) { + Class[] paramClasses = method.getParameterTypes(); + int userIndex = Integer.parseInt(usedUserClass[2]); + if (paramClasses.length <= userIndex) + continue; + Class userClass = paramClasses[userIndex]; + if (userClass == null) + continue; + for (Method methodInUser : userClass.getDeclaredMethods()) { + Class[] paramUserClasses = methodInUser.getParameterTypes(); + if (paramUserClasses.length == 1 && + "org.json.JSONObject".equals(paramUserClasses[0].getName())) { + userParse = methodInUser; + } + } + if (userParse != null) + break; + } + } + if (userParse == null) + return; + XposedBridge.log("finded user.parse(JsonObject) method:" + + userParse.getDeclaringClass().getName() + "." + userParse.getName() + "(JsonObject)"); + XposedBridge.hookMethod(userParse, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + JSONObject jsonObject = (JSONObject) param.args[0]; + //XposedBridge.log(jsonObject.toString('\n')); + long time = System.currentTimeMillis() / 1000 + 365 * 24 * 60 * 60; + jsonObject.put("vip_expired_at", time); + jsonObject.put("svip_expired_at", time); + jsonObject.put("vip_type", "s"); + jsonObject.put("is_vip", true); + param.args[0] = jsonObject; + } + }); + } + + @Override + public void startHook(XC_InitPackageResources.InitPackageResourcesParam resparam) throws Throwable { + } + +}