Bypass Biometric Authentication (Android)

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

方法1 – 暗号オブジェクトの使用なしでのバイパス

ここでは、認証プロセスで重要なonAuthenticationSucceededコールバックに焦点を当てます。WithSecureの研究者たちは、*onAuthenticationSucceeded(...)*でのNULL CryptoObjectのバイパスを可能にするFridaスクリプトを開発しました。このスクリプトは、メソッドの呼び出し時に指紋認証を自動的にバイパスします。以下は、Androidの指紋コンテキストでバイパスを示す簡略化されたスニペットであり、完全なアプリケーションはGitHubで入手できます。

biometricPrompt = new BiometricPrompt(this, executor, new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
Toast.makeText(MainActivity.this,"Success",Toast.LENGTH_LONG).show();
}
});
frida -U -f <package_name> -l <script_name.js> --no-pause
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass.js

方法2 – 例外処理アプローチ

別のFridaスクリプトは、セキュリティの脆弱な暗号オブジェクトの使用をバイパスする方法について述べています。このスクリプトは、指紋によって認証されていないCryptoObjectを使用してonAuthenticationSucceededを呼び出します。アプリケーションが異なる暗号オブジェクトを使用しようとすると、例外が発生します。このスクリプトは、onAuthenticationSucceededを呼び出す準備をし、_Cipher_クラスでjavax.crypto.IllegalBlockSizeExceptionを処理し、アプリケーションによって使用される後続のオブジェクトが新しいキーで暗号化されるようにします。

Fridaスクリプトを実行するコマンド:

frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass-via-exception-handling.js

以下は、Fridaコンソールでbypass()を入力してバイパスをアクティブ化するために、指紋認証画面に到達しauthenticate()を開始した後の手順です:

Spawning com.generic.insecurebankingfingerprint...
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> Hooking BiometricPrompt.authenticate()...
Hooking BiometricPrompt.authenticate2()...
Hooking FingerprintManager.authenticate()...
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> bypass()

方法3 – Instrumentation Frameworks

Instrumentation frameworks like Xposed or Frida can be used to hook into application methods at runtime. For fingerprint authentication, these frameworks can:

  1. Mock the Authentication Callbacks: By hooking into the onAuthenticationSucceeded, onAuthenticationFailed, or onAuthenticationError methods of the BiometricPrompt.AuthenticationCallback, you can control the outcome of the fingerprint authentication process.

  2. Bypass SSL Pinning: This allows an attacker to intercept and modify the traffic between the client and the server, potentially altering the authentication process or stealing sensitive data.

Example command for Frida:

frida -U -l script-to-bypass-authentication.js --no-pause -f com.generic.in

方法4 – 逆コンパイルとコードの変更

APKTooldex2jarJD-GUIなどの逆コンパイルツールを使用して、Androidアプリケーションを逆コンパイルし、ソースコードを読み取り、認証メカニズムを理解することができます。一般的な手順は次のとおりです:

  1. APKの逆コンパイル: APKファイルをより人間が読みやすい形式(例:Javaコード)に変換します。

  2. コードの分析: 指紋認証の実装を探し、フォールバックメカニズムや適切でない検証チェックなどの潜在的な弱点を特定します。

  3. APKの再コンパイル: 指紋認証をバイパスするためにコードを変更した後、アプリケーションを再コンパイルし、署名してデバイスにインストールしてテストします。

方法5 – カスタム認証ツールの使用

認証メカニズムをテストおよびバイパスするために設計された専門ツールやスクリプトがあります。例えば:

  1. MAGISKモジュール: MAGISKはAndroid用のツールで、ユーザーがデバイスをルート化し、指紋などのハードウェアレベルの情報を変更またはスプーフィングするモジュールを追加できます。

  2. カスタムスクリプト: スクリプトを作成して、Android Debug Bridge(ADB)やアプリケーションのバックエンドと直接やり取りし、指紋認証をシミュレートしたりバイパスしたりすることができます。

参考文献

Last updated