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