Skip to content

Commit

Permalink
add NetworkCapture and NowCasting
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxianlin committed Feb 26, 2023
1 parent e4eae64 commit 926bc71
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/wuxianlin/luckyhooker/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/wuxianlin/luckyhooker/HookUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -45,6 +48,21 @@ public static int getPackageVersionCode(String packageName) {
return 0;
}

public static List<Method> findMethodWithName(String className, ClassLoader classLoader, String methodName) {
List<Method> 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();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/wuxianlin/luckyhooker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
}
91 changes: 91 additions & 0 deletions app/src/main/java/com/wuxianlin/luckyhooker/hooks/NowCasting.java
Original file line number Diff line number Diff line change
@@ -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 {
}

}

0 comments on commit 926bc71

Please sign in to comment.