简体   繁体   English

如何使用Charles Proxy分析来自Android 6模拟器的https流量

[英]How to analyze https traffic from Android 6 emulator with Charles Proxy

I want to analyze the https traffic of the app I am developing for Android. 我想分析我正在为Android开发的应用的https流量。
Charles Web Debugging Proxy is the tool I want to use for that. Charles Web Debugging Proxy是我想要使用的工具。 I have the following system configuartion: 我有以下系统配置:

  • Mac OS X El Capitan Version 10.11.5 Mac OS X El Capitan版本10.11.5
  • Android Studio 2.1.2 Android Studio 2.1.2
    • Build #AI-143.2915827, built on May 26, 2016 Build#AI-143.2915827,建于2016年5月26日
    • Android SDK Tools 25.2.0 rc1 Android SDK工具25.2.0 rc1
    • Platform Version: API 24: Android 6.X (N) revision 2 平台版本:API 24:Android 6.X(N)版本2
  • Charles Web Debugging Proxy v 3.11.5 30 day trial version Charles Web Debugging Proxy v 3.11.5 30天试用版

I already read several posts on StackOverflow like eg 我已经在StackOverflow上阅读过几篇文章,例如

But still I didn't reach my goal. 但我还没达到目标。 I walked through all the important steps: 我走过了所有重要的步骤:

  • Charles Root Certificate installed and added to Max OS X Keychain and trusted Charles Root证书已安装并添加到Max OS X Keychain并受到信任
    • Open Proxy Settings: Proxy -> Proxy Settings, Proxies Tab, check "Enable transparent HTTP proxying" 打开代理设置:代理 - >代理设置,代理选项卡,选中“启用透明HTTP代理”
    • Open SSL Proxy Settings:Proxy -> SSL Proxy Settings, SSL Proxying tab, Check “enable SSL Proxying” 打开SSL代理设置:代理 - > SSL代理设置,SSL代理选项卡,选中“启用SSL代理”
  • Android Emulator started from Android Studio Terminal by ~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -http-proxy <IP_FROM_DEVICE_WITH_CHARLES_PROXY_INSTALLED>:8888 -avd Nexus_5_API_23 Android模拟器从Android Studio终端开始~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -http-proxy <IP_FROM_DEVICE_WITH_CHARLES_PROXY_INSTALLED>:8888 -avd Nexus_5_API_23
  • Certificate installed from http://charlesproxy.com/getssl 证书从http://charlesproxy.com/getssl安装
  • OR Certificate saved by Charles Proxy, converted to .crt by openssl and installed on emulated device 或者由Charles Proxy保存的证书,由openssl转换为.crt并安装在模拟设备上

I can read all the http traffic in Charles Proxy without any problems. 我可以毫无问题地阅读Charles Proxy中的所有http流量。 I also can read the https traffic but Charles only lists IP addresses. 我也可以阅读https流量 Charles只列出IP地址。 There are entries like 有条目喜欢

https://173.194.65.188:5228

So the ip addresses are not resolved. 所以ip地址没有解决。 How to get real https URLs? 如何获得真正的https网址? Do I have to activate DNS for https somewhere? 我是否必须在某处为https激活DNS?

I too found this to be an issue. 我也认为这是一个问题。 My solution when I want to debug network traffic via Charles Proxy, is to switch over to Genymotion emulator. 当我想通过Charles Proxy调试网络流量时,我的解决方案是切换到Genymotion模拟器。 The Genymotion emulator will give you the url(s) vs. ip(s) in Charles. Genymotion模拟器将为您提供Charles中的url(s)与ip(s)。

In the Genymotion emulator you configure the Wifi proxy hostname to '10.0.3.2' and Proxy port enter '8888' (*assuming port 8888 is the listening port you have configured in Charles Proxy). 在Genymotion仿真器中,您将Wifi代理主机名配置为'10 .0.3.2',代理端口输入'8888'(*假设端口8888是您在Charles Proxy中配置的侦听端口)。

There are instructions that make the Android emulator work with Charles here: 有一些说明可以让Android模拟器在这里与Charles一起使用:

https://stackoverflow.com/a/35577864/2832027 https://stackoverflow.com/a/35577864/2832027

It is quite unreliable. 这是非常不可靠的。 You need to put the emulator in and out of airplane mode if it was working and then stops working. 如果模拟器工作正常,则需要将模拟器放入和退出飞行模式,然后停止工作。

Here are the steps from the above post: 以下是上述帖子的步骤:

  1. Start the emulator from the terminal with /{path to your android sdk directory}/tools/emulator -avd Nexus_5X_API_23 -http-proxy http://192.168.2.38:8888 where the -avd value is the name of your emulator and the -http-proxy value is the ip address from Charles: Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device or Remote Browser. 使用/{path to your android sdk directory}/tools/emulator -avd Nexus_5X_API_23 -http-proxy http://192.168.2.38:8888从终端启动模拟器,其中-avd值是模拟器的名称,并且-http-proxy值是Charles的IP地址:帮助> SSL代理>在移动设备或远程浏览器上安装Charles Root证书。

  2. In Charles, the following should be set: Proxy > Proxies 8888 Enable transparent proxying should be checked; 在Charles中,应设置以下内容:Proxy> Proxies 8888应检查Enable transparent proxying ; Proxy > macOS Proxy should be checked 应检查代理> macOS代理

  3. In the emulator, `Settings > More (Wireless > Cellular Networks > Access Points > T-Mobile US (or whichever other network is there) set Proxy to 10.0.2.2 and port to 8888 在模拟器中,`设置>更多(无线>蜂窝网络>接入点> T-Mobile US(或其他任何网络)将代理设置为10.0.2.2并将端口设置为8888

  4. In the emulator, Settings > Developer Options > Use legacy DHCP client should be on. 在模拟器中,应启用Settings > Developer Options > Use legacy DHCP客户端”。

  5. In the emulator, turn Airplane mode on and off 在仿真器中,打开和关闭飞行模式

Also, see this if you have issues getting Charles working on Android 7 (API 24) and above. 另外,如果您在Charles使用Android 7(API 24)及更高版本时遇到问题,请参阅此内容。 https://android.jlelse.eu/android-nougat-charlesing-ssl-network-efa0951e66de https://android.jlelse.eu/android-nougat-charlesing-ssl-network-efa0951e66de

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM