12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

apkを狙い撃ちでadb pullする

Posted at

参考 : https://stackoverflow.com/questions/29992225/adb-copy-apk-from-system-app-using-pull-command

(´-`).。oO(タイトルのセンスが…orz)

狙い撃ちする

パッケージ名を調べる

# パッケージ名一覧から探す
$ adb shell pm list packages

# grepしても良いでしょう
$ adb shell pm list packages | grep com.example.hoge
package:com.example.hoge.fuga

居所を調べる

$ adb shell pm path com.example.hoge.fuga
package:/data/app/com.example.hoge.fuga-1/base.apk

撃つ

$ adb pull /data/app/com.example.hoge.fuga-1/base.apk
/data/app/com.example.hoge.fuga-1/base.apk: 1 file pulled. 5.6 MB/s (15269701 bytes in 2.606s)

pullできました!

一網打尽

すみません、シェルスクリプトで書こうとしたんですがうまく書けず、rubyに逃げました。 :bow_tone1:

./apk-collector.rb
list = `adb shell pm list packages | sed -e 's/package://g'`.split("\r\n")

# Tip: 同様にgrepしても良いでしょう
# list = `adb shell pm list packages | grep com.example | sed -e 's/package://g'`.split("\r\n")


list.each {|package|
  path = `adb shell pm path #{package}`.sub(/package:+/, '').sub(/\r\n+/,'')
  `adb pull #{path}`
}
$ ruby ./apk-collector.rb

これで実行したディレクトリにapkが転がると思います。

以上

12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?