root检测代码

简介: 检测root

文章目录
1.检测路径
2.检测路径2
3.检测属性

  1. 检测路径3

5.检测包名

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;

}

相关文章
|
5月前
|
JSON Shell 数据格式
sh脚本之判断环境
sh脚本之判断环境
|
9月前
|
数据安全/隐私保护
kali下设置root权限(包含很多技巧)
kali下设置root权限(包含很多技巧)
|
9月前
|
弹性计算 运维 Unix
检查当前是不是root用户
【4月更文挑战第29天】
63 2
|
9月前
|
机器学习/深度学习 Shell 开发工具
利用 test命令的测试功能
【1月更文挑战第4天】利用 test命令的测试功能。
97 4
|
9月前
|
安全 数据库
2021Kali系列 -- 漏洞检测(wmap/db_nmap)
2021Kali系列 -- 漏洞检测(wmap/db_nmap)
70 0
|
Shell Linux
检查你是否是root用户
检查你是否是root用户
171 1
|
Shell 开发工具 Perl
写一个脚本/root/bin/sumid.sh,计算/etc/passwd 文件中的第10个用户和第20用户的ID之和
写一个脚本/root/bin/sumid.sh,计算/etc/passwd 文件中的第10个用户和第20用户的ID之和
79 1
|
算法
Qt实现一个重复文件检测小工具(原理:通过md5校验)
Qt实现一个重复文件检测小工具(原理:通过md5校验)
338 0
|
Unix Linux
RHEL系统状态检测命令
1.ifconfig命令 2.uname命令 3.uptime命令 4.free命令 5.who命令 6.last命令 7.ping命令 8.traceoath命令 9.netstat命令 10.history命令 11.sosreport命令
235 0
RHEL系统状态检测命令
Daz
|
Unix Linux