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

47 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{#include ../../banners/hacktricks-training.md}}
有些应用程序不喜欢用户下载的证书,因此为了检查某些应用的网络流量,我们实际上需要反编译应用程序,添加一些内容并重新编译它。
# 自动
工具 [**https://github.com/shroudedcode/apk-mitm**](https://github.com/shroudedcode/apk-mitm) 将 **自动** 对应用程序进行必要的更改,以开始捕获请求,并且还会禁用证书固定(如果有的话)。
# 手动
首先我们反编译应用: `apktool d *file-name*.apk`
![](../../images/img9.png)
然后我们进入 **Manifest.xml** 文件,向下滚动到 `<\application android>` 标签,如果没有以下行,我们将添加它:
`android:networkSecurityConfig="@xml/network_security_config"`
添加前:
![](../../images/img10.png)
添加后:
![](../../images/img11.png)
现在进入 **res/xml** 文件夹,创建/修改一个名为 network_security_config.xml 的文件,内容如下:
```html
<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>
```
然后保存文件退出所有目录并使用以下命令重建apk `apktool b *folder-name/* -o *output-file.apk*`
![](../../images/img12.png)
最后,您只需**签署新应用程序**。 [阅读此页面的此部分 Smali - Decompiling/\[Modifying\]/Compiling 以了解如何签署它](smali-changes.md#sing-the-new-apk)。
{{#include ../../banners/hacktricks-training.md}}