root检测实现
【摘要】 检测root
文章目录
1.检测路径
2.检测路径2
3.检测属性
4. 检测路径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;
}
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)