티스토리 뷰


취약점 상세 진단 - 루팅 탐지 및 우회



취약점 소개

리눅스 기반 OS 에서 보안상의 이유로 Root 권한을 막아 놓았다. 안드로이드의 경우도 마찬가지로 애플리케이션에서 할 수 있는 행위가 제한된다. 이런 제한을 풀거나 우회하기 위해 시스템 권한을 루트 권한으로 획득해야 한다.

Root 권한이 부여되면 안드로이드 앱과 모든 자원에 대한 권한이 생겨 모든 조작이 가능해진다. 때문에 기기 또는 앱 삭제 및 다양한 문제가 생길 수 있으므로 민감한 앱에서는 Rooting된 기기에서는 설치가 불가능하게 하기도 한다.


진단 과정

주로 Rooting 체크하는 방법

 - 루팅 체크 주 경로 4가지 

  /system/bin/su

  /system/sbin/su

  /system/app/superuser.apk

  /data/data/com.noshufou.android.su

 - PostLogin.class 로직확인






PostLogin.class 파일 확인


PostLogin.class 의 Rooting 탐지

private boolean doesSUexist()
  {
    Object localObject3 = null;
    Object localObject1 = null;
    try
    {
      localProcess = Runtime.getRuntime().exec(new String[] { "/system/xbin/which""su" });
      localObject1 = localProcess;
      localObject3 = localProcess;
      String str = new BufferedReader(new InputStreamReader(localProcess.getInputStream())).readLine();
      return str != null;
    }
    catch (Throwable localThrowable)
    {
      Process localProcess;
      if (localObject1 != null) {
        ((Process)localObject1).destroy();
      }
      return false;
    }
    finally
    {
      if (localThrowable != null) {
        localThrowable.destroy();
      }
    }
  }
 
cs


private boolean doesSuperuserApkExist(String paramString)
  {
    return Boolean.valueOf(new File("/system/app/Superuser.apk").exists()).booleanValue() == true;
  } 
 
cs



adb shell  확인






class 파일 분석으로 찾아본 결과 해당 파일들이 존재하고 있으므로 Rooting된 상태임을 알 수 있다.


우회방법 

파일이름 변경으로 간단히 우회 가능.

Runtime.getRuntime().exec("시스템 명령어") 를 사용하여 su 명령어가 동작하면 Rooting 확인이 가능하다.


대응방안

문자열 난독화로 Rooting 탐지 로직을 알수 없도록 해야한다.

apk 파일 조작하여 루팅을 유지하는 것을 방지해야하며 무결성 검증이 필요하다.

Rooting 되어있는 것이 확인되면 금융앱이나 민감한 정보를 다루는 앱은 사용을 중지해야 한다.




Comments
최근에 올라온 글
최근에 달린 댓글
TAG
more
Total
Today
Yesterday