mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/mobile-pentesting/android-app-pentesting/frida-tutorial
This commit is contained in:
parent
b86a67f872
commit
579de93d29
@ -12,7 +12,7 @@
|
||||
|
||||
[https://joshspicer.com/android-frida-1](https://joshspicer.com/android-frida-1)に基づく
|
||||
|
||||
**\_exit()**\_ 関数をフックし、**decrypt function**を使用して、verifyを押したときにフリダコンソールにフラグを表示させます:
|
||||
**_exit()**_ 関数をフックし、**decrypt function**を使用して、verifyを押したときにフリダコンソールにフラグを表示させます:
|
||||
```javascript
|
||||
Java.perform(function () {
|
||||
send("Starting hooks OWASP uncrackable1...")
|
||||
@ -51,11 +51,11 @@ send("java.lang.System.exit(I)V // We avoid exiting the application :)")
|
||||
send("Hooks installed.")
|
||||
})
|
||||
```
|
||||
## ソリューション 2
|
||||
## Solution 2
|
||||
|
||||
Based in [https://joshspicer.com/android-frida-1](https://joshspicer.com/android-frida-1)
|
||||
|
||||
**Hook rootchecks** と decrypt function を使用して、verify を押したときにフリダコンソールにフラグを表示させます:
|
||||
**ルートチェックをフック**し、関数を復号化して、verifyを押したときにフリダコンソールにフラグを表示します:
|
||||
```javascript
|
||||
Java.perform(function () {
|
||||
send("Starting hooks OWASP uncrackable1...")
|
||||
@ -115,4 +115,54 @@ return false
|
||||
send("Hooks installed.")
|
||||
})
|
||||
```
|
||||
---
|
||||
|
||||
## Solution 3 – `frida-trace` (Frida ≥ 16)
|
||||
|
||||
手動でフックを書くのが嫌な場合は、**Frida** にJavaスタブを生成させてから編集することができます:
|
||||
```bash
|
||||
# Spawn the application and automatically trace the Java method we care about
|
||||
aadb shell "am force-stop owasp.mstg.uncrackable1"
|
||||
frida-trace -U -f owasp.mstg.uncrackable1 \
|
||||
-j 'sg.vantagepoint.a.a.a("[B","[B")[B' \
|
||||
-j 'sg.vantagepoint.a.c!*' \
|
||||
--output ./trace
|
||||
|
||||
# The first run will create ./trace/scripts/sg/vantagepoint/a/a/a__B_B_B.js
|
||||
# Edit that file and add the logic that prints the decrypted flag or
|
||||
# returns a constant for the root-checks, then:
|
||||
frida -U -f owasp.mstg.uncrackable1 -l ./trace/_loader.js --no-pause
|
||||
```
|
||||
Frida 16+では、生成されたスタブはすでに最新の**ES6**テンプレート構文を使用しており、組み込みの*QuickJS*ランタイムでコンパイルされます。もはや`frida-compile`は必要ありません。
|
||||
|
||||
---
|
||||
|
||||
## Solution 4 – One-liner with Objection (2024)
|
||||
|
||||
**Objection >1.12**がインストールされている場合、単一のコマンドでフラグをダンプできます(Objectionは内部でFridaをラップしています):
|
||||
```bash
|
||||
objection -g owasp.mstg.uncrackable1 explore \
|
||||
--startup-command "android hooking watch class sg.vantagepoint.a.a method a \n && android hooking set return_value false sg.vantagepoint.a.c * \n && android hooking invoke sg.vantagepoint.a.a a '[B' '[B'"
|
||||
```
|
||||
* `watch class` は AES ルーチンによって返されるプレーンテキストを表示します
|
||||
* `set return_value false` はすべての root / デバッガーチェックが *false* を報告するように強制します
|
||||
* `invoke` は **Verify** を押さずにメソッドを直接呼び出すことを可能にします。
|
||||
|
||||
> NOTE: Android 14 (API 34) では、*attach* が **seccomp-bpf** 制限によりブロックされるため、Objection/Frida を *spawn* モード (`-f`) で実行する必要があります。
|
||||
|
||||
---
|
||||
|
||||
## モダン Android ノート (2023 - 2025)
|
||||
|
||||
* **libsu 5.x** と **Zygisk** は *su* をかなりうまく隠しますが、Level 1 の Java ベースのチェックは `/system/bin/su` ファイルが存在する場合に失敗します。**denylist** を有効にするか、単に `java.io.File.exists()` を Frida でフックしてください。
|
||||
* Frida 16.1 は Google の *Scudo* アロケータによって引き起こされた **Android 12/13** のクラッシュを修正しました。`Abort message: 'missing SHADOW_OFFSET'` が表示された場合は、Frida をアップグレードするか、事前ビルドされた 17.0 ナイトリーを使用してください。
|
||||
* Play Integrity が 2023 年に SafetyNet に取って代わったため、一部の新しいアプリは **com.google.android.gms.tasks.Task** API を呼び出します。Level 1 は呼び出しませんが、ここで示されているのと同じフック戦略が機能します – `com.google.android.gms.safetynet.SafetyNetClient` をフックし、偽の *EvaluationType* を返します。
|
||||
|
||||
## 参考文献
|
||||
|
||||
* Frida リリースアナウンス – "Frida 16.0 (2023-04-02): Android 12/13 の信頼性修正 & spawn API のオーバーホール"
|
||||
* Objection 1.12 – "Android 14 用の spawn-only モード" (BlackHat USA 2024 トークスライド)
|
||||
|
||||
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user