Android通过tcpdump抓包(wifi, 2g, 3g都可以)

转载

原文地址:http://blog.csdn.net/deng529828/article/details/20646197

1. 手机要有root权限

2. 下载tcpdump   http://www.androidtcpdump.com/android-tcpdump/downloads

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

如果这一步真机无法push,可以用adb push c:\where_you_put\tcpdump /sdcard,即先将文件存入不需要权限的文件夹中,这里用sdcard,然后在传到/data/local/tcpdump。

4. adb shell chmod 6755 /data/local/tcpdump

5, adb shell,   su获得root权限

6, cd /data/local

7, ./tcpdump -i any -p -s 0 -w /sdcard/capture.pcap

 

命令参数:

 

        # "-i any": listen on any network interface

  # "-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)

  ... do whatever you want to capture, then ^C to stop it ...

下载tcpdump文件到电脑 

 adb pull /sdcard/capture.pcap capture.pcap 

 

二、使用手机自带的tcpdump命令抓包

如果使用手机自带的tcpdump用上面的命令参数抓包会生成很多个小文键,使用如下命令即可:

tcpdump -i  any -c 100000 -w  ./capture.pcap

#-i   指定要抓取数据包的网卡
#-c  指定抓取多少个数据包生成一个文件
#-w  指定要保存的文件

 

 

 

 

然后用wireshark打开即可看到数据包的详细信息。

 

posted @ 2017-07-03 18:35  远洪  阅读(749)  评论(0)    收藏  举报