Android uses Tcpdump to capture packets

Source: Internet
Author: User

1. The mobile phone must have the root permission

2. Download tcpdump Http://www.strazzere.com/android/tcpdump

3.Adb push c: \ wherever_you_put \Tcpdump /Data/local/Tcpdump

4.Adb shell chmod 6755/data/local/Tcpdump

5, adb shell, Su obtains the root permission.

6. cd/data/local

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

Command parameters:

 

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


8,Adb pull/sdcard/capture. pcap d :/

9,Enable capture. pcap with wireshark on the computer to analyze the log

 

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
Just the header ): 

 

AdbShellTcpdump-N-S0  

 

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

Only listen for http

AdbShellTcpdump-X-N-S0Port80

 

Based on the above information, write a bat for execution (the tcpdump file must be in the current directory ).

 

Start tcpdump

Adb push tcpdump/data/local/tcpdumpadb shell chmod 6755/data/local/tcpdumpadb shell rm-r/sdcard/capture. pcapadb shell /Data/local/tcpdump-I any-p-s 0-w/sdcard/capture. pcapPause

Download the tcpdump file to your computer

 Adb pull/sdcard/capture. pcap capture. pcap

 

 Problem: some machines use the adb shell after root, which is not the root user by default. You need to enter su to switch to the root user. This will cause problems when performing batch processing. The solution is as follows:

Adb shell "su-c 'sleep 1'" adb start-server

Adb push tcpdump/data/local/tcpdump

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.