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

來源:互聯網
上載者:User

標籤:android   style   http   color   io   os   使用   ar   for   

ADB:

adb devices: 失敗時使用下一句查詢5037連接埠被佔用情況,

netstat -ano | findstr 5037: 然後查看佔用的PID,關閉佔用程式。

TCPDUMP抓包

1. 下載tcpdump   http://download.csdn.net/detail/happylisher/8035645

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

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

5, adb shell,   su獲得root許可權

6, cd /data/local

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

命令參數:

 

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


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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.