Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
feat: security center & guard provider - Disable environment check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevtinge committed Dec 13, 2024
1 parent cf466c2 commit 6c64c45
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

import com.hchen.database.HookBase;
import com.sevtinge.hyperceiler.module.base.BaseModule;
import com.sevtinge.hyperceiler.module.hook.guardprovider.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.guardprovider.DisableUploadAppListNew;

@HookBase(targetPackage = "com.miui.guardprovider", isPad = false)
public class GuardProvider extends BaseModule {
@Override
public void handleLoadPackage() {
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("guard_provider_disable_root_check"));
initHook(new DisableUploadAppListNew(), mPrefsMap.getBoolean("disable_upload_applist"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -111,6 +112,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -111,6 +112,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sevtinge.hyperceiler.module.hook.securitycenter.AppLockPinScramble;
import com.sevtinge.hyperceiler.module.hook.securitycenter.BypassAdbInstallVerify;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableReport;
import com.sevtinge.hyperceiler.module.hook.securitycenter.DisableRootedCheck;
import com.sevtinge.hyperceiler.module.hook.securitycenter.GetBubbleAppString;
import com.sevtinge.hyperceiler.module.hook.securitycenter.HideXOptModeTip;
import com.sevtinge.hyperceiler.module.hook.securitycenter.InstallIntercept;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void handleLoadPackage() {
initHook(BeautyPc.INSTANCE, mPrefsMap.getBoolean("security_center_beauty_pc"));

// 其他
initHook(new DisableRootedCheck(), mPrefsMap.getBoolean("security_center_disable_root_check_environment"));
initHook(SimplifyMainFragment.INSTANCE, mPrefsMap.getBoolean("security_center_simplify_home"));
initHook(new InstallIntercept(), mPrefsMap.getBoolean("security_center_install_intercept"));
initHook(LockOneHundredPoints.INSTANCE, mPrefsMap.getBoolean("security_center_score"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.guardprovider;

import com.sevtinge.hyperceiler.module.base.BaseHook;
import com.sevtinge.hyperceiler.module.base.dexkit.DexKit;
import com.sevtinge.hyperceiler.module.base.dexkit.IDexKitList;

import org.luckypray.dexkit.DexKitBridge;
import org.luckypray.dexkit.query.FindMethod;
import org.luckypray.dexkit.query.matchers.MethodMatcher;
import org.luckypray.dexkit.result.BaseDataList;
import org.luckypray.dexkit.result.MethodData;
import org.luckypray.dexkit.result.MethodDataList;

import java.lang.reflect.Method;
import java.util.List;

public class DisableRootedCheck extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
List<Method> methods = DexKit.findMemberList("CheckRoot", new IDexKitList() {
@Override
public BaseDataList<MethodData> dexkit(DexKitBridge bridge) throws ReflectiveOperationException {
MethodDataList methodData = bridge.findMethod(FindMethod.create()
.matcher(MethodMatcher.create()
.usingStrings("/system/bin/")
.returnType(boolean.class)
)
);
return methodData;
}
});
for (Method method : methods) {
// Method method = methodData.getMethodInstance(lpparam.classLoader);
logD(TAG, lpparam.packageName, "Current hooking method is " + method);
hookMethod(method, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* This file is part of HyperCeiler.
*
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2023-2024 HyperCeiler Contributions
*/

package com.sevtinge.hyperceiler.module.hook.securitycenter;

import android.content.Intent;

import com.sevtinge.hyperceiler.module.base.BaseHook;
import com.sevtinge.hyperceiler.module.base.dexkit.DexKit;
import com.sevtinge.hyperceiler.module.base.dexkit.IDexKitList;

import org.luckypray.dexkit.DexKitBridge;
import org.luckypray.dexkit.query.FindMethod;
import org.luckypray.dexkit.query.matchers.MethodMatcher;
import org.luckypray.dexkit.result.BaseDataList;
import org.luckypray.dexkit.result.MethodData;
import org.luckypray.dexkit.result.MethodDataList;

import java.lang.reflect.Method;
import java.util.List;

public class DisableRootedCheck extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
findAndHookMethod("com.xiaomi.security.xsof.MiSafetyDetectService", "onCreate", new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
findAndHookMethod("com.xiaomi.security.xsof.MiSafetyDetectService", "onDestroy", new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
/*findAndHookMethod("com.xiaomi.security.xsof.MiSafetyDetectService", "onBind", Intent.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
findAndHookMethod("com.xiaomi.security.xsof.MiSafetyDetectService", "onUnbind", Intent.class, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});*/
List<Method> methods = DexKit.findMemberList("CheckRoot", new IDexKitList() {
@Override
public BaseDataList<MethodData> dexkit(DexKitBridge bridge) throws ReflectiveOperationException {
MethodDataList methodData = bridge.findMethod(FindMethod.create()
.matcher(MethodMatcher.create()
.usingStrings("/system/bin/")
.returnType(boolean.class)
)
);
return methodData;
}
});
for (Method method : methods) {
// Method method = methodData.getMethodInstance(lpparam.classLoader);
logD(TAG, lpparam.packageName, "Current hooking method is " + method);
hookMethod(method, new MethodHook() {
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@
<string name="guard_provider">MIUI 安全组件</string>
<string name="guard_provider_hyperos">系统安全组件</string>
<string name="guard_provider_disable_upload_applist">阻止自动上传已安装应用列表</string>
<string name="guard_provider_disable_root_check">禁用环境检查</string>
<!--系统桌面-->
<string name="mihome">系统桌面</string>
<string name="home_gesture">手势与导航</string>
Expand Down Expand Up @@ -1625,6 +1626,7 @@
<string name="security_center_beauty_title">前置摄像助手</string>
<string name="security_center_bubble_and_freeform_title">小窗和气泡通知</string>
<string name="security_center_newbox_title">全局侧边栏</string>
<string name="security_center_disable_root_check_environment">禁用环境检查</string>
<string name="security_center_dolby_open">关闭杜比弹窗</string>
<string name="security_center_show_battery_temperature">显示电池温度</string>
<string name="security_center_show_battery_health">显示具体电池健康度</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@
<string name="guard_provider">MIUI security components</string>
<string name="guard_provider_hyperos">System security components</string>
<string name="guard_provider_disable_upload_applist">Prevent automatic upload of installed app list</string>
<string name="guard_provider_disable_root_check">Disable environment check</string>
<!--System launcher-->
<string name="mihome">System launcher</string>
<string name="home_gesture">Gesture and navigation</string>
Expand Down Expand Up @@ -1584,6 +1585,7 @@
<string name="security_center_beauty_title">Front camera assistant</string>
<string name="security_center_bubble_and_freeform_title">Bubble and freeform</string>
<string name="security_center_newbox_title">Sidebar</string>
<string name="security_center_disable_root_check_environment">Disable environment check</string>
<string name="security_center_dolby_open">Close the Dolby pop-up window</string>
<string name="security_center_show_battery_temperature">Show battery temperature</string>
<string name="security_center_show_battery_health">Show detailed battery health</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/guard_provider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
app:myLocation="@string/guard_provider"
app:myLocationHyper="@string/guard_provider_hyperos"
app:quick_restart="com.miui.guardprovider">
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_guard_provider_disable_root_check"
android:title="@string/guard_provider_disable_root_check" />
<SwitchPreference
android:title="@string/guard_provider_disable_upload_applist"
android:key="prefs_key_disable_upload_applist"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/security_center_other.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
</PreferenceCategory>

<PreferenceCategory>
<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_security_center_disable_root_check_environment"
android:title="@string/security_center_disable_root_check_environment" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_security_center_simplify_home"
Expand Down

0 comments on commit 6c64c45

Please sign in to comment.