오늘은 apk 디컴파일을 통해 소스 코드를 조회하고 코드 난독화가 이루어졌는지 확인하는 방법에 대해 알아보도록 하겠습니다.
본 포스팅은 macOS
기준으로 작성되었습니다.
1. Preview
apk 디컴파일 과정은 아래와 같습니다.
- apk를 jar 파일로 변환
- jar 파일의 소스 코드 조회
위 과정을 위해 필요한 것은 3가지 입니다.
apk
dex2jar
: apk to jarJD-GUI
: jar 내용을 보여주는 툴
2. 툴 다운로드
2-1. dex2jar
https://github.com/pxb1988/dex2jar
GitHub - pxb1988/dex2jar: Tools to work with android .dex and java .class files
Tools to work with android .dex and java .class files - GitHub - pxb1988/dex2jar: Tools to work with android .dex and java .class files
github.com
위 페이지에서 dex2jar
를 다운받습니다.
2-2. JD-GUI
http://java-decompiler.github.io/
Java Decompiler
The “Java Decompiler project” aims to develop tools in order to decompile and analyze Java 5 “byte code” and the later versions. JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reco
java-decompiler.github.io
마찬가지로 OS에 맞는 JD-GUI
를 다운받습니다
3. 소스 코드 조회 및 난독화 적용 확인
터미널에서 dex2jar를 다운로드 받은 경로로 이동해줍니다.
그리고 준비한 apk를 해당 경로로 이동 or 복사해줍니다.
sh d2j-dex2jar.sh <APK_NAME>
명령어를 입력해서 apk 파일을 jar 파일로 변환합니다.
해당 경로에 jar 파일이 생긴 것을 확인할 수 있습니다.
이제 JD-GUI
를 켜고 위 jar 파일을 open 합니다.