hacktricks/mobile-pentesting/android-app-pentesting/bypass-biometric-authentication-android.md

92 lines
7 KiB
Markdown
Raw Normal View History

# Bypass Biometric Authentication (Android)
2022-10-26 09:06:33 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2024-02-08 04:06:37 +01:00
2022-10-26 09:06:33 +00:00
<details>
<summary>Support HackTricks</summary>
2022-10-26 09:06:33 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-10-26 09:06:33 +00:00
</details>
{% endhint %}
2022-10-26 09:06:33 +00:00
## **Metode 1 Omseiling sonder Crypto Object Gebruik**
2022-10-26 09:06:33 +00:00
Die fokus hier is op die *onAuthenticationSucceeded* terugroep, wat van kardinale belang is in die verifikasieproses. Navorsers by WithSecure het 'n [Frida script](https://github.com/WithSecureLABS/android-keystore-audit/blob/master/frida-scripts/fingerprint-bypass.js) ontwikkel, wat die omseiling van die NULL *CryptoObject* in *onAuthenticationSucceeded(...)* moontlik maak. Die script dwing 'n outomatiese omseiling van die vingerafdrukverifikasie by die metode se aanroep. Hieronder is 'n vereenvoudigde snit wat die omseiling in 'n Android Vingerafdruk konteks demonstreer, met die volle toepassing beskikbaar op [GitHub](https://github.com/St3v3nsS/InsecureBanking).
2022-10-26 09:06:33 +00:00
```javascript
biometricPrompt = new BiometricPrompt(this, executor, new BiometricPrompt.AuthenticationCallback() {
2024-02-11 02:07:06 +00:00
@Override
public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) {
Toast.makeText(MainActivity.this,"Success",Toast.LENGTH_LONG).show();
}
2022-10-26 09:06:33 +00:00
});
```
Opdrag om die Frida-skrip te loop:
2024-02-03 15:45:32 +01:00
```bash
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass.js
2022-10-26 09:06:33 +00:00
```
## **Metode 2 Uitsondering Hantering Benadering**
2022-10-26 09:06:33 +00:00
Nog 'n [Frida script](https://github.com/WithSecureLABS/android-keystore-audit/blob/master/frida-scripts/fingerprint-bypass-via-exception-handling.js) deur WithSecure spreek die omseiling van onveilige kripto objek gebruik aan. Die script roep *onAuthenticationSucceeded* aan met 'n *CryptoObject* wat nie deur 'n vingerafdruk geverifieer is nie. As die aansoek probeer om 'n ander cipher objek te gebruik, sal dit 'n uitsondering ontlok. Die script berei voor om *onAuthenticationSucceeded* aan te roep en die *javax.crypto.IllegalBlockSizeException* in die _Cipher_ klas te hanteer, wat verseker dat daaropvolgende objek wat deur die aansoek gebruik word, met die nuwe sleutel geënkripteer is.
2022-10-26 09:06:33 +00:00
Opdrag om die Frida script te loop:
2024-02-03 15:45:32 +01:00
```bash
frida -U -f com.generic.insecurebankingfingerprint --no-pause -l fingerprint-bypass-via-exception-handling.js
2022-10-26 09:06:33 +00:00
```
Upon reaching the fingerprint screen and the initiation of `authenticate()`, type `bypass()`` in the Frida console to activate the bypass:
2022-10-26 09:06:33 +00:00
```
2024-02-03 15:45:32 +01:00
Spawning com.generic.insecurebankingfingerprint...
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> Hooking BiometricPrompt.authenticate()...
2022-10-26 09:06:33 +00:00
Hooking BiometricPrompt.authenticate2()...
Hooking FingerprintManager.authenticate()...
2024-02-03 15:45:32 +01:00
[Android Emulator 5554::com.generic.insecurebankingfingerprint]-> bypass()
2022-10-26 09:06:33 +00:00
```
## **Metode 3 Instrumentasie Raamwerke**
2022-10-26 09:06:33 +00:00
Instrumentasie raamwerke soos Xposed of Frida kan gebruik word om in toepassingsmetodes tydens uitvoering in te haak. Vir vingerafdrukverifikasie kan hierdie raamwerke:
2024-02-03 15:45:32 +01:00
1. **Mok die Verifikasie Terugroepe**: Deur in die `onAuthenticationSucceeded`, `onAuthenticationFailed`, of `onAuthenticationError` metodes van die `BiometricPrompt.AuthenticationCallback` in te haak, kan jy die uitkoms van die vingerafdrukverifikasieproses beheer.
2. **Omseil SSL Pinning**: Dit laat 'n aanvaller toe om die verkeer tussen die kliënt en die bediener te onderskep en te wysig, wat moontlik die verifikasieproses kan verander of sensitiewe data kan steel.
2024-02-03 15:45:32 +01:00
2024-02-11 02:07:06 +00:00
Voorbeeldopdrag vir Frida:
2024-02-03 15:45:32 +01:00
```bash
frida -U -l script-to-bypass-authentication.js --no-pause -f com.generic.in
```
## **Metode 4 Omgekeerde Ingenieurswese & Kodewysiging**
2024-02-03 15:45:32 +01:00
Omgekeerde ingenieurswese gereedskap soos `APKTool`, `dex2jar`, en `JD-GUI` kan gebruik word om 'n Android-toepassing te dekompileer, sy bronnkode te lees, en sy outentikasie-meganisme te verstaan. Die stappe sluit gewoonlik in:
2024-02-03 15:45:32 +01:00
1. **Dekomplilering van die APK**: Converteer die APK-lêer na 'n meer menslike leesbare formaat (soos Java-kode).
2. **Analiseer die Kode**: Soek na die implementering van vingerafdrukoutentikasie en identifiseer potensiële swakpunte (soos terugvalmeganismes of onvanpaste valideringskontroles).
3. **Hersamestelling van die APK**: Nadat die kode gewysig is om vingerafdrukoutentikasie te omseil, word die toepassing hersamestel, onderteken, en op die toestel geïnstalleer vir toetsing.
2024-02-03 15:45:32 +01:00
## **Metode 5 Gebruik van Pasgemaakte Outentikasiegereedskap**
2024-02-03 15:45:32 +01:00
Daar is gespesialiseerde gereedskap en skripte ontwerp om outentikasie-meganismes te toets en te omseil. Byvoorbeeld:
2024-02-03 15:45:32 +01:00
1. **MAGISK Modules**: MAGISK is 'n gereedskap vir Android wat gebruikers toelaat om hul toestelle te root en modules by te voeg wat hardewarevlak-inligting kan wysig of spoof, insluitend vingerafdrukke.
2. **Pasgemaakte Skripte**: Skripte kan geskryf word om met die Android Debug Bridge (ADB) of direk met die toepassing se agterkant te kommunikeer om vingerafdrukoutentikasie te simuleer of te omseil.
2024-02-03 15:45:32 +01:00
2024-02-11 02:07:06 +00:00
## Verwysings
2024-02-03 15:45:32 +01:00
* [https://securitycafe.ro/2022/09/05/mobile-pentesting-101-bypassing-biometric-authentication/](https://securitycafe.ro/2022/09/05/mobile-pentesting-101-bypassing-biometric-authentication/)
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-10-26 09:06:33 +00:00
<details>
<summary>Support HackTricks</summary>
2022-10-26 09:06:33 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-10-26 09:06:33 +00:00
</details>
{% endhint %}