Android

[Android] APK 디컴파일, 리패키징

시커먼수르 2022. 1. 13. 09:41

 

1. APK 를 추출한다.

마켓의 ExtractApk 앱이 가장 유명하다.

다른걸로 추출해도 됨..

 

2. PC로 추출된 APK를 복사한다.

 

3. JADX 툴을 이용하여 디컴파일된 코드를 확인한다.

https://github.com/skylot/jadx

 

GitHub - skylot/jadx: Dex to Java decompiler

Dex to Java decompiler. Contribute to skylot/jadx development by creating an account on GitHub.

github.com

 

여러가지 방법이 있지만 JADX 가 가장 쉽게 코드를 확인하는 방법중 하나이다.

 

4. 혹시나 코드를 수정해서 다시 리패키징하여 테스트해보고 싶다면?

APKTool을 이용해야한다.

https://ibotpeaches.github.io/Apktool/

 

Apktool - A tool for reverse engineering 3rd party, closed, binary Android apps.

A tool for reverse engineering 3rd party, closed, binary Android apps. It can decode resources to nearly original form and rebuild them after making some modifications. It also makes working with an app easier because of the project like file structure and

ibotpeaches.github.io

APktool을 이용하여 디컴파일을 수행하면, Smaili라는 확장자를 가진 어셈블리어 비슷한 코드가 나오게 된다.

이걸 수정하면된다.

 

하지만 저걸 어떻게 수정해야하나..?

인터넷에 Smali 문법으로 검색하면 많이 나오긴한다.

일단 jadx로 디컴파일된 소스를 찾아서, apktool로 디컴파일된 파일로 가서 수정을 하면 된다.

 

수정이 끝났다면 apktool로 apk로 만든다.

 

 

5. APK signing하기

아래 링크로 가서 signapk, pem, pk8 파일들을 받은뒤 signing을 수행한다.

https://github.com/appium/sign

 

GitHub - appium-boneyard/sign: Sign.jar automatically signs an apk with the Android test certificate.

Sign.jar automatically signs an apk with the Android test certificate. - GitHub - appium-boneyard/sign: Sign.jar automatically signs an apk with the Android test certificate.

github.com

 

 

6. Signing을 했는데도 apk가 설치가 안된다면?

흠.. Global setting을 이렇게 쉽게 바꾸게 해도되는건가

다시 원복시키는 법은 다시 찾아봐야할듯 하다.

 

하지만 끝내 apk 재설치는 실패했다. 그냥 코드 보는 용도로만 써야할 듯 하다.

 

 

7. 출처들

 

https://codechacha.com/ko/how-to-decompile-android-apk/

 

안드로이드 앱(apk)을 decompile하는 다양한 방법

Android apk를 decompile하는 방법을 소개합니다. Apk는 zip으로 압축된 파일입니다. 압축을 풀면 여러 리소스 파일들과 실행 파일인 dex(Dalvik Executable)파일이 있습니다. 몇개의 툴(Apktool, dex2jar, jd-cmd)을

codechacha.com

 

https://cha3m.tistory.com/72