Android 抓包的一些命令 及 adb使用的一些注意事項

ADB:android

adb devices: 失敗時使用下一句查詢5037端口被佔用狀況,shell

netstat -ano | findstr 5037: 而後查看佔用的PID,關閉佔用程序。app

TCPDUMP抓包
tcp

1. 下載tcpdump   http://www.strazzere.com/android/tcpdump spa

3. adb push c:\wherever_you_put\tcpdump /data/local/tcpdumporm

4. adb shell chmod 6755 /data/local/tcpdumpip

5, adb shell,   su得到root權限get

6, cd /data/localit

7, ./tcpdump -i any -p -s 0 -w /sdcard/capture.pcapio

命令參數:

 

        # "-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,  在電腦上用wireshark打開capture.pcap便可分析log

 

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):  

 

adb shell tcpdump -n -s 0   

 

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

只監聽http  

adb shell tcpdump -X -n -s 0 port 80

 

根據以上的信息,寫一個bat去執行(tcpdump文件必須在當前目錄裏)。

 

開始tcpdump 

adb push tcpdump /data/local/tcpdump

adb shell chmod 6755 /data/local/tcpdump

adb shell rm -r /sdcard/capture.pcap

adb shell  /data/local/tcpdump -i any -p -s 0 -w /sdcard/capture.pcap

pause

 

下載tcpdump文件到電腦 

 adb pull /sdcard/capture.pcap capture.pcap 

相關文章
相關標籤/搜索