ANDROID] 루팅, 디버깅 확인

노션으로 옮김·2020년 5월 5일
1

Study

목록 보기
24/33
post-thumbnail

루팅

Test-Key

Test-Keys means it was signed with a custom key generated by a third-party developer.

Does it mean my device is rooted?

The fact that you have not been able to apply official firware updates ( which check for root ) indicates that the device may be rooted (in addition ). You can verify in alternate ways (other than apps ) as mentioned here How can I tell if I have root?

https://android.stackexchange.com/questions/176083/does-test-keys-mean-device-is-rooted

private boolean detectTestKeys() {
    String buildTags = android.os.Build.TAGS;
    return buildTags != null && buildTags.contains("test-keys");
}

su binary

This binary is installed when you try to root your phone using apps like kinguser or via fastboot in Android. These files are necessary so that one can root their phone and become the superuser.

private String[] binaryPaths= {
        "/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/",
        "/system/app/Superuser.apk",
        "/cache",
        "/data",
        "/dev"
};
/**
 * @param filename - check for this existence of this 
 * file("su","busybox")
 * @return true if exists
 */
private boolean checkForBinary(String filename) {
    for (String path : binaryPaths) {
        File f = new File(path, filename);
        boolean fileExists = f.exists();
        if (fileExists) {
            return true;
        }
    }
    return false;
}

private boolean checkForSuBinary() {
    return checkForBinary("su"); // function is available below
}

busybox

If a device has been rooted, more often than not Busybox has been installed as well. Busybox is a binary that provides many common Linux commands.

private boolean checkForBusyBoxBinary() {
   return checkForBinary("busybox");//function is available below
}

디버깅

public static boolean a(Context context) {
    return (context.getApplicationContext().getApplicationInfo().flags & 2) != 0; //2 or ApplicationInfo.FLAG_DEBUGGABLE
}

참조

https://medium.com/@deekshithmoolyakavoor/root-detection-in-android-device-9144b7c2ae07

https://lsit81.tistory.com/entry/Android-%EB%A3%A8%ED%8C%85-%EC%97%AC%EB%B6%80-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0

1개의 댓글

comment-user-thumbnail
2024년 4월 5일

Great. I learned your ways to play the game better.

답글 달기