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了

相关推荐
有毒的教程3 小时前
Dev-C++ 使用扩展库两种方式:DevPak一键安装 / 手动配置(重点)
android·c++·adb
Lsetea3 小时前
OpenSSL读取加密私钥报bad decrypt:passin与口令来源排查
linux·https·ssl证书·openssl·私钥
mmsx3 小时前
Android 测绘数值基础:测量单位系统与七四参数、高程拟合
android
郑州光合科技余经理3 小时前
出海外卖平台:支付对接为什么要和下单收款分开
android·java·开发语言·前端·后端·php·ai编程
夜雪一千3 小时前
MySQL 如何提高查询速度:从索引、SQL、表结构到实战调优
android·sql·mysql
终端安全笔记4 小时前
配置锁状态那一栏查的是什么:报告里几项各自指向什么风险
android·前端·安全·ios
恋猫de小郭4 小时前
Kotlin Toolchain 0.13,JetBrains 推荐 KMP 都切换到到全新工具链
android·前端·flutter
安卓机器4 小时前
rom定制系列------小米8 安卓16线刷原生固件 体验新版本
android·小米8安卓16
cyy2984 小时前
小米电视安装tts引擎
android·tv
小锋学长生活大爆炸5 小时前
【工具】在 Android 手机上运行 Docker
android·docker·智能手机