본문 바로가기

카테고리 없음

자바소스 속 문자열 ID



apk의 decompile 된 자바소스를 JAD를 통해서 보는 과정에서 
문자열 표현이 실제 문자열이 아니라 이상한 번호로 되어 있더군요...

 

    onCreate(paramBundle);
    setContentView(2130903040);
    setRequestedOrientation(1);
    if (Build.VERSION.SDK_INT >= 7)
    {
      Intent localIntent = new Intent(this, AndroidMDKProvider.class);
      String str1 = getApplicationContext().getResources().getText(2130968578).toString();
      localIntent.putExtra("APPLICATION_ID", str1);
      String str2 = getApplicationContext().getResources().getText(2130968579).toString();
      localIntent.putExtra("DEVELOPER_ID", str2);
      String str3 = getApplicationContext().getResources().getText(2130968580).toString();
      localIntent.putExtra("M_SERVER_URL", str3);
      startService(localIntent);
    }



구글 검색을 통해 확인해보니 해당 숫자는 Resource ID라는 것으로..
APK 파일 안에 있는  resources.arsc 와 관련되어 있다고 하네요...... 

하지만, 해당 파일을 무작정 열어보니 흠.... ASCII 문자열 외의 값들도 포함되어 있더군요..

안드롱~은 리소스 테이블이 덤프된 모든 리소스에 대한 정보를 "resources.arsc" 파일로 유지한다고 합니다.  
리소스 파일은 aapt.exe(Android Asset Packaging Tool) 툴을 통해서 우리가 눈으로 확인할 수 있는 구조로 덤프할 수 있습니다. 

ApkTool>aapt.exe dump --values resources [test.apk] > resources.txt

 
덤프된 결과를 보면, 우리가 찾는 resource id의 Hex 값을 통해 값을 얻을 수가 있습니다. 

      config 0
        resource 0x7f040000 com.crazyapps.angry.birds.rio.unlocker:string/app_name: t=0x03 d=0x00000002 (s=0x0008 r=0x00) (PUBLIC)
          (string16) "Angry Birds Rio Unlocker"
        resource 0x7f040001 com.crazyapps.angry.birds.rio.unlocker:string/unlock_levels_text: t=0x03 d=0x00000003 (s=0x0008 r=0x00) (PUBLIC)
          (string16) "Unlock levels 1,2,3,4 in 1 click!"
        resource 0x7f040002 com.crazyapps.angry.birds.rio.unlocker:string/application_id: t=0x03 d=0x00000004 (s=0x0008 r=0x00) (PUBLIC)
          (string16) "325842966"
        resource 0x7f040003 com.crazyapps.angry.birds.rio.unlocker:string/developer_id: t=0x03 d=0x00000005 (s=0x0008 r=0x00) (PUBLIC)
          (string16) "752469853"
        resource 0x7f040004 com.crazyapps.angry.birds.rio.unlocker:string/m_server_url: t=0x03 d=0x00000006 (s=0x0008 r=0x00) (PUBLIC)
          (string16) "http://www.searchwebmobile.com/ProtocolGW/protocol"
    type 4 configCount=1 entryCount=1
      spec resource 0x7f050000 com.crazyapps.angry.birds.rio.unlocker:id/unlock_levels_button: flags=0x40000000


 
[참고] http://www.slideshare.net/aftekandroid/androidresourcemanagerkt