리버싱/Android

Android Root Detection Techniques in JNI

즉흥 2016. 8. 9. 19:36
728x90
반응형

참고 : https://blog.netspi.com/android-root-detection-techniques/



참고라기 보다는 거의 번역본.



1. Installed Files & Packages


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cstdio>
#include <string>
 
std::string FindFileDir[6= {"/sbin/su""/system/su",
                         "/system/sbin/su""/system/xbin/su",
                         "/data/data/com.noshufou.android.su",
                          "/system/app/Superuser.apk",
                         "/system/bin/su""/system/bin/.ext/.su",
                         "/system/usr/we-need-root/su-backup",
                         "/system/xbin/mu"};
 
bool CheckFile(){
    int i;
    for( i = 0; i < 6 ; i++){
        if ( access(FindFileDir[i].c_str(), F_OK == 0 )
            return true;
    }
    return false;
}
cs


Superuser.apk 패키지는 루팅된 디바이스에서 가장 흔하게 발견되는 패키지이다.


그 외에도 위에 나열된 su 바이너리 역시 루팅된 디바이스에서 가장 흔하게 발견되는 바이너리이다.




2. Directory Permissions



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <unistd.h>
#include <string>
bool CheckDir(){
    int i;
    std::string CheckDir[] = {
            "/data""/",
            "/system""/system/bin",
            "/system/sbin""/system/xbin",
            "/vendor/bin""/sys""/sbin",
            "/etc""/proc""/dev"};
    for( i = 0 ; i< 12; i++) {
        LOGI("ky msg : (%d/12) %s", i + 1, CheckDir[i].c_str());
        if (0 == access(CheckDir[i].c_str(), F_OK)) {
            if (0 == access(CheckDir[i].c_str(), W_OK))
                return true;
            if (i == 0) {
                if (0 == access(CheckDir[i].c_str(), R_OK))
                    return true;
            }
        }
    }
    return false;
}
cs


일반적으로 루팅되지 않은 폰에서는 /bin 디렉토리를 읽을 수 없다. (읽기 권한이 없다)

그리고 위에 언급된 모든 디렉토리에는 쓰기 권한이 없다.



3. Commands



su 명령어, id 명령어 등을 통해 현재 권한을 확인할 수 있다.


일반적인 안드로이드 기기에는 su 명령어 자체가 없고, 만약 루팅된 기기라면 id 명령어를 입력했을 때 root id가 나올 것이다.



1
2
shell@android:/ # id
uid=0(root) gid=0(root) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r)
cs


728x90
반응형