Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android root detection using build tags?

Tags:

android

root

The following method is one of the ways we can programatically detect if an android device is rooted:

public boolean checkRootMethod1(){
    String buildTags = android.os.Build.TAGS;

    if (buildTags != null && buildTags.contains("test-keys")) {
        return true;
    }
    return false;
}

Can someone explain what this is actually doing? What is the "test-keys" build tag, and what does it have to do with root? I couldn't find any relevant information from google.

like image 597
thisiscrazy4 Avatar asked Sep 15 '13 03:09

thisiscrazy4


People also ask

How to get the build tag of an Android device?

String buildTags = android.os.Build.TAGS; This code is for getting build.prop located in /system/build.prop. As you can see you are getting android.os.Build.TAGS that means you are getting ro.build.tags value inside build.prop. here is the code of build.java

How to bypass root detection on Android devices?

We can bypass the root detection logic with adb shell of the device and hide/replace the root files and directories in the device With the help of apps and frameworks such as Xposed, RootCloak, etc. we will have to disallow apps to read the root detection from your rooted device

How to detect all types of rooting methods?

Hence, there is no single check that detects all types of rooting methods. Hence, implementing multiple checks will ensure a higher detection rate. Most detection apps simply try to run su or perform basic checks. Root Inspector uses multiple methods of root detection. There are 15 root checks via SDK (Java) and 13 checks via NDK (Native Code).

How to check if a device is rooted?

Another common way used by security experts for root detection is to search for applications that are commonly found on a rooted device. Some of such examples are Busyboy, Titanium Backup, Xposed Manager, Luckypatcher. Similarly, we can also use the shell to confirm some of the apps too.


2 Answers

Release-Keys and Test-Keys has to do with how the kernel is signed when it is compiled. Release-Keys means it was signed with an official Key from an official developer. Test-Keys means it was signed with a custom key generated by a third-party developer. From a security standpoint Release-Keys generally means the kernel is more secure, which is not always the case.

like image 116
gollum18 Avatar answered Sep 22 '22 21:09

gollum18


String buildTags = android.os.Build.TAGS;

This code is for getting build.prop located in /system/build.prop. As you can see you are getting android.os.Build.TAGS that means you are getting ro.build.tags value inside build.prop. here is the code of build.java

For your second question I can not make sure it will work because my ro.build.tags string is release-keys in my rooted device.

like image 28
Sieryuu Avatar answered Sep 20 '22 21:09

Sieryuu