Thông thường lập trình viên thường check root theo luồng logic lập trình dưới.
- /system/bin/su
- /system/xbin/su
- /sbin/su (less common)
- /system/sbin/su (less common)
- /system/bin/.ext/.su (sometimes used for hiding the binary)
- /system/xbin/mu (another hidden location)
- “/system/sd/xbin/su
- /data/local/xbin/su
- /data/local/bin/su
- /data/local/su
- /system/bin/failsafe/su
1 số kiểu check detect
privatestaticboolean isDebug; //check máy có debugs hay không?
privatestaticboolean isEmulator; //check máy ảo
privatestaticboolean isIntegrity;
privatestaticboolean isRoot; // check root
publicenum Architecture {
X86_32,
X86_64,
ARM_UNKNOWN,
PPC,
PPC64,
ARMV6,
ARMV7,
UNKNOWN,
ARMV7S,
ARM64;
/
publicstaticboolean isRooted(Context context) {
boolean isEmulator = isEmulator(context);
String str = Build.TAGS;
if ((isEmulator || str == null || !str.contains("test-keys")) && !new File("/system/app/Superuser.apk").exists()) {
return !isEmulator && new File("/system/xbin/su").exists();
}
returntrue;
}