1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
| public class AntiDetectHook { public static void Hook(ClassLoader classLoader) { try { XposedHelpers.findAndHookMethod(Location.class, "isFromMockProvider", XC_MethodReplacement.returnConstant(false)); if (Build.VERSION.SDK_INT >= 31) { XposedHelpers.findAndHookMethod(Location.class, "isMock", XC_MethodReplacement.returnConstant(false)); } XposedHelpers.findAndHookMethod(Settings.Secure.class, "getInt", android.content.ContentResolver.class, String.class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String setting = (String) param.args[1]; if (Settings.Secure.ALLOW_MOCK_LOCATION.equals(setting)) { param.setResult(0); } } }); try { XposedHelpers.findAndHookMethod("android.location.LocationManager", classLoader, "requestLocationUpdates", String.class, long.class, float.class, "android.location.LocationListener", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String provider = (String) param.args[0]; if ("network".equals(provider)) { param.args[0] = "passive"; } } }); XposedHelpers.findAndHookMethod("android.location.LocationManager", classLoader, "getLastKnownLocation", String.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { param.setResult(null); } }); } catch (Throwable ignore) {}
try { Class<?> aMapLocationClientOptionClass = XposedHelpers.findClassIfExists("com.amap.api.location.AMapLocationClientOption", classLoader); if (aMapLocationClientOptionClass != null) { Class<?> aMapLocationModeEnum = XposedHelpers.findClassIfExists("com.amap.api.location.AMapLocationClientOption$AMapLocationMode", classLoader); if (aMapLocationModeEnum != null) { try { final Object deviceSensorsMode = Enum.valueOf((Class<Enum>) aMapLocationModeEnum, "Device_Sensors"); XposedBridge.hookAllMethods(aMapLocationClientOptionClass, "setLocationMode", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (deviceSensorsMode != null) { param.args[0] = deviceSensorsMode; } } }); } catch (Throwable t) {} } } Class<?> aMapLocationClass = XposedHelpers.findClassIfExists("com.amap.api.location.AMapLocation", classLoader); if (aMapLocationClass != null) { XposedBridge.hookAllMethods(aMapLocationClass, "isMock", XC_MethodReplacement.returnConstant(false)); XposedBridge.hookAllMethods(aMapLocationClass, "getTrustedLevel", XC_MethodReplacement.returnConstant(1)); XposedBridge.hookAllMethods(aMapLocationClass, "getErrorCode", XC_MethodReplacement.returnConstant(0)); XposedBridge.hookAllMethods(aMapLocationClass, "getSatellites", XC_MethodReplacement.returnConstant(12)); XposedBridge.hookAllMethods(aMapLocationClass, "getLocationType", XC_MethodReplacement.returnConstant(1)); XposedBridge.hookAllMethods(aMapLocationClass, "getAccuracy", XC_MethodReplacement.returnConstant(5.0f)); XposedBridge.hookAllMethods(aMapLocationClass, "getSpeed", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { float speed = (float) param.getResult(); if (speed <= 0.5f) { param.setResult(2.5f); } } }); }
Class<?> hcjAddressInfo = XposedHelpers.findClassIfExists("huachenjie.sdk.map.lib_base.HCJAddressInfo", classLoader); if (hcjAddressInfo != null) { XposedBridge.hookAllMethods(hcjAddressInfo, "isMock", XC_MethodReplacement.returnConstant(false)); XposedBridge.hookAllMethods(hcjAddressInfo, "getSatellites", XC_MethodReplacement.returnConstant(12)); XposedBridge.hookAllMethods(hcjAddressInfo, "getGpsStatus", XC_MethodReplacement.returnConstant(1)); XposedBridge.hookAllMethods(hcjAddressInfo, "getAccuracy", XC_MethodReplacement.returnConstant(5.0f)); XposedBridge.hookAllMethods(hcjAddressInfo, "getSpeed", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { float speed = (float) param.getResult(); if (speed <= 0.5f) { param.setResult(2.5f); } } }); } Class<?> runLatLng = XposedHelpers.findClassIfExists("com.huachenjie.common.bean.RunLatLng", classLoader); if (runLatLng != null) { XposedBridge.hookAllMethods(runLatLng, "getSatellites", XC_MethodReplacement.returnConstant(12)); XposedBridge.hookAllMethods(runLatLng, "isValid", XC_MethodReplacement.returnConstant(true)); XposedBridge.hookAllMethods(runLatLng, "getAccuracy", XC_MethodReplacement.returnConstant(5.0f)); }
Class<?> dataComponent = XposedHelpers.findClassIfExists("com.huachenjie.running.service.DataComponent", classLoader); if (dataComponent != null) { XposedBridge.hookAllMethods(dataComponent, "P0", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Object hcjInfo = param.getResult(); if (hcjInfo != null) { XposedHelpers.callMethod(hcjInfo, "setSatellites", 12); XposedHelpers.callMethod(hcjInfo, "setMock", false); XposedHelpers.callMethod(hcjInfo, "setFromMockProvider", false); XposedHelpers.callMethod(hcjInfo, "setAccuracy", 5.0f); XposedHelpers.callMethod(hcjInfo, "setGpsStatus", 1); float speed = (float) XposedHelpers.callMethod(hcjInfo, "getSpeed"); if (speed <= 0.5f) { XposedHelpers.callMethod(hcjInfo, "setSpeed", 2.5f); } } } }); } Class<?> targetPointsClass = XposedHelpers.findClassIfExists("com.huachenjie.common.bean.TargetPoints", classLoader); if (targetPointsClass != null) { XposedBridge.hookAllMethods(targetPointsClass, "isInFence", XC_MethodReplacement.returnConstant(true)); XposedBridge.hookAllMethods(targetPointsClass, "getIsInFence", XC_MethodReplacement.returnConstant(true)); XposedBridge.hookAllMethods(targetPointsClass, "isSensitiveFenceAdded", XC_MethodReplacement.returnConstant(false)); XposedBridge.hookAllMethods(targetPointsClass, "getIsSensitiveFenceAdded", XC_MethodReplacement.returnConstant(false)); }
Class<?> autoPauseView = XposedHelpers.findClassIfExists("com.huachenjie.running.widget.AutoPauseView", classLoader); if (autoPauseView != null) { XposedBridge.hookAllMethods(autoPauseView, "setLastedDuration", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { int reason = (int) param.args[1]; param.args[1] = reason & ~3; } }); } } catch (Throwable ignore) {}
try { Class<?> gnssStatusClass = XposedHelpers.findClassIfExists("android.location.GnssStatus", classLoader); if (gnssStatusClass != null) { XposedBridge.hookAllMethods(gnssStatusClass, "getSatelliteCount", XC_MethodReplacement.returnConstant(12)); } } catch (Throwable ignore) {}
XposedHelpers.findAndHookMethod(Location.class, "getExtras", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { android.os.Bundle extras = (android.os.Bundle) param.getResult(); if (extras == null) { extras = new android.os.Bundle(); } extras.putInt("satellites", 12); param.setResult(extras); } });
XposedHelpers.findAndHookMethod(File.class, "exists", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { File file = (File) param.thisObject; String path = file.getAbsolutePath(); if (path != null && (path.endsWith("/su") || path.contains("magisk") || path.contains("xposed"))) { param.setResult(false); } } });
XposedBridge.log("★[XXXX校园] 防检测机制(Root/虚拟定位)Hook 成功"); } catch (Throwable t) { XposedBridge.log("★[XXXX校园] 防检测机制 Hook 异常: " + t.getMessage()); } } }
|