개발/안드로이드 rooting

root detection in android device

개복치 개발자 2019. 11. 16. 19:53

 

Root Detection in Android device 의 번역본입니다.

 

 

Root Access is the process of allowing users smartphones, tablets and other devices running the Android mobile operating system to attain privileged control (known as root access). 

 

루트 어세스는 스마트폰의 관리자 권한(루트 엑세스)를 얻는 프로세스입니다.

 

 

“Rooting” is the process by which one gains access to the administrative commands and functions of an operating system.

 

"루팅"은 운영 체제의 관리 명령 및 기능에 접근하는 프로세스입니다.

 

It gives the ability (or permission) to alter or replace system applications, files, and settings, removing pre-installed applications, run specialized applications (“apps”) that require administrator-level permissions.

 

시스템 응용 프로그램, 파일 및 설정 변경 또는 교체. 설치된 응용 프로그램을 제거하고 관리자 권한이 필요한 프로그램을 실행할 수 있습니다.

 

Why root Android Device?

 

왜 루팅을 할까요?

 

Super User will get the privileged control (root access), full control over the applications installed on your handset, can remove the pre-installed application, full system backup with apps, installing a different version of Android, update with customs ROMs and many more.

 

슈퍼유저는 특권제어를 할 수 있는데, 어플리케이션에 설치된 모든 권한과, 시스템 백업, 다른 버전 안드로이드 설치, ROM 커스텀 등을 컨트롤 할 수 있습니다.

 

Why is a rooted device potentially dangerous to users/apps?

 

루팅된 기기가 위험한 이유는 무엇일까요?

 

System security and safeguards cannot be guaranteed after the root. In root, device data is at risk, including gaining access to personal information such as contact lists, emails, and other data, or collecting data like credentials and passwords. With a rooted device, a user or malicious program can elevate their permissions to root and circumvent this protection giving them access to other app’s private data.

So it is the best way to check in your application whether the device is rooted or not to avoid data theft but there’s no 100% way to check for root.

 

루팅 이후에는 시스템 보안을 보장할 수 없습니다. 개인 정보인 연락처 리스트 이메일 등 데이터에 접근하거나, 자격증명 및 비밀번호에 접근할 수 있습니다.

따라서, 가장 데이터 유출을 방지하기 위한 좋은 방법은 디바이스가 루팅되었는지 확인하는 방법이지만, 100% 탐지하기는 어렵습니다.

 

 

Let’s see, how to check the device is rooted or not

 

일단 장치가 루팅 되었는지 알아봅니다.

 

Check for Test-Keys: Test-Keys has to do with how the kernel is signed when it is compiled. By default, stock Android ROMs from Google are built with release-keys tags. Test-Keys means it is signed with a custom key generated by a third-party developer. Specifically, it will check in build properties(“android.os.Build.TAGS”) for test-keys.

 

테스트키 확인 : 테스트키는 커널이 컴파일될때 서명되는 방법과 관려이 있습니다. 디폴트로, Android ROM은 release-key tage로 빌드됩니다. 테스트 키는 개발자가 생성한 사용자 지정 키로 서명되었음을 의미하고, “android.os.Build.TAGS” 로 접근 가능합니다.

 

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

 

Check for “su” binary: Su binary check is to identify the superuser in the device. 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. The existence of this binary can be checked from the following paths.

 

"su" 확인 : "su" 바이너리 체크는 유퍼유저를 식별할 떄 사용합니다. 이 것은 핸드폰이 루팅될 때 생성되며, 이 파일은 핸드폰을 루팅하고 슈퍼유저가 될 때 사용되며, 아래 경로에서 확인 가능합니다.

 

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

 

Check for “busybox” binary: 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. Running busybox is a good indication that a device has been rooted.

 

busybox 체크 : busybox는 루팅된 장치에 종종 설치됩니다. 이 것은 linux 명령어를 제공하는 바이너리 파일이고, busybox가 실행되면 루팅된 디바이스라고 생각할 수 있습니다.

 

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

 

To check for the existence of the su or busybox binary

 

busybox 체크하는 코드

 

/**
 * @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;
}

 

 

Check for SuExists: different file system check for the su binary.

 

su 파일 체크

 

/**
 * A variation on the checking for SU, this attempts a 'which su'
 * different file system check for the su binary
 * @return true if su exists
 */
private boolean checkSuExists() {
    Process process = null;
    try {
        process = Runtime.getRuntime().exec(new String[]
                {"/system /xbin/which", "su"});
        BufferedReader in = new BufferedReader(
                new InputStreamReader(process.getInputStream()));
        String line = in.readLine();
        process.destroy();
        return line != null;
    } catch (Exception e) {
        if (process != null) {
            process.destroy();
        }
        return false;
    }
}

 

The following paths, Su and busybox binaries are often looked for on rooted devices.

 

아래의 경로에 su와 busybox가 탐지됩니다.

 

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"
};

 

There are few applications which hide the root status of your Android device.
Hence using the Package Manager we can check for installed apps that are typically used for managing superuser/root access. 
The following are the few Root cloaking and Potentially Dangerous Apps

 

루팅을 숨기는 앱은 거의 없습니다. 그러므로 패키지 관리자를 이용해서 슈퍼유저와 루트 액세스 관리에 설치된 앱을 확인할 수 있습니다

 

com.devadvance.rootcloak
com.devadvance.rootcloakplus
com.koushikdutta.superuser
com.thirdparty.superuser

 

This is probably nowhere near a complete list, but it does show the many different ways root can be detected on Android devices.
Since a rooted device is much more at risk of being compromised, it is important to know about it. Detecting whether the device is rooted or not is essential for further security measures. There are ways to implement complex techniques but bypassing these verifications is not that difficult. It is always recommended to do not just depend on root detection techniques but secure the mobile application from all aspect of the information security.

 

이 것은 완전한 목록은 아니지만, 안드로드에서 루트를 탐지할 수 있는 여러 방법입니다. 루팅 된 기기는 많은 위협에 노출될 수 있고 추가 보안조치를 위해서는 기기가 루팅되었는지 확인해야합니다. 복합한 기술을 구현하는 방법이 있지만, 이 것을 우회하는 것은 어렵지 않습니다. 루트 탐지 기술뿐만 아니라, 모든 측면에서 모바일 애플리케이션을 보호해야합니다.

 

 

 

'개발 > 안드로이드 rooting' 카테고리의 다른 글

Reversing DexGuard’s String Encryption  (0) 2019.12.02
루팅 어플 체크  (0) 2019.11.17
무결성검사  (0) 2019.11.14
코드 난독화  (0) 2019.11.13
후킹(hooking)  (0) 2019.11.13