13 KiB
Drozer チュートリアル
{{#include ../../../banners/hacktricks-training.md}}
テストする APK
このチュートリアルの一部は Drozer ドキュメント pdfから抜粋されました。
インストール
ホスト内に Drozer クライアントをインストールします。最新のリリースからダウンロードしてください。
pip install drozer-2.4.4-py2-none-any.whl
pip install twisted
pip install service_identity
最新のリリースからdrozer APKをダウンロードしてインストールします。現時点ではこれです。
adb install drozer.apk
サーバーの起動
エージェントはポート31415で実行されています。Drozerクライアントとエージェント間の通信を確立するために、ポートフォワーディングを行う必要があります。これを行うためのコマンドは次のとおりです:
adb forward tcp:31415 tcp:31415
最後に、アプリケーションを起動し、下の「ON」を押します。
そして、それに接続します:
drozer console connect
興味深いコマンド
コマンド | 説明 |
---|---|
Help MODULE | 選択したモジュールのヘルプを表示します |
list | 現在のセッションで実行可能なすべてのdrozerモジュールのリストを表示します。適切な権限がないモジュールは非表示になります。 |
shell | エージェントのコンテキストでデバイス上にインタラクティブなLinuxシェルを開始します。 |
clean | Androidデバイス上にdrozerが保存した一時ファイルを削除します。 |
load | drozerコマンドを含むファイルを読み込み、順番に実行します。 |
module | インターネットから追加のdrozerモジュールを見つけてインストールします。 |
unset | drozerが生成する任意のLinuxシェルに渡す名前付き変数を削除します。 |
set | drozerによって生成される任意のLinuxシェルに環境変数として渡される変数に値を格納します。 |
shell | エージェントのコンテキストでデバイス上にインタラクティブなLinuxシェルを開始します。 |
run MODULE | drozerモジュールを実行します |
exploit | Drozerはデバイスで実行するためのエクスプロイトを作成できます。 drozer exploit list |
payload | エクスプロイトにはペイロードが必要です。 drozer payload list |
パッケージ
名前の一部でフィルタリングしてパッケージ名を見つけます:
dz> run app.package.list -f sieve
com.mwr.example.sieve
パッケージの基本情報:
dz> run app.package.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
Process Name: com.mwr.example.sieve
Version: 1.0
Data Directory: /data/data/com.mwr.example.sieve
APK Path: /data/app/com.mwr.example.sieve-2.apk
UID: 10056
GID: [1028, 1015, 3003]
Shared Libraries: null
Shared User ID: null
Uses Permissions:
- android.permission.READ_EXTERNAL_STORAGE
- android.permission.WRITE_EXTERNAL_STORAGE
- android.permission.INTERNET
Defines Permissions:
- com.mwr.example.sieve.READ_KEYS
- com.mwr.example.sieve.WRITE_KEYS
マニフェストを読む:
run app.package.manifest jakhar.aseem.diva
パッケージの攻撃面:
dz> run app.package.attacksurface com.mwr.example.sieve
Attack Surface:
3 activities exported
0 broadcast receivers exported
2 content providers exported
2 services exported
is debuggable
- 活動: おそらく、アクティビティを開始し、起動を防ぐべき認証をバイパスできるかもしれません。
- コンテンツプロバイダー: おそらく、プライベートデータにアクセスしたり、いくつかの脆弱性(SQLインジェクションやパストラバーサル)を悪用できるかもしれません。
- サービス:
- デバッグ可能: 詳細を学ぶ
活動
エクスポートされたアクティビティコンポーネントの “android:exported” 値は、AndroidManifest.xmlファイルで “true” に設定されています:
<activity android:name="com.my.app.Initial" android:exported="true">
</activity>
エクスポートされたアクティビティのリスト:
dz> run app.activity.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
com.mwr.example.sieve.FileSelectActivity
com.mwr.example.sieve.MainLoginActivity
com.mwr.example.sieve.PWList
アクティビティを開始:
おそらく、アクティビティを開始し、起動を防ぐべきいくつかの認証をバイパスできるかもしれません。
dz> run app.activity.start --component com.mwr.example.sieve com.mwr.example.sieve.PWList
adbを使用してエクスポートされたアクティビティを開始することもできます:
- PackageNameはcom.example.demoです
- Exported ActivityNameはcom.example.test.MainActivityです
adb shell am start -n com.example.demo/com.example.test.MainActivity
コンテンツプロバイダー
この投稿はここに収まりきらないので、こちらの独自のページでアクセスできますこちら。
サービス
エクスポートされたサービスは、Manifest.xml内で宣言されます:
<service android:name=".AuthService" android:exported="true" android:process=":remote"/>
コード内でcheckを行い、handleMessage
関数を探してください。この関数はmessageを受信します:
サービスのリスト
dz> run app.service.info -a com.mwr.example.sieve
Package: com.mwr.example.sieve
com.mwr.example.sieve.AuthService
Permission: null
com.mwr.example.sieve.CryptoService
Permission: null
サービスと対話する
app.service.send Send a Message to a service, and display the reply
app.service.start Start Service
app.service.stop Stop Service
例
app.service.send
のdrozerヘルプを見てください:
最初に"msg.what"の中のデータを送信し、その後に"msg.arg1"と"msg.arg2"を送信します。どの情報が使用されているかとその場所をコード内で確認する必要があります。
--extra
オプションを使用すると、"msg.replyTo"によって解釈されるものを送信でき、--bundle-as-obj
を使用すると、提供された詳細を持つオブジェクトを作成します。
次の例では:
what == 2354
arg1 == 9234
arg2 == 1
replyTo == object(string com.mwr.example.sieve.PIN 1337)
run app.service.send com.mwr.example.sieve com.mwr.example.sieve.AuthService --msg 2354 9234 1 --extra string com.mwr.example.sieve.PIN 1337 --bundle-as-obj
ブロードキャストレシーバー
Androidの基本情報セクションでは、ブロードキャストレシーバーとは何かを見ることができます。
このブロードキャストレシーバーを発見した後は、コードを確認する必要があります。特に**onReceive
**関数に注意を払い、受信したメッセージを処理します。
すべての ブロードキャストレシーバーを検出する
run app.broadcast.info #Detects all
アプリのブロードキャストレシーバーを確認する
#Check one negative
run app.broadcast.info -a jakhar.aseem.diva
Package: jakhar.aseem.diva
No matching receivers.
# Check one positive
run app.broadcast.info -a com.google.android.youtube
Package: com.google.android.youtube
com.google.android.libraries.youtube.player.PlayerUiModule$LegacyMediaButtonIntentReceiver
Permission: null
com.google.android.apps.youtube.app.common.notification.GcmBroadcastReceiver
Permission: com.google.android.c2dm.permission.SEND
com.google.android.apps.youtube.app.PackageReplacedReceiver
Permission: null
com.google.android.libraries.youtube.account.AccountsChangedReceiver
Permission: null
com.google.android.apps.youtube.app.application.system.LocaleUpdatedReceiver
Permission: null
ブロードキャスト インタラクション
app.broadcast.info Get information about broadcast receivers
app.broadcast.send Send broadcast using an intent
app.broadcast.sniff Register a broadcast receiver that can sniff particular intents
メッセージを送信
この例では、FourGoats apk のコンテンツプロバイダーを悪用して、ユーザーに許可を求めることなく、任意のSMSを非プレミアムの宛先に送信できます。
コードを読むと、パラメータ "phoneNumber" と "message" をコンテンツプロバイダーに送信する必要があります。
run app.broadcast.send --action org.owasp.goatdroid.fourgoats.SOCIAL_SMS --component org.owasp.goatdroid.fourgoats.broadcastreceivers SendSMSNowReceiver --extra string phoneNumber 123456789 --extra string message "Hello mate!"
Is debuggeable
生産用APKは決してデバッグ可能であってはなりません。
これは、Javaデバッガを実行中のアプリケーションにアタッチし、実行時に検査し、ブレークポイントを設定し、ステップバイステップで進み、変数の値を収集し、さらにはそれらを変更することができることを意味します。InfoSec institute has an excellent article on digging deeper when you application is debuggable and injecting runtime code.
アプリケーションがデバッグ可能な場合、マニフェストに表示されます:
<application theme="@2131296387" debuggable="true"
すべてのデバッグ可能なアプリケーションはDrozerで見つけることができます:
run app.package.debuggable
チュートリアル
- https://resources.infosecinstitute.com/android-penetration-tools-walkthrough-series-drozer/#gref
- https://github.com/mgcfish/mobiletools/blob/master/_posts/2016-08-01-Using-Drozer-for-application-security-assessments.md
- https://www.hackingarticles.in/android-penetration-testing-drozer/
- https://medium.com/@ashrafrizvi3006/how-to-test-android-application-security-using-drozer-edc002c5dcac
さらに詳しい情報
{{#include ../../../banners/hacktricks-training.md}}