Objection チュートリアル

Reading time: 11 minutes

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

はじめに

objection - ランタイムモバイル探索

ObjectionFrida によって駆動されるランタイムモバイル探索ツールキットです。これは、jailbroken or rooted mobile device を必要とせずに、モバイルアプリケーションとそのセキュリティ体制を評価するのを支援することを目的として構築されました。

注: これは jailbreak / root bypass のようなものではありません。objection を使用する場合でも、直面している sandbox によって課されるすべての制限を受けます。

概要

objection目的 は、ユーザーが Frida が提供する主要なアクション を呼び出せるようにすることです。そうしないと、ユーザーはテストしたい各アプリケーションごとに single script を作成する必要があります。

チュートリアル

このチュートリアルでは、ここからダウンロードできる APK を使用します:

またはその original repository (download app-release.apk) から入手できます。

インストール

bash
pip3 install objection

接続

デバイスでregular ADB conectionを行い、fridaサーバーをstartしてください(クライアントとサーバーの両方でfridaが動作していることを確認してください)。

もしrooted deviceを使用している場合、--gadget オプションでテストしたいアプリケーションを選択する必要があります。この場合:

bash
frida-ps -Uai
objection --gadget asvid.github.io.fridaapp explore

基本操作

このチュートリアルでは、objections のすべてのコマンドを列挙するわけではなく、私がより有用だと感じたものだけを紹介します。

環境

環境内には、(例えば passwords や paths のような) 興味深い情報が見つかることがあります。

bash
env

Frida の情報

bash
frida

アップロード/ダウンロード

bash
file download <remote path> [<local path>]
file upload <local path> [<remote path>]

frida スクリプトのインポート

bash
import <local path frida-script>

SSLPinning

bash
android sslpinning disable #Attempts to disable SSL Pinning on Android devices.

Root検出

bash
android root disable  #Attempts to disable root detection on Android devices.
android root simulate #Attempts to simulate a rooted Android environment.

Exec コマンド

bash
android shell_exec whoami

スクリーンショット

bash
android ui screenshot /tmp/screenshot
android ui FLAG_SECURE false  #This may enable you to take screenshots using the hardware keys

Static analysis made Dynamic

実際のアプリでは、objection を使用する前に、このパートで見つかったすべての情報を static analysis によって把握しておくべきです。とはいえ、この方法ではクラス、メソッド、エクスポートされたオブジェクトの完全な一覧しか得られないため、ここで 何か新しいもの を発見できるかもしれません。

また、何らかの理由でアプリの 可読なソースコードを取得できない 場合にも有用です。

List activities, receivers and services

bash
android hooking list activities

bash
android hooking list services
android hooking list receivers

Frida は見つからない場合、エラーを発生させます。

現在の activity を取得する

bash
android hooking get current_activity

クラスを検索

アプリケーション内のクラスを探し始めましょう。

bash
android hooking search classes asvid.github.io.fridaapp

クラスのメソッドを検索

では、クラス MainActivity 内のメソッドを抽出します:

bash
android hooking search methods asvid.github.io.fridaapp MainActivity

クラスに宣言されたメソッドを、そのパラメータとともに一覧表示

クラスのメソッドがどのパラメータを必要とするかを確認しましょう:

bash
android hooking list class_methods asvid.github.io.fridaapp.MainActivity

クラスの一覧

現在のアプリケーション内にロードされたすべてのクラスを一覧表示することもできます:

bash
android hooking list classes #List all loaded classes, As the target application gets usedmore, this command will return more classes.

これは、class の名前しか分からない場合にその class の method を hook したいときに非常に便利です。
この関数を使って、どの module がその class を所有しているかを検索し、その後その method を hook できます。

Hooking は簡単

Hooking(method の監視)

From the source code of the application we know that the function sum() from MainActivity is being run every second関数が呼ばれるたびに(arguments、return value、backtrace)可能な限りの情報を dumpしてみましょう:

bash
android hooking watch class_method asvid.github.io.fridaapp.MainActivity.sum --dump-args --dump-backtrace --dump-return

Hooking (クラス全体を監視)

実は MainActivity クラスの全てのメソッドが非常に興味深いので、すべてを hook してみましょう。注意:これによりアプリケーションが クラッシュ する可能性があります。

bash
android hooking watch class asvid.github.io.fridaapp.MainActivity --dump-args --dump-return

If you play with the application while the class is hooked you will see when each function is being called, its arguments and the return value.

関数の boolean 戻り値を変更する

ソースコードから、関数 checkPinString を引数に取り、boolean を返すことがわかります。関数が 常に true を返す ようにしましょう:

今、PIN コード用のテキストボックスに何でも入力すると、何でも有効であることが確認できます:

クラスのインスタンス

完全修飾クラス名で指定された特定の Java クラスの ライブインスタンスを検索して表示 します。Out は、発見された objection の文字列値を取得しようとした結果で、通常はオブジェクトのプロパティ値を 含みます

android heap print_instances <class>

Keystore/Intents

keystore と intents は次のコマンドで操作できます:

bash
android keystore list
android intents launch_activity
android intent launch_service

メモリ

ダンプ

bash
memory dump all <local destination> #Dump all memory
memory dump from_base <base_address> <size_to_dump> <local_destination> #Dump a part

リスト

bash
memory list modules

リストの下部に frida が表示されています:

frida がエクスポートしているものを確認してみましょう:

検索/書き込み

objection を使ってメモリ内を検索・書き込みすることもできます:

bash
memory search "<pattern eg: 41 41 41 ?? 41>" (--string) (--offsets-only)
memory write "<address>" "<pattern eg: 41 41 41 41>" (--string)

SQLite

コマンド sqlite を使って sqlite データベースと対話できます。

Exit

終了

bash
exit

Objectionで物足りない点

  • hooking methods は時々アプリをクラッシュさせる(これは Frida によるものでもある)。
  • クラスの instances を使ってそのインスタンスの functions を呼び出すことができない。また、クラスの新しい instances を作成してそれらで functions を呼び出すこともできない。
  • アプリで使われている一般的な crypto methods をすべて hook して、cyphered text、plain text、keys、IVs、使用されている algorithms を確認するためのショートカット(sslpinnin のようなもの)がない。

参考資料

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする