常规root的检查方案

简介: root

1.检测路径1

public boolean c() {

    String[] strArr = {"/system/bin/", "/system/xbin/", "/system/sbin/", "/sbin/", "/vendor/bin/"};
    int i = 0;
    while (i < 5) {
        try {
            if (new File(strArr[i] + "su").exists()) {
                return true;
            }
            i++;
        } catch (Exception e) {
        }
    }
    return false;
}

public String o() {

    return a("ro.kernel.qemu", "0");
}

2.检测路径2

public static boolean a() {

    String[] strArr = {"/system/xbin/", "/system/bin/", "/system/sbin/", "/sbin/", "/vendor/bin/", "/su/bin/"};
    try {
        int length = strArr.length;
        for (int i = 0; i < length; i++) {
            String str = strArr[i] + "su";
            if (new File(str).exists()) {
                String a = a(new String[]{"ls", "-l", str});
                f.b("cyb", "isRooted=" + a);
                if (TextUtils.isEmpty(a) || a.indexOf("root") == a.lastIndexOf("root")) {
                    return false;
                }
                return true;
            }
        }
    } catch (Exception e) {
    }
    return false;
}

3.检测属性

public static boolean checkRootMethod1() {

    if (PatchProxy.isSupport(new Object[0], null, changeQuickRedirect, true, 3217, new Class[0], Boolean.TYPE)) {
        return ((Boolean) PatchProxy.accessDispatch(new Object[0], null, changeQuickRedirect, true, 3217, new Class[0], Boolean.TYPE)).booleanValue();
    }
    String str = Build.TAGS;
    return str != null && str.contains("test-keys");
}

4. 检测路径3

public static boolean checkRootMethod2() {

if (PatchProxy.isSupport(new Object[0], null, changeQuickRedirect, true, 3218, new Class[0], Boolean.TYPE)) {
    return ((Boolean) PatchProxy.accessDispatch(new Object[0], null, changeQuickRedirect, true, 3218, new Class[0], Boolean.TYPE)).booleanValue();
}
try {
    if (new File("/system/bin/su").exists() || new File("/system/xbin/su").exists()) {
        return true;
    }
} catch (Exception e) {
}
return false;

}

5.检测包名

public static boolean checkRootMethod3() {

if (PatchProxy.isSupport(new Object[0], null, changeQuickRedirect, true, 3219, new Class[0], Boolean.TYPE)) {
    return ((Boolean) PatchProxy.accessDispatch(new Object[0], null, changeQuickRedirect, true, 3219, new Class[0], Boolean.TYPE)).booleanValue();
}
try {
    if (new File("/system/app/Superuser.apk").exists()) {
        return true;
    }
} catch (Exception e) {
}
return false;

}

相关文章
|
1月前
|
存储 算法 C语言
【C/C++ 应用开发 检测文件 】详解 C/C++ 中常用的 5 种文件存在检查方式
【C/C++ 应用开发 检测文件 】详解 C/C++ 中常用的 5 种文件存在检查方式
46 0
|
6月前
|
存储 Shell Linux
Shell命令切换root用户、管理配置文件、检查硬件
  与其他基于UNIX的系统一样,Linux也可以被多个人同时使用。多用户功能能够让多人在单个Linux系统上拥有账户,并且保护自己的数据不被他人破坏。
154 0
|
7月前
|
监控 jenkins 测试技术
处理 Jenkins 中的测试预期失败与构建状态的设置
本文将讨论如何在 Jenkins 中处理测试中的预期失败情况,并将其与构建状态相结合,以便更好地监控和管理项目的健康状况。
处理 Jenkins 中的测试预期失败与构建状态的设置
|
8月前
|
Shell Linux
检查你是否是root用户
检查你是否是root用户
90 1
error MSB8008: 指定的平台工具集()未安装或无效。请确保选择受支持的 PlatformToolset 值
error MSB8008: 指定的平台工具集()未安装或无效。请确保选择受支持的 PlatformToolset 值
91 0
error MSB8008: 指定的平台工具集()未安装或无效。请确保选择受支持的 PlatformToolset 值
|
安全 API Android开发
教你如何高效的检查APK中使用敏感权限的地方以及检查某系统方法被调用的地方
教你如何高效的检查APK中使用敏感权限的地方以及检查某系统方法被调用的地方
402 0
教你如何高效的检查APK中使用敏感权限的地方以及检查某系统方法被调用的地方
|
XML 测试技术 Shell
SIPP不同的安装模式和做测试
SIPP不同的安装模式和做测试
Windiws10系统不显示可用网络的处理方法!
Windiws10系统不显示可用网络的处理方法!
420 0
Windiws10系统不显示可用网络的处理方法!
|
SQL 资源调度 关系型数据库