[Android]/data/以下のファイルにアクセスする

スポンサーリンク

掲題の通り、Androidで、/data/以下のファイルにアクセスする方法です。

結論

run-as [アプリパッケージ名]

アプリパッケージ名について
具体的には、jp.co.domain.appnameみたいな一意のアプリであることを示す名前です。

アプリパッケージ名の調べ方

ソースコードから調べる

build.gradleとか、AndroidManifest.xmlなどのファイルを読んでみたり、
APPLICATION_IDとか、applicationIdとかで検索したり。
 あまり知らないアプリの中を見ようとすると複数あったりして、以外にどれ?ってなりました。。。

コマンドで調べる

$ adb shell pm list package

でインストールパッケージ一覧を表示して調べる
 それっぽい名前が見つける

Samsung(サムスン)端末のAndroid6.0.1だとできない?

Galaxyで発生するそうです。

$ run-as org.ligi.passandroid
run-as: Could not set capabilities: Operation not permitted

According to this, this is a bug on Samsung devices: code.google.com/p/android/issues/detail?id=206581#c4

If you have a SAMSUNG device, don’t bother – SAMSUNG broke run-as by dropping the setuid flag (so run-as has no chance of switching to a different identity).
Also don’t bother trying the Smart Switch "reinitialize device" workaround, it won’t work until SAMSUNG fixes it in the firmware (so it is worth updating to the latest version).
Use some other method to access your app’s data, like adb backup:

adb backup -f data.ab <my.package>
dd if=data.ab  bs=24 skip=1 | openssl zlib -d > data.tar

コメント

  1. Buggy より:
タイトルとURLをコピーしました