iOS Hooking With Objection

AWSハッキングをゼロからヒーローまで学ぶ htARTE(HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

このセクションでは、Objectionというツールを使用します。 次のような操作を実行して、Objectionのセッションを取得してください。

objection -d --gadget "iGoat-Swift" explore
objection -d --gadget "OWASP.iGoat-Swift" explore
スマートフォンの実行プロセスを確認するには、`frida-ps -Uia`を実行できます。

## アプリの基本列挙

### ローカルアプリパス

* `env`: デバイス内のアプリケーションが格納されているパスを見つける

```bash
env

Name               Path
-----------------  -----------------------------------------------------------------------------------------------
BundlePath         /private/var/containers/Bundle/Application/179A6E8B-E7A8-476E-BBE3-B9300F546068/iGoat-Swift.app
CachesDirectory    /var/mobile/Containers/Data/Application/A079DF84-726C-4AEA-A194-805B97B3684A/Library/Caches
DocumentDirectory  /var/mobile/Containers/Data/Application/A079DF84-726C-4AEA-A194-805B97B3684A/Documents
LibraryDirectory   /var/mobile/Containers/Data/Application/A079DF84-726C-4AEA-A194-805B97B3684A/Library

バンドル、フレームワーク、ライブラリの一覧

  • ios bundles list_bundles: アプリケーションのバンドルを一覧表示

ios bundles list_bundles
Executable    Bundle                Version    Path
------------  --------------------  ---------  -------------------------------------------
iGoat-Swift   OWASP.iGoat-Swift     1.0        ...8-476E-BBE3-B9300F546068/iGoat-Swift.app
AGXMetalA9    com.apple.AGXMetalA9  172.18.4   ...tem/Library/Extensions/AGXMetalA9.bundle
  • ios bundles list_frameworks: アプリケーションで使用されている外部フレームワークを一覧表示

ios bundles list_frameworks
Executable                      Bundle                                        Version     Path
------------------------------  --------------------------------------------  ----------  -------------------------------------------
ReactCommon                     org.cocoapods.ReactCommon                     0.61.5      ...tle.app/Frameworks/ReactCommon.framework
...
  • memory list modules: メモリにロードされたモジュールを一覧表示

memory list modules
Name                                 Base         Size                 Path
-----------------------------------  -----------  -------------------  ------------------------------------------------------------------------------
iGoat-Swift                          0x104ffc000  2326528 (2.2 MiB)    /private/var/containers/Bundle/Application/179A6E8B-E7A8-476E-BBE3-B9300F54...
SubstrateBootstrap.dylib             0x105354000  16384 (16.0 KiB)     /usr/lib/substrate/SubstrateBootstrap.dylib
...
  • memory list exports <module_name>: ロードされたモジュールのエクスポートを表示

memory list exports iGoat-Swift
Type      Name                                                                                                                                    Address
--------  --------------------------------------------------------------------------------------------------------------------------------------  -----------
variable  _mh_execute_header                                                                                                                      0x104ffc000
function  _mdictof                                                                                                                                0x10516cb88
...

アプリのクラスの一覧

  • ios hooking list classes: アプリのクラスを一覧表示

ios hooking list classes

AAAbsintheContext
AAAbsintheSigner
...
  • ios hooking search classes <search_term>: 文字列を含むクラスを検索。メインアプリパッケージ名に関連する一意の用語を検索して、アプリの主要なクラスを見つけることができます。

ios hooking search classes iGoat
iGoat_Swift.CoreDataHelper
iGoat_Swift.RCreditInfo
...

クラスのメソッドの一覧

  • ios hooking list class_methods: 特定のクラスのメソッドを一覧表示

ios hooking list class_methods iGoat_Swift.RCreditInfo
- cvv
- setCvv:
- setName:
...
  • ios hooking search methods <search_term>: 文字列を含むメソッドを検索

ios hooking search methods cvv
...

基本的なフック

アプリケーションで使用されているクラスやモジュールを列挙したので、興味深いクラスやメソッド名を見つけることができました。

クラスのすべてのメソッドをフック

  • ios hooking watch class <class_name>: クラスのすべてのメソッドをフックし、呼び出されるたびに初期パラメータと戻り値をすべてダンプします

ios hooking watch class iGoat_Swift.PlistStorageExerciseViewController

単一のメソッドをフック

  • ios hooking watch method "-[<class_name> <method_name>]" --dump-args --dump-return --dump-backtrace: 特定のクラスの特定のメソッドをフックし、呼び出されるたびにパラメータ、バックトレース、戻り値をダンプします

ios hooking watch method "-[iGoat_Swift.BinaryCookiesExerciseVC verifyItemPressed]" --dump-args --dump-backtrace --dump-return

ブール値の返り値を変更

  • ios hooking set return_value "-[<class_name> <method_name>]" false: 選択したメソッドが指定されたブール値を返すようにします

ios hooking set return_value "-[iGoat_Swift.BinaryCookiesExerciseVC verifyItemPressed]" false

フックテンプレートの生成

  • ios hooking generate simple <class_name>:

ios hooking generate simple iGoat_Swift.RCreditInfo

var target = ObjC.classes.iGoat_Swift.RCreditInfo;

Interceptor.attach(target['+ sharedSchema'].implementation, {
onEnter: function (args) {
console.log('Entering + sharedSchema!');
},
onLeave: function (retval) {
console.log('Leaving + sharedSchema');
},
});

...

Last updated