79
Hacker School Smart Phone Study Android Jack2

Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android

Jack2

Page 2: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 3: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 4: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Page 5: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?우리가 실제로

사용하는Application 은 ?

Page 6: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Page 7: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

구글이 운영하고 있는

안드로이드 마켓을 통해서

안드로이드용 응용 소프트웨어를

다운로드

Page 8: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

우리가 실제로 사용하는

Application=

안드로이드용 응용소프트웨어

=APK

Page 9: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

APK

: 안드로이드 어플리케이션의 확장자

안드로이드용 어플의 패키지

마켓에서 스마트폰으로 바로 설치할 수 있는 Format

apk 파일은 직접 스마트폰으로 복사하여 설치가능

Page 10: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

1. APK 파일정보 확인

Page 11: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Page 12: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

예제로 사용하기 위해 미리 제작해 놓은HelloAndroidWorld3.apk 을 이용해서 APK 파일 정보에 대해설명하겠습니다 ^_^

Page 13: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?Nexus S 에 설치를 한 뒤

Page 14: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?HelloAndroidWorld.apk

실행하면HelloAndroidWorld 라는간단한 Text 가 출력되는 것을볼 수 있습니다 .

Page 15: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

다시 데스크톱 환경으로 돌아와서Apk 파일의 정보를 확인해 보겠습니다 .

Page 16: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?Terminal 상에서 hexedit 를 이용해서HelloAndroidWorld3.apk 파일을확인해보았습니다 .

Page 17: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ? Header 정보를 확인한 결과50 4B 03 04 … => ZIP Header 와같다는 것을 알 수 있었습니다 .

Page 18: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

눈치빠른 분들은 hexedit 를 실행하기 전 파일을 보자마자 확인하셨을 것 같네요 .헤더파일 정보를 확인했듯이 zip 압축파일이라고 나오는 것을 볼 수 있습니다 .

Page 19: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

APK 파일을 열어보았더니META-INF, res, AndroidManifest.xml, classes.dex, resources.arsc 라는 폴더와 파일이 보이네요 .Apk 를 제작하면서 본 파일도 있지만 처음 본 파일도 있어서 구글링 ㄱㄱ

Page 20: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

= META-INF =

: 프로그램 자체 정보 데이터 배포시 인증서로 서명한 내용

Page 21: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

= res =

: 패키지가 가지고 있는 내부리소스 폴더

Page 22: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

= AndroidManifest.xml =

: 안드로이드 어플리케이션에 대한 전반적인 정보

Page 23: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

= classes.dex =

: 클래스들의 정보를 함축적으로 가지고 있는 파일 .

Page 24: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

= resources.arsc =

: 별도로 컴파일된 리소스 파일

Page 25: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

지금까지 살펴본 결과apk 파일은 위와 같은 구조로 구성되었다는 것을 알 수 있었습니다 .

Page 26: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

이제 APK 파일을 압축해제 시킨 뒤

Page 27: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

일반 text 로 이루어진 xml 파일을Gedit 으로 열어보기로 하죠 .원본소스코드를 볼 수 있다는 마음에기대가 되는데요 두구두구두구 !!

Page 28: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

하지만 기대가 큰 만큼 실망도 큰 법 OTL

Text 는 커녕 gedit 에서 확인 불가ㅠ . ㅠ

Page 29: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?혹시나 하는 마음에Hexedit 를 이용해서 파일을열어보았으나 약간의 text 는확인할 수 있을뿐 원본 xml 의 내용 그대로 볼 수는 없네요 ㅠ . ㅠ

Page 30: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Why? 왜 이런 결과과 나올까 ?

이런 궁금함이 생겨서

다시 구글링을 해보았습니다 .

Page 31: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

압축을 해제했을 때에 볼 수 있는 xml 파일은 일종의 Compile 된 xml 로 xml 변환을 막기위해 보안을 해놓은 것이라고 하네요 .

출처 : http://blog.naver.com/trddy/90134258434

Page 32: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Xml 파일이 Compile 이 되어있다고 하니

Decompile 을 해야 원본파일을 확인할 수 있겠네요 .

Page 33: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

이번에도 역시 구글링의 힘을 빌려서 검색한 결과

Page 34: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

decompile 하기 위해서 apktool 이라는 툴이 필요하다는 것을 알 수 있었습니다 .

그래서 지금부터는 apktool 을 이용해서 compile/decompile 하는 방법을 이야기해보죠 .

Page 35: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 36: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

- 준비해야 되는 Tool -

apktool : http://code.google.com/p/android-apktool/

압축해제 후

/usr/local/bin 으로 복사

Page 37: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

HelloAndroidWorld3.apk 파일이존재하는 경로를 확인합니다 .

Page 38: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

Apktool 을 돌려봅시다 ㅎㅎ옵션 설명 d : decode mode -d : debug mode

Page 39: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

짜자잔~Decoding 이 되었습니다 .

Page 40: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

이제 decoding 이 잘 (?)되었는지확인해보도록 하죠 ㅎㅎAndroidManifest.xml 파일을 제외하고나머지 폴더와 파일은 단순 압축해제를 했을 때와는 다르네요 .

Page 41: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

비교를 위해 다시 한 번 봅시다 . 압축해제를 했을때에 나타나는META-INF, res 폴더AndroidManifest.xml, classes.dex, resources.arsc 파일

Page 42: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile2. Decompile 된

APK 파일정보 확인

Page 43: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

= res =

: 패키지가 가지고 있는 내부리소스 폴더

Page 44: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

= Smali =

: 안드로이드의 dex 포맷에 대한 어셈블러 /디어셈블러

Page 45: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

Decompile 이 제대로 되었는지확인하기 위해 이전에 단순 압축해제시Gedit 으로 확인할 수 없었던hello_world.xml 파일을 확인해봅시다 .

과연 이번에는 ? 두구두구두구두 !

Page 46: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

브라보 ~~~짝 !짝 !짝 !보시다시피 이번에는 문제없이Xml 파일을 열 수 있었습니다 .한 마디로 decompile 이 잘 되었다는 것이겠죠 ?

Page 47: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

▲ 원본 소스코드에서 xml◀ Decompile 을 통해 얻은 xml

보시다시피 두 xml 파일의 내용이같은 것을 확인할 수 있었습니다 .

*참고 * : layout_width(_height)android 2.2 froyo 이후부터는fill_parent 가 mach_parent 로 변경됨

Page 48: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Apktool 을 이용한 APK decompile/compile

우리눈으로볼 수 있는화면 구성

=> UI 생성

Page 49: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 50: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 51: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

앞에서 확인한 hello_world.xml파일을 수정해보기로 하죠 .

Page 52: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

바로 이 부분을 수정해 보기로했습니다 .^_^

Page 53: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

Change TextText!!이렇게 수정을 했습니다 .

Page 54: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

수정을 하고 저장한 뒤HelloAndroidWorld3 디렉토리에 있는 파일들을 APK 로 생성했습니다 .

Page 55: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

이 경로에 들어가면HelloAndroidWorld3.apk 가 생성된 것을확인할 수 있습니다 .

Page 56: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

이 경로에 들어가면HelloAndroidWorld3.apk 가 생성된 것을확인할 수 있습니다 .

Page 57: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

APK 파일이 생성완료

Page 58: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

APK 파일이 생성완료

되었다고 생각하면 안된다 !!

Page 59: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

모든 Android Application 은

Deploy 되기 전에 Digital Signed 가 필요하다 .

다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Digital Certificates 를 구매할 필요없이

자신의 Personal Certificate 를 생성하여

Android Application 에 sign 하면 된다 .

Page 60: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

Sign 을하기 위한KEY 생성

Page 61: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

생성된 APK 파일과 Keystore 파일을 확인할 수 있습니다 .

Page 62: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

예제를 통한 실습 XML 수정 -1. XML 자체 수정

생성한KEY 로Sign

Page 63: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

SIGN 까지 마친 APK 파일을스마트폰으로 복사를 해주었습니다 .

Page 64: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

스마트폰에 복사한 APK 파일을 설치해보도록 하죠

Page 65: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

정상적으로 설치가 되었습니다 .과연 이 앱을 실행하면어떻게 결과가 바뀌었을까요 ?두구두구 두구두구 !!

Page 66: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

Change TextText!! 라는 내용을확인할 수 있었습니다 .

Page 67: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -1. XML 자체 수정

이전에 작업했던 hello_world.xml파일의 android:text 부분에 입력한문구가 그대로 출력되었다는 것을 확인할 수 있었습니다 .

Page 68: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study

Android 어디까지 알고있니 ?

Apktool 을 이용한 APK decompile/compile

예제를 통한 실습 XML 수정

1. XML 자체 수정

2. Smali 를 이용해서 다른 XML 나타나게 하기

Page 69: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용 Apktool 을 이용한 APK decompile/compile

= Smali =

: 안드로이드의 dex 포맷에 대한 어셈블러 /디어셈블러

Smali 가 무엇인지 잊어버린 분들을위해 다시 한 번 앞의 내용을 살펴봅시다

Page 70: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

Emacs 를 이용해서HelloAndroidWorldActivity.smali 와R$layout.smali 를 열어보았습니다 .

Page 71: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

HelloAndroidWorldActivity.smali 를확인하니 0x7f030001 이라는16진수가 보이는데요 .

Page 72: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

R$layout.smali 에서도0x7f030001 이라는16진수를 확인할 수 있었습니다 .앞의 변수를 확인해보니0x7f030001 은 hell_world.xml 파일을 가리킨다는 것을 알 수 있었습니다 .

Page 73: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

지금 현재 hacker_school.xml 이라는 파일도존재한다는 것을 확인할 수 있습니다 .

16진수로 0x7f030000 을 나타내는 것을알 수 있네요

Page 74: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

HelloAndroidWorldActivity.smali 를확인하니 0x7f030001 부분을0x7f030000 으로 바꾸면 기존의hello_world.xml 의 내용이 아니라hacker_school.xml 의 내용이 실행될 것 이라는 예상을 할 수 있습니다 .

Page 75: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

0x7f030000 으로 값을 변경한 뒤저장을 하고 1.XML 을 변경했을 때와동일하게 APK 파일을 생성해보았습니다 .

Page 76: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

과연 어떻게 바뀌었을까요 ?두구두구 두구두구 !!

Page 77: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 예제를 통한 실습 XML 수정 -2. Smali 를 이용

이렇게 hacker_school.xml 이실행되는 것을 확인할 수 있었습니다 .

Page 78: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 전체적인 정리

XML 수정

원본 파일Smali수정

Page 79: Android · 2012-03-26 · 모든 Android Application은 Deploy되기 전에 Digital Signed가 필요하다. 다른 모바일 플랫폼과는 달리 Certificate Authority(CA)로 부터

Hacker School Smart Phone Study 전체적인 정리

테스트한 앱은 간단한 텍스트가 표시되는 APK 파일이었지만 디컴파일을 통해서 xml 파일을 수정을 통해 APK 파일 변조가 가능하고 , smali 파일에서 0x7f030000 와 0x7f030001 을 통해서 보았듯이 1 이라는 차이를 통해 다른 내용이 앱에서 실행될 수 있다는 것을 알 수 있었습니다 .