为 Burp Suite 抓包准备 Android 设备

妙哉。


适用于 Android 7 (Nougat) 及以上。
Android 7 以下可通过 root 设备安装系统级 CA 证书。

启动 Burp Suite 代理

将 Android 设备连接至 Burp Suite 代理

对于 Windows Subsystem for Android™️ (WSA) 可尝试如下命令行

adb shell settings put global http_proxy 127.0.0.1:8080

安装用户 CA 证书

打开 http://burp/,点击右上角 CA Certificate 下载证书并转到设置安装。

修改 APK 以支持用户 CA 证书

解包

下载 Apktool,以 a.apk 为例,执行:

java -jar apktool.jar d a.apk

改包

检查 AndroidManifest.xml 中是否已存在以下属性:

//file: AndroidManifest.xml
<application ... android:networkSecurityConfig="@xml/network_security_config" ...>

如果已存在,定位到 a/res/xml/,打开上述文件中指定的文件,否则,在 AndroidManifest.xml 中添加以上属性后在 a/res/xml 下新建 network_security_config.xml。
向上述已存在文件或新建文件中合并入以下内容:

<network-security-config>
    <base-config>
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
        </trust-anchors>
    </base-config>
</network-security-config>

重新打包

重新定位至 apk 目录,执行:

java -jar apktool.jar b a

异常处理

Invalid resource directory name …/res navigation 等
更改打包命令为:

java -jar apktool.jar b --use-aapt2 a

签名

生成证书

定位至 a/dist/ 执行:

keytool -genkeypair -alias key.keystore -keyalg RSA -validity 500000 -keystore key.keystore

签名

jarsigner -keystore key.keystore -signedjar signed.apk a.apk key.keystore

安装

adb install a/dist/signed.apk

异常处理

INSTALL_FAILED_INVALID_APK: INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2
更改 AndroidManifest.xml:

//file: AndroidManifest.xml
...
<application ... android:extractNativeLibs="true" ...>
</application>
...

重新打包、签名、安装。

参考

Configuring Burp Suite With Android Nougat - ropnop blog


文件历史

feat: splash image! b37c038
2025 年 3 月 3 日 11:28djdjz7
chore: continue migration 30e3bf6
2025 年 2 月 23 日 07:52djdjz7
chore: remove lcpu related code b5e18ec
2025 年 2 月 22 日 08:59djdjz7
fix: typo 85f70db
2023 年 11 月 28 日 13:37djdjz7
theme: layout update 9984f92
2023 年 11 月 11 日 13:20djdjz7
update 3e02699
2023 年 10 月 2 日 09:32djdjz7
refractoring cd66e4f
2023 年 10 月 2 日 05:51djdjz7
update 002e446
2023 年 9 月 30 日 03:11djdjz7
update 831d192
2023 年 9 月 30 日 02:59djdjz7
更新 2023-09-30-prep-android-for-burp.md 61dac59
2023 年 9 月 30 日 00:44Jason Dai
更新 2023-09-30-prep-android-for-burp.md 8f7f62c
2023 年 9 月 30 日 00:43Jason Dai
add post b3388bd
2023 年 9 月 29 日 23:46djdjz7
© 2023 - 2025
Unless otherwise stated, text contents are licensed under CC BY-NC 4.0, and codes are licensed under MIT.
Images may be subject to separate licenses, see the image captions for details if applicable.