LoginSignup
8
6

More than 5 years have passed since last update.

Android - Proguardで難読化して、リバースエンジニアリングして確認してみるまで

Posted at

Proguardで難読化する

Proguardを有効にする

app/build.gradleminifyEnabled trueを追加する

app/build.gradle
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

とりえあずやってみる

Build > Generate Signed APK ... を実行して、難読化を実行してみる

エラーが出たら

Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn xx.yy.** してwarningを消す

基本的には以上で完了。

リバースエンジニアリングしてみる

apk取り出し

Android 7.0以前

$ adb shell pm path <pkg_name>
# => package:/data/app/com.xxx.yyy-1/base.apk
$ adb pull /data/app/com.xxx.yyy-1/base.apk

Android 7.0以降

$ adb shell pm path <pkg_name>
# => package:/data/app/com.xxx.yyy-1/base.apk
$ adb shell cp/data/app/com.xxx.yyy-1/base.apk /storage/emulated/0/Download
$ adb pull /storage/emulated/0/Download/base.apk

または、 APK抽出アプリを入れて取り出したapkファイルを使う。
例えば ... ApkExtractor

dexファイル取り出し

unzip xxx.apk

たくさんファイルできるので注意。どこかフォルダに入れてからunzipコマンドを実行するのがいいかも。

dex → jar

dex2jarを任意のフォルダにダウンロードし、実行権限がない場合は与える。 (GithubからDownloadして解凍したフォルダ内のファイル)

chmod +x *

次に、jarファイルへの変換を行う

sh d2j-dex2jar.sh -f target.dex

dex2jarと同じフォルダに classes-dex2jar.jar ができていれば成功。

デコンパイルツールを入れて確認。

JD-GUIをダウンロードする。先程のjarファイルをDrag&Drop。

参考

ProGuardによるクラッシュ・不具合を正しく回避する

8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6