android 用tcpdump抓取網路包

來源:互聯網
上載者:User

 

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:
  Cmd代碼
  adb root
  adb remount
  adb push /wherever/you/put/tcpdump /system/xbin/tcpdump
  adb shell chmod 6755 /data/local/tmp/tcpdump
  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代碼
  adb shell tcpdump -i any -p -s 0 -w /sdcard/capture.pcap
  # "-i any": listen on any network inte**ce
  # "-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 ...
  adb pull /sdcard/capture.pcap .
  sudo apt-get install wireshark # or ethereal, if you're still on dapper
  wireshark capture.pcap # or ethereal
  ... look at your packets and be wise ...
  adb shell tcpdump -i any -p -s 0 -w /sdcard/capture.pcap
  # "-i any": listen on any network inte**ce
  # "-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 ...
  adb pull /sdcard/capture.pcap .
  sudo apt-get install wireshark # or ethereal, if you're still on dapper
  wireshark capture.pcap # or ethereal
  ... look at your packets and be wise ...
  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代碼
  adb shell tcpdump -n -s 0
  adb shell tcpdump -n -s 0
  Typical tcpdump options apply. For example, if you want to see HTTP traffic:
  Cmd代碼
  adb shell tcpdump -X -n -s 0 port 80
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.