Android uses tcpdump to capture network packets

Source: Internet
Author: User
Tags root access

 

Instructions
Http://source.android.com/porting/tcpdump.html
Source code and documents ents
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 code
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 your strated below:
CMD code
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 wowould 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 code
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 code
ADB shell tcpdump-X-n-s 0 port 80
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.