Android 模拟器:如何监控网络流量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2453949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android emulator: How to monitor network traffic?
提问by mlindeboom
How do I monitor network traffic sent and received from my android emulator?
如何监控从我的 android 模拟器发送和接收的网络流量?
回答by Christopher Orr
There are two ways to capture network traffic directlyfrom an Android emulator:
有两种方法可以直接从 Android 模拟器捕获网络流量:
Copy and run an ARM-compatible tcpdump binaryon the emulator, writing output to the SD card, perhaps (e.g.
tcpdump -s0 -w /sdcard/emulator.cap
).Run
emulator -tcpdump emulator.cap -avd my_avd
to write all the emulator's traffic to a local file on your PC
在模拟器上复制并运行一个ARM 兼容的 tcpdump 二进制文件,将输出写入 SD 卡,也许(例如
tcpdump -s0 -w /sdcard/emulator.cap
)。运行
emulator -tcpdump emulator.cap -avd my_avd
以将所有模拟器的流量写入 PC 上的本地文件
In both cases you can then analyse the pcap file with tcpdump or Wireshark as normal.
在这两种情况下,您都可以正常使用 tcpdump 或 Wireshark 分析 pcap 文件。
回答by Waltsu
It is also possible to use http proxy to monitor http requests from emulator. You can pass -http-proxy
flag when starting a new emulator to set proxy (Example burp) to monitor Android traffic. Example usage ./emulator -http-proxy localhost:8080 -avd android2.2
. Note that in my example I'm using Burp, and it is listening port 8080. More info can be found here.
也可以使用 http 代理来监控来自模拟器的 http 请求。您可以-http-proxy
在启动新模拟器时传递标志来设置代理(例如burp)来监控 Android 流量。示例用法./emulator -http-proxy localhost:8080 -avd android2.2
。请注意,在我的示例中,我使用的是 Burp,它正在侦听端口 8080。可以在此处找到更多信息。
回答by Tom Susel
For OS X you can use Charles, it's simple and easy to use.
对于 OS X,您可以使用Charles,它简单易用。
For more information, please have a look at Android Emulator and Charles Proxyblog post.
有关更多信息,请查看Android Emulator 和 Charles Proxy博客文章。
回答by Tad
A current release of Android Studio did not correctly apply the -tcpdump
argument. I was still able to capture a dump by passing the related parameter to qemu as follows:
当前版本的 Android Studio 未正确应用该-tcpdump
参数。我仍然能够通过将相关参数传递给 qemu 来捕获转储,如下所示:
tools/emulator -engine classic -tcpdump dump.cap -avd myAvd
回答by Bitdivision
Yes, wireshark will work.
是的,wireshark 会起作用。
I don't think there is any easy way to filter out solely emulator traffic, since it is coming from the same src IP.
我认为没有任何简单的方法可以过滤掉模拟器流量,因为它来自同一个 src IP。
Perhaps the best way would be to set up a very bare VMware environment and only run the emulator in there, at least that way there wouldn't be too much background traffic.
也许最好的方法是建立一个非常裸的 VMware 环境并只在其中运行模拟器,至少这样不会有太多的后台流量。
回答by Laramie
回答by Prof. Moriarty
It is now possible to use Wireshark directly to capture Android emulator traffic. There is an extcapplugin called androiddumpwhich makes it possible. You need to have a tcpdump
executable in the system image running on the emulator (most current images have it, tested with API 24 and API 27 images) and adbd
running as root on the host (just run adb root
). In the list of the available interfaces in Wireshark (Qt version only, the deprecated GTK+ doesn't have it) or the list shown with tshark -D
there should be several Android interfaces allowing to sniff Bluetooth, Logcat, or Wifi traffic, e.g.:
现在可以直接使用 Wireshark 来捕获 Android 模拟器流量。有一个名为androiddump的extcap插件使它成为可能。您需要在模拟器上运行的系统映像中有一个可执行文件(大多数当前映像都有它,使用 API 24 和 API 27 映像进行了测试)并在主机上以 root 身份运行(只需 run )。在 Wireshark 中的可用接口列表(仅限 Qt 版本,已弃用的 GTK+ 没有)或显示的列表中应该有几个 Android 接口允许嗅探蓝牙、Logcat 或 Wifi 流量,例如:tcpdump
adbd
adb root
tshark -D
android-wifi-tcpdump-emulator-5554 (Android WiFi Android_SDK_built_for_x86 emulator-5554)
android-wifi-tcpdump-emulator-5554 (Android WiFi Android_SDK_built_for_x86 emulator-5554)
回答by Ritveak
I would suggest you use Wireshark.
我建议你使用Wireshark。
Steps:
- Install Wireshark.
- Select the network connection that you are using for the calls(for eg, select the Wifi if you are using it)
- There will be many requests and responses, close extra applications.
- Usually the requests are in green color, once you spot your request, copy the destination address and use the filter on top by typing
ip.dst==52.187.182.185
by putting the destination address.
脚步:
- 安装 Wireshark。
- 选择您用于通话的网络连接(例如,如果您正在使用,请选择 Wifi)
- 会有很多请求和响应,关闭额外的应用程序。
- 通常请求是绿色的,一旦你发现你的请求,复制目标地址并通过输入目标地址来使用顶部的过滤器
ip.dst==52.187.182.185
。
You can make use of other filtering techniques mentioned hereto get specific traffic.
您可以利用此处提到的其他过滤技术来获取特定流量。
回答by Dhiraj Himani
You can use http://docs.mitmproxy.org/en/stable/install.html
您可以使用 http://docs.mitmproxy.org/en/stable/install.html
Its easy to setup and won't require any extra tweaks.
它易于设置,不需要任何额外的调整。
I go through various tool but found it to be really good and easy.
我使用了各种工具,但发现它非常好且简单。
回答by Paddy
You can start the emulator with the command -avd Adfmf -http-proxy http://SYSTEM_IP:PORT
.
I used HTTP Analyzer, but it should work for anything else. More details can be found here:
http://stick2code.blogspot.in/2014/04/intercept-http-requests-sent-from-app.html
您可以使用命令启动模拟器-avd Adfmf -http-proxy http://SYSTEM_IP:PORT
。我使用了 HTTP Analyzer,但它应该适用于其他任何事情。更多细节可以在这里找到:http:
//stick2code.blogspot.in/2014/04/intercept-http-requests-sent-from-app.html