欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

android判断是否root或者是否能被root的方法

程序员文章站 2022-06-21 20:02:15
已知的root应用应用判断通过adb shell pm list packages | findstr xxx 判断是否存在下面的报名"com.noshufou.android.su","com.noshufou.android.su.elite","eu.chainfire.supersu","com.koushikdutta.superuser","com.thirdparty.superuser","com.yellowes.su","com.topjohnwu.magisk"....

已知的root应用应用判断

通过adb shell pm list packages | findstr xxx 判断是否存在下面的包名

"com.noshufou.android.su",
"com.noshufou.android.su.elite",
"eu.chainfire.supersu",
"com.koushikdutta.superuser",
"com.thirdparty.superuser",
"com.yellowes.su",
"com.topjohnwu.magisk"

判断是否存在一些需要root权限的应用

通过adb shell pm list packages | findstr xxx 判断是否存在下面的包名

"com.koushikdutta.rommanager",
"com.koushikdutta.rommanager.license",
"com.dimonvideo.luckypatcher",
"com.chelpus.lackypatch",
"com.ramdroid.appquarantine",
"com.ramdroid.appquarantinepro",
"com.android.vending.billing.InAppBillingService.COIN",
"com.chelpus.luckypatcher"

检测一些常用目录是否有su文件

"/data/local/",
"/data/local/bin/",
"/data/local/xbin/",
"/sbin/",
"/su/bin/",
"/system/bin/",
"/system/bin/.ext/",
"/system/bin/failsafe/",
"/system/sd/xbin/",
"/system/usr/we-need-root/",
"/system/xbin/",
"/cache/",
"/data/",
"/dev/"

除了这种方法还可以通过Linux 的which命令来查找su文件,这样会更全面的查找。但是不可避免的一个问题就是,如果曾经root过但是root权限已经失效的设备会被判断成已经root。这个可以根据需求添加

判断系统的Tags标签

建设银行解析后的判断节点有:

    不能包含下面这些apk文件:
    public static final String[] a = new String[]{"com.noshufou.android.su", "com.noshufou.android.su.elite", "eu.chainfire.supersu", "com.koushikdutta.superuser", "com.thirdparty.superuser", "com.yellowes.su"};
    public static final String[] b = new String[]{"com.koushikdutta.rommanager", "com.koushikdutta.rommanager.license", "com.dimonvideo.luckypatcher", "com.chelpus.lackypatch", "com.ramdroid.appquarantine", "com.ramdroid.appquarantinepro"};
    public static final String[] c = new String[]{"com.devadvance.rootcloak", "com.devadvance.rootcloakplus", "de.robv.android.xposed.installer", "com.saurik.substrate", "com.zachspong.temprootremovejb", "com.amphoras.hidemyroot", "com.amphoras.hidemyrootadfree", "com.formyhm.hiderootPremium", "com.formyhm.hideroot"};

以下文件可以执行su操作:

 public static final String[] d = new String[]{"/data/local/", 
                                                  "/data/local/bin/", 
                                                  "/data/local/xbin/", 
                                                  "/sbin/", 
                                                  "/su/bin/", 
                                                  "/system/bin/", 
                                                  "/system/bin/.ext/", 
                                                  "/system/bin/failsafe/", 
                                                  "/system/sd/xbin/", 
                                                  "/system/usr/we-need-root/", 
                                                  "/system/xbin/"};

以下目录是否有写入的权限: (成功)

    public static final String[] e = new String[]{"/system", 
                                                  "/system/bin", 
                                                  "/system/sbin", 
                                                  "/system/xbin", 
                                                  "/vendor/bin", 
                                                  "/sbin", 
                                                  "/etc"};
}

本文地址:https://blog.csdn.net/wangjicong_215/article/details/107385590

相关标签: Android root