android app要抓TCP数据包,我们可以使用TCPdump工具!

下载tcpdump,可到http://www.tcpdump.org/查看使用文档.

还有个地址是http://www.strazzere.com/android/tcpdump.

 

具体步骤:

1.需要root权限

2.推送tcpdump文件到手机端,最好放在data目录下,如

adb push c:\wherever_you_put\tcpdump  /data/local/tcpdump

3.更改tcpdump文件的权限
adb shell chmod 777 /data/local/tcpdump

4.启动你要抓包的app,执行如下命令就可以开始抓包了,抓包文件以.pcap为后缀
adb shell tcpdump -p -vv -s 0 -w /sdcard/capture.pcap
# "-p": disable promiscuous mode (doesn't work anyway)
# "-s 0": capture the entire packet
# "-w": write packets to a file (rather than printing to stdout)

5.停止抓包,使用ctrl+C
... do whatever you want to capture, then ^C to stop it ...

6.导出转包文件
adb pull /sdcard/capture.pcap .

7.使用Wireshark将日志文件打开

 

 

posted on 2013-04-15 19:36  随我畅翔  阅读(578)  评论(0编辑  收藏  举报