Android利用tcpdump抓包


Instructions
http://source.android.com/porting/tcpdump.html
Source Code and Documents
http://www.tcpdump.org/
Compiled Binary Download
http://www.strazzere.com/android/tcpdump
数据包分析工具Wireshark
http://www.wireshark.org/download.html


Installing tcpdump

Pushing the binary to an existing device
Download tcpdump from http://www.tcpdump.org/, then execute:

adb root  adb remount  adb push /wherever/you/put/tcpdump /system/xbin/tcpdump  adb shell chmod 6755 /data/local/tmp/tcpdump



Running tcpdump
You need to have root access on your device.
Batch mode capture
The typical procedure is to capture packets to a file and then examine the file on the desktop, as illustrated below:
Cmd代码
  1. adbshelltcpdump-iany-p-s0-w/sdcard/capture.pcap
  2. #"-iany":listenonanynetworkinterface
  3. #"-p":disablepromiscuousmode(doesn'tworkanyway)
  4. #"-s0":capturetheentirepacket
  5. #"-w":writepacketstoafile(ratherthanprintingtostdout)
  6. ...dowhateveryouwanttocapture,then^Ctostopit...
  7. adbpull/sdcard/capture.pcap.


You can run tcpdump in the background from an interactive shell or from Terminal. By default, tcpdump captures all traffic without filtering. If you prefer, add an expression like port 80 to the tcpdump command line.

Real time packet monitoring
Execute the following if you would like to watch packets go by rather than capturing them to a file (-n skips DNS lookups. -s 0 captures the entire packet rather than just the header):
Cmd代码
  1. adbshelltcpdump-n-s0


Typical tcpdump options apply. For example, if you want to see HTTP traffic:


先把内容放这,有空来做些整理和说明。


更多相关文章

  1. android带图片的AlertDialog和文件管理器(代码)
  2. 最常用的GitHub—— Android(安卓)开源项目整理(精品)
  3. Android中隐藏ActionBar的方法
  4. Android去掉头部标题
  5. Android屏幕自适应的四种方法
  6. Android(安卓)Camera使用小结
  7. Android中的visibility属性的区别
  8. android 字体&颜色
  9. Android(安卓)Notification的使用

随机推荐

  1. Android NDK Log信息打印
  2. Android(安卓)3 开始 Activity MainThrea
  3. Android 通过命令将文件导出
  4. Android ListPreference
  5. android的一些常用手机信息获取
  6. android播放本地音乐程序
  7. Android--(11)--解读单选(RadioButton)和
  8. Android之SQLite列操作
  9. Android Studio 初步在代码中操作控件
  10. Android导入工程提示Invalid project des