1. 手机要有root权限

2. 下载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获得root权限

6, cd /data/local

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

       ./tcpdump -p  -vv -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 

 

 问题:有些机器root后通过adb shell 后,默认不是root用户,需要输入 su才能切换到root,这样在执行批处理会有问题,解决方法如下

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

adb push tcpdump /data/local/tcpdump 

更多相关文章

  1. Android读写文件源码
  2. 高斯模糊效果移植到android系统
  3. 解决“Connection to https://dl-ssl.google.com refused”问题
  4. Android(安卓)模拟器方向键和键盘方向键不能用
  5. android自定标题栏
  6. Android问题总结
  7. 编译友善之背的mini210的android文件系统
  8. 【Android-File】Android文件的读写
  9. 14 Android(安卓)android 按钮效果的两种实现方法

随机推荐

  1. 程序设计神器 之 实体
  2. 互联网测试校招系列4:面试篇
  3. 上班摸鱼程序,再也不怕领导偷偷出现在身后
  4. 弃繁就简!一行代码搞定 Python 日志!
  5. 开眼界!Python 遍历文件可以这样做!
  6. PDMan 之数据库逆向解析
  7. 20210404
  8. html5+css3制作的课程表和注册表单
  9. 元数据管理—动态表单设计器在crudapi系
  10. Spring Cloud 升级之路 - 2020.0.x - 1.