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了

相关推荐
solo_995 小时前
Android Event 日志完全指南
android
孙晓鹏life5 小时前
MySQL-Seconds_behind_master的精度误差
android·mysql·adb
雨白5 小时前
C 语言文件操作核心
android
鱼儿也有烦恼7 小时前
01.搭建Android Studio开发环境
android·android studio
m0_738120728 小时前
PHP代码审计基础——面向对象(四)
android·开发语言·网络·安全·github·php
Coffeeee9 小时前
搞Android的怎么可能搞不懂Context Engineering?
android·人工智能·ai编程
Carson带你学Android9 小时前
Gemini Nano 开发实战:让你的App轻松拥有端侧 AI 功能
android·ai编程
TDengine (老段)11 小时前
TDengine SMA 索引 — 块级/文件级统计索引
android·大数据·服务器·数据库·人工智能·时序数据库·tdengine
心中有国也有家11 小时前
AtomGit Flutter 鸿蒙客户端: AnimatedScale 与 AnimatedContainer 联合实战
android·javascript·flutter·华为·harmonyos
韩曙亮11 小时前
【Flutter】iOS 网络权限设置 ② ( 配置 iOS 平台可使用 HTTP 访问 | ATS 网络安全强制规范 )
网络·flutter·http·ios·https·网络权限·ats