LoginSignup
11
14

More than 5 years have passed since last update.

端末に落としたAndroidアプリのAPKファイルを抽出する

Posted at
  • 他の方が作ったアプリの中身がどうなってるか気になって色々調べました
  • その最初のステップであるAPKファイルの抽出についてメモリます

前提

  • adbを使える前提

端末を確認

  • 接続された端末を確認します
[Hoge@Mac] ~
% adb devices        
List of devices attached
192.168.57.101:5555    device

対象アプリの置き場

  • 抽出対象のアプリが置かれたディレクトリを見つけます
  • 今回はContacts.apkファイルを対象にしています
  • いちいち出たり入ったりするのはメンドイので、シェル経由でコマンドをぶっこんであげましょう
[Hoge@Mac] ~
% adb -s 192.168.57.101:5555 shell pm list packages -f | grep -i Contacts
package:/system/priv-app/Contacts/Contacts.apk=com.android.contacts
package:/system/priv-app/ContactsProvider/ContactsProvider.apk=com.android.providers.contacts
  • /system/priv-app/Contacts/配下にあることがわかりました
  • ちなみにGoogle Playなどから落としたアプリはだいたい/data/app配下にいます

対象アプリを抽出(おしまい)

  • pullで抽出します
[Hoge@Mac] ~/workspace/android_security
% adb -s 192.168.57.101:5555 pull /system/priv-app/Contacts/Contacts.apk
6676 KB/s (3373448 bytes in 0.493s)
% ls -l
total 6592
-rw-r--r--  1 Hoge  staff  3373448  9  8 00:10 Contacts.apk

おまけ - AndroidManifestの抽出

[Hoge@Mac] ~/workspace/android_security
% /usr/local/bin/apktool d -f -s Contacts.apk 
[Hoge@Mac] ~/workspace/android_security
% ls -l
total 6592
drwxr-xr-x  7 Hoge  staff      238  9  8 00:18 Contacts/
-rw-r--r--  1 Hoge  staff  3373448  9  8 00:10 Contacts.apk
[Hoge@Mac] ~/workspace/android_security
% cd Contacts 
[Hoge@Mac] ~/workspace/android_security/Contacts
% ls -l
total 168
-rw-r--r--    1 Hoge  staff  20313  9  8 00:18 AndroidManifest.xml
-rw-r--r--    1 Hoge  staff  64960  9  8 00:18 apktool.yml
drwxr-xr-x    4 Hoge  staff    136  9  8 00:18 original/
drwxr-xr-x  105 Hoge  staff   3570  9  8 00:18 res/
drwxr-xr-x    3 Hoge  staff    102  9  8 00:18 unknown/
11
14
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
11
14