安卓/Android9.0以上版本使用Charles抓包操作流程

准备环境:
1、安卓手机(已root)
2、Charles
步骤一 将手机和Charles连接并下载证书:
1、将手机和电脑连接至同一WiFi
2、打开Charles–help–Local IP Addresses查看ip地址
请添加图片描述
3、打开手机–WiFi–设置代理为手动,输入ip和端口号
在这里插入图片描述
4、打开手机浏览器输入:chls.pro/ssl 下载Charles证书
在这里插入图片描述
5、由于安卓版本限制,不能直接安装证书,需要从手机–设置–系统安全–加密与凭据–从SD卡安装
在这里插入图片描述
步骤二 unknown解决方法:
1、安装证书后,因安卓版本原因,导致该证书并没有安装至系统证书,所以此时抓包看到的请求和响应依然为(unknown)在这里插入图片描述
2、解决方法,将证书移至手机系统目录(/system/etc/security/cacerts/)需要通过adb命令,切换为超级用户使用命令:su
在这里插入图片描述
3、由于证书安装完后,通过adb命令查看该路径(/data/misc/user/0/cacerts-added )就是一个hash值,所以将该hash值复制到系统目录(/system/etc/security/cacerts/)即可
在这里插入图片描述
使用命令(/data/misc/user/0/cacerts-added # cp hash值.0 /system/etc/security/cacerts/)
4、复制发现,此时system文件为只读,所以修改system文件编辑权限
在这里插入图片描述

	a、执行:mount -o rw,remount -t auto /
	b、执行:chmod 777 system/

步骤三 检查是否成功
1、此路径下(/system/etc/security/cacerts/)已有复制的证书hash值
2、手机–设置–系统安全–加密与凭据–信任的凭据–系统下有开启状态的证书
在这里插入图片描述
3、查看Charles抓包结果,此时可以进行正常抓取数据
在这里插入图片描述

  • 7
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android 9.0 及以上版本,为了进一步增强应用程序的安全性,Android 引入了更严格的后台限制,禁止所有未在前台运行的应用程序启动服务。如果您想在后台启动服务,需要使用 `startForegroundService()` 方法,并且需要在 5 秒钟内调用 `startForeground()` 方法将服务设置为前台服务。 以下是一个使用 `startForegroundService()` 和 `startForeground()` 的示例代码: ``` if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // 创建一个 NotificationChannel NotificationChannel channel = new NotificationChannel("channel_id", "channel_name", NotificationManager.IMPORTANCE_DEFAULT); // 向系统注册 NotificationChannel NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(channel); } // 创建一个 Intent,启动你的服务 Intent serviceIntent = new Intent(this, YourService.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // 在 Android 9.0 及以上版本上,需要调用 startForegroundService() 方法启动服务。 startForegroundService(serviceIntent); // 在启动服务后,5 秒钟内调用 startForeground() 方法将服务设置为前台服务。 // 如果在 5 秒钟内没有调用 startForeground() 方法,系统会认为服务无法正常启动,会抛出异常。 new Handler().postDelayed(new Runnable() { @Override public void run() { startForeground(1, new Notification()); } }, 5000); } else { // 在 Android 9.0 以下版本上,可以直接调用 startService() 方法启动服务。 startService(serviceIntent); } ``` 注意:在 Android 9.0 及以上版本上,如果你使用的是 `startForeground()` 方法,会在 5 秒钟后抛出 `ANR` 异常,因为 Android 9.0 及以上版本要求服务必须在 5 秒钟内设置为前台服务。如果你想在后台运行服务,必须使用 `startForegroundService()` 和 `startForeground()` 方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值