hacktricks/mobile-pentesting/android-app-pentesting/make-apk-accept-ca-certificate.md

73 lines
3.9 KiB
Markdown
Raw Normal View History

{% 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)
<details>
<summary>Support HackTricks</summary>
* 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.
</details>
{% endhint %}
Alguns aplicativos não aceitam certificados baixados pelo usuário, então, para inspecionar o tráfego da web de alguns aplicativos, precisamos realmente descompilar o aplicativo, adicionar algumas coisas e recompilá-lo.
2022-04-28 16:01:33 +00:00
2023-06-06 18:56:34 +00:00
# Automático
2022-04-28 16:01:33 +00:00
A ferramenta [**https://github.com/shroudedcode/apk-mitm**](https://github.com/shroudedcode/apk-mitm) **automaticamente** fará as alterações necessárias no aplicativo para começar a capturar as requisições e também desativará o pinning de certificado (se houver).
2022-05-01 12:41:36 +00:00
# Manual
Primeiro, descompilamos o aplicativo: `apktool d *file-name*.apk`
![](../../.gitbook/assets/img9.png)
Em seguida, vamos ao arquivo **Manifest.xml** e rolamos até a tag `<\application android>` e vamos adicionar a seguinte linha, se ainda não estiver lá:
`android:networkSecurityConfig="@xml/network_security_config`
2023-06-06 18:56:34 +00:00
Antes de adicionar:
![](../../.gitbook/assets/img10.png)
2023-06-06 18:56:34 +00:00
Depois de adicionar:
![](../../.gitbook/assets/img11.png)
Agora vá para a pasta **res/xml** e crie/modifique um arquivo chamado network\_security\_config.xml com o seguinte conteúdo:
```markup
<network-security-config>
<base-config>
<trust-anchors>
<!-- Trust preinstalled CAs -->
<certificates src="system" />
<!-- Additionally trust user added CAs -->
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
```
Então salve o arquivo e saia de todos os diretórios e reconstrua o apk com o seguinte comando: `apktool b *folder-name/* -o *output-file.apk*`
![](../../.gitbook/assets/img12.png)
Finalmente, você só precisa **assinar a nova aplicação**. [Leia esta seção da página Smali - Decompiling/\[Modifying\]/Compiling para aprender como assiná-la](smali-changes.md#sing-the-new-apk).
{% 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)
<details>
<summary>Support HackTricks</summary>
* 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.
</details>
{% endhint %}