Android 第三方app https 抓包

工具选择

Charles 或 Fiddler 都可以

在PC上安装工具并进行设置

Charles
Fiddler

设置按官网说明设置一下好。
Charles设置
Fiddler设置

Android Api Level >= 24 SSL特殊设置

当Android 的 Api Level > 24时需要修改一下app的一起配置

1.在项目中添加 Android/src/main/res/xml/network_security_config.xml

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
        <trust-anchors>
        <!-- Trust preinstalled CAs -->
        <certificates src="system" />
        <!-- HERE: Additionally trus user-added CAs -->
        <certificates src="user"/>
    </trust-anchors>
    </base-config>
</network-security-config>

2.在AndroidManifest.xml中的application中添加networkSecurityConfig属性

xml 复制代码
android:networkSecurityConfig="@xml/network_security_config"

结果如下:

xml 复制代码
<application
    android:name="com.tns.NativeScriptApplication"
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:networkSecurityConfig="@xml/network_security_config">
    ...

问题

我是想要查看别人的apk包,要怎么添加上面提到的配置呢?

方案

1. apktool 解包
shell 复制代码
apktool d xxx.apk -o xxx_folder
2. 修改及添加相关xml配置
3. apktool 打包
shell 复制代码
apktool b xxx_folder -o xxx_tmp.apk
4. 使用zipalign将apk包4字节对齐
shell 复制代码
zipalign -p -f -v 4 xxx_tmp.apk xxx_final.apk
5. 签名

不签名的apk是无法安装的, 使用自己的key签名

shell 复制代码
apksigner sign --ks <your_keystore> --ks-key-alias <your_key_alias> --out xxx_final_sign.apk xxx_final.apk

xxx_final_sign.apk 即为修改后的最终文件。

相关推荐
马 孔 多 在下雨8 小时前
安卓旋转屏幕后如何防止数据丢失-ViewModel入门
android
Just_Paranoid13 小时前
【Settings】恢复出厂设置密码校验
android·python·settings·sha256·hmac-sha256
拷贝码农卡卡东15 小时前
pre-commit run --all-files 报错:http.client.RemoteDisconnected
网络·网络协议·http
DoWhatUWant16 小时前
域格YM310 X09移芯CAT1模组HTTPS连接服务器
服务器·网络协议·https
肥肥呀呀呀16 小时前
flutter配置Android gradle kts 8.0 的打包名称
android·flutter
平生不喜凡桃李18 小时前
C++ 异常
android·java·c++
言之。19 小时前
TCP 拥塞控制设计空间课程要点总结
网络·网络协议·tcp/ip
Propeller20 小时前
【Android】View 交互的事件处理机制
android·java
吴Wu涛涛涛涛涛Tao20 小时前
Flutter 实现「可拖拽评论面板 + 回复输入框 + @高亮」的完整方案
android·flutter·ios