Android Studio高版本安卓模拟器抓取https包

Android Studio avd 设置

证书生成

复制代码
*.cer格式证书

​ openssl x509 -inform DER -subject\_hash\_old -in charles-ssl-proxying-certificate.cer

​ *.pem格式证书

​ openssl x509 -inform PEM -subject\_hash\_old -in charles-ssl-proxying-certificate.pem

会输出 `2cb30a9e`   ,证书修改成 `2cb30a9e`.0系统证书

adb push 2cb30a9e.0 /sdcard/
或者
adb push 2cb30a9e.0 /data/local/tmp/

证书脚本

charles.sh

shell 复制代码
set -e # Fail on error
mkdir -m 700 /data/local/tmp/htk-ca-copy
# Copy out the existing certificates
cp /system/etc/security/cacerts/* /data/local/tmp/htk-ca-copy/
# Create the in-memory mount on top of the system certs folder
mount -t tmpfs tmpfs /system/etc/security/cacerts
# Copy the existing certs back into the tmpfs mount, so we keep trusting them
mv /data/local/tmp/htk-ca-copy/* /system/etc/security/cacerts/
# Copy our new cert in, so we trust that too
cp /data/local/tmp/2cb30a9e.0 /system/etc/security/cacerts/
# Update the perms & selinux context labels, so everything is as readable as before
chown root:root /system/etc/security/cacerts/*
chmod 644 /system/etc/security/cacerts/*
chcon u:object_r:system_file:s0 /system/etc/security/cacerts/*
# Delete the temp cert directory & this script itself
rm -r /data/local/tmp/htk-ca-copy
# rm ${injectionScriptPath}
echo "System cert successfully injected"

推送到模拟器和执行

sh 复制代码
# 推送到服务器 
adb push charles.sh /data/local/tmp/
# 给权限
adb shell chmod +x /data/local/tmp/charles.sh
#本地执行
adb shell sh /data/local/tmp/charles.sh
#模拟器执行
xz:~ $ adb shell
emulator_arm64:/ $ su
emulator_arm64:/ # cd /data/local/tmp/
emulator_arm64:/data/local/tmp # ./charles.sh
System cert successfully injected

执行完成后可以在手机系统信任证书里面查看到,必须是在系统里面这一栏,用户这一栏高版本安卓系统的证书已经抓取不到https了

相关推荐
flower_drop9 小时前
基于 WebUSB 与 CDP:在浏览器端实现 Android 设备通信与无证书抓包实践
android·chrome·测试工具·adb·bug·edge浏览器
撩得Android一次心动11 小时前
Jetpack Compose 知识点整理1【个人用】
android·学习·kotlin·android jetpack·compose
ForteScarlet12 小时前
Kotlin 2.4.20 现已发布,新特性多不多?
android·java·开发语言·开源·kotlin·jetbrains
方白羽13 小时前
Android Studio 自动国际化插件:SmartI18n
android·android studio·intellij idea
码农coding16 小时前
android12 状态栏图标的加载流程
android
hai_android17 小时前
Kotlin 协程作用域源码剖析
android·kotlin
Yeyu17 小时前
Android 画中画(PiP)小窗播放:怎么做、以及它到底是怎么工作的
android
千里马学框架17 小时前
安卓系统性能优化高级实战开发专题--开机,app冷启动优化
android·智能手机·性能优化·framework·性能·开机优化·app冷启动优化
律宏阔18 小时前
Android 手机通过 adblib 使用 ADB Wi-Fi 控制 Android 9 开发板
android
律宏阔18 小时前
Android App 里实现开机动画替换
android