Android通过tcpdump抓包

简介: 1 手机要有root权限2 下载tcpdumpandroid模拟器上linux里面有的会自带。3 adb push c:\wherever_you_put\tcpdump /data/local/tcpdump4 adb shell chmod...

1 手机要有root权限

2 下载tcpdump

android模拟器上linux里面有的会自带。

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 

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

adb shell "su -c 'sleep 1'"
adb start-server
adb push tcpdump /data/local/tcpdump 

因没有root权限导致的问题

adb shell su -c "/data/local/tmp/tcpdump -i any -p -s 0 -w /sdcard/netCapture.pcap"
相关文章
|
9月前
|
网络协议 Android开发 Python
Android 抓包工具r0capture使用
Android 抓包工具r0capture使用
689 1
|
9月前
|
存储 Java API
Android 浅度解析:mk预置AAR、SO文件、APP包和签名
Android 浅度解析:mk预置AAR、SO文件、APP包和签名
1063 0
|
4月前
|
Web App开发 网络协议 数据可视化
tcpdump 和 wireshark 抓包工具 ,介绍、安装、命令使用。 详解三次握手、四次挥手。两个结合使用,会更好分析报文
这篇文章详细介绍了网络抓包工具tcpdump和Wireshark的使用,包括安装、命令选项、过滤器语法,以及如何通过分析TCP的三次握手和四次挥手来理解网络通信细节。
976 1
|
9月前
|
Java 开发工具 Android开发
如何在Eclipse中查看Android源码或者第三方组件包源码(转)
如何在Eclipse中查看Android源码或者第三方组件包源码(转)
75 4
|
6月前
|
安全 Java Android开发
【Android P】OTA升级包定制,移除不需要更新的分区,重新打包签名
如何解压OTA升级包、编辑升级包内容(例如移除不需要更新的分区)、重新打包、签名以及验证OTA文件的过程。
497 2
【Android P】OTA升级包定制,移除不需要更新的分区,重新打包签名
|
6月前
tcpdump抓包命令详解
tcpdump抓包命令详解
|
7月前
|
运维 监控 网络协议
Linux抓包命令tcpdump使用技巧大全
【7月更文挑战第10天】
262 5
Linux抓包命令tcpdump使用技巧大全
|
6月前
|
Android开发 开发者
Android、Flutter为不同的CPU架构包打包APK(v7a、v8a、x86)
Android、Flutter为不同的CPU架构包打包APK(v7a、v8a、x86)
432 1
|
8月前
|
存储 Android开发
详细解读Android获取已安装应用信息(图标,名称,版本号,包)
详细解读Android获取已安装应用信息(图标,名称,版本号,包)
121 0
|
9月前
|
Android开发 数据安全/隐私保护 iOS开发
ios和安卓测试包发布网站http://fir.im的注册与常用功能
ios和安卓测试包发布网站http://fir.im的注册与常用功能
392 0
ios和安卓测试包发布网站http://fir.im的注册与常用功能

热门文章

最新文章

推荐镜像

更多