tcpdump抓包(转)
Linux 环境下,通常通过 tcpdump 来进行抓包和分析。它是几乎所有 Linux 发行版本预装的数据包抓取和分析工具。
tcpdump 工具的获取和安装可以参阅相应操作系统的官方文档,本文不再详述。
tcpdump 的用法如下:
tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
[ -c count ]
[ -C file_size ] [ -G rotate_seconds ] [ -F file ]
[ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
[ --number ] [ -Q in|out|inout ]
[ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ]
[ -E spi@ipaddr algo:secret,... ]
[ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
[ --time-stamp-precision=tstamp_precision ]
[ --immediate-mode ] [ --version ]
[ expression ]
常见参数说明(区分大小写):
- -s 设置数据包抓取长度。如果置为0,则表示自动选择合适的长度来抓取数据包。
- -w将抓包结果导出到文件,而不是在控制台进行分析和打印输出。
- -i 指定需要监听的接口(网卡)。
- -vvv 输出详细的数据交互信息。
- expression 一个正则表达式,用作过滤报文的条件。主要包含如下几类:
- 关于类型的关键字:包括 host(主机),net(网络),port(端口)。
- 确定传输方向的关键字:包括 src(源),dst(目标),dst or src(源或目标),dst and src(源和目标)。
- 使用协议的关键字:包括 icmp,ip,arp,rarp,tcp,udp等类型。
更多参数说明及用法,可以参阅 tcpdump 的 man 帮助。
常见用法和示例输出:
- 抓取指定网卡指定端口的交互数据
- 操作指令
tcpdump -s 0 -i eth0 port 22 - 示例输出
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
20:24:59.414951 IP 172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], seq 442372:442536, ack 53, win 141, length 164
20:24:59.415002 IP 172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], seq 442536:442700, ack 53, win 141, length 164
20:24:59.415052 IP 172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], seq 442700:442864, ack 53, win 141, length 164
20:24:59.415103 IP 172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], seq 442864:443028, ack 53, win 141, length 164
- 操作指令
- 抓取指定网卡发送给指定 IP 上指定端口的交互数据,并在控制台输出详细交互信息
- 操作指令
tcpdump -s 0 -i eth1 -vvv port 22 - tcpdump -s 0 -i enp1s0 -vvv dst 172.16.2.226 and port 22
- 示例输出
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
20:24:20.991006 IP (tos 0x10, ttl 64, id 22747, offset 0, flags [DF], proto TCP (6), length 316)
172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], cksum 0x2504 (incorrect -> 0x270d), seq 133624:133900, ack 1, win 141, length 276
20:24:20.991033 IP (tos 0x0, ttl 53, id 2348, offset 0, flags [DF], proto TCP (6), length 92)
42.120.74.107.43414 > 172.16.2.226.ssh: Flags [P.], cksum 0x4759 (correct), seq 1:53, ack 129036, win 15472, length 52
20:24:20.991130 IP (tos 0x10, ttl 64, id 22748, offset 0, flags [DF], proto TCP (6), length 540)
172.16.2.226.ssh > 42.120.74.107.43414: Flags [P.], cksum 0x25e4 (incorrect -> 0x5e78), seq 133900:134400, ack 53, win 141, length 500
20:24:20.991162 IP (tos 0x0, ttl 53, id 2349, offset 0, flags [DF], proto TCP (6), length 40)
42.120.74.107.43414 > 172.16.2.226.ssh: Flags [.], cksum 0xf39e (correct), seq 53, ack 129812, win 15278, length 0
- 操作指令
- 抓取发送至指定 IP 的 ping 交互数据,并在控制台输出详细交互信息
- 操作指令
tcpdump -s 0 -i eth1 -vvv dst 223.5.5.5 and icmp - 示例输出
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
20:26:00.368958 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
172.16.2.226 > public1.alidns.com: ICMP echo request, id 55097, seq 341, length 64
20:26:01.369996 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
172.16.2.226 > public1.alidns.com: ICMP echo request, id 55097, seq 342, length 64
20:26:02.371058 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
172.16.2.226 > public1.alidns.com: ICMP echo request, id 55097, seq 343, length 64
20:26:03.372181 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
172.16.2.226 > public1.alidns.com: ICMP echo request, id 55097, seq 344, length 64
- 操作指令
- 抓取系统内所有接口数据并保存到指定文件
- 操作指令
tcpdump -i any -s 0 -w test.cap - 示例输出
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
- 操作指令
tcpdump抓包(转)的更多相关文章
- tcpdump抓包命令
本文转自 : http://www.cnblogs.com/ggjucheng/archive/2012/01/14/2322659.html http://www.itshouce.com.cn/l ...
- [转] Android利用tcpdump抓包
原文链接:http://mysuperbaby.iteye.com/blog/902201 Android利用tcpdump抓包 博客分类: Android AndroidAccessGoHTML ...
- TCPdump抓包命令详解--摘
http://blog.csdn.net/s_k_yliu/article/details/6665673/ http://starsliao.blog.163.com/blog/static/890 ...
- Android手机tcpdump抓包
在开发过程中遇到问题时,无法非常方便的获取到数据包,导致分析解决问题比较麻烦.这里介绍如何在Android手机上实现tcpdump抓包. 1.root机器 在用tcpdump抓包过程中,需要使用 ...
- Wireshark和TcpDump抓包分析心得
Wireshark和 TcpDump抓包分析心得 1. Wireshark与tcpdump介绍 Wireshark是一个网络协议检测工具,支持Windows平台和Unix平台,我一般只在Window ...
- tcpdump 抓包让wireshark来分析
在linux下面用tcpdump 抓包非常方便, 但是抓的包要提取出来进行分析, 还是得用wireshark来过滤分析比较方便. 下面先介绍一下 TCPDUMP 的使用 例:tcpdump host ...
- tcpdump抓包并保存成cap文件
首选介绍一下tcpdump的常用参数 tcpdump采用命令行方式,它的命令格式为: tcpdump [ -adeflnNOpqStvx ] [ -c 数量 ] [ -F 文件名 ] [ -i 网络接 ...
- Android tcpdump抓包应用实现
Android tcpdump抓包应用实现 Android应用很多时候都会涉及到网络,在请求网络出错时,我们可以通过抓包来分析网络请求,返回的数据等,通常我们是用tcpdump这个工具来抓包,再通 ...
- linux使用tcpdump抓包工具抓取网络数据包,多示例演示
tcpdump是linux命令行下常用的的一个抓包工具,记录一下平时常用的方式,测试机器系统是ubuntu 12.04. tcpdump的命令格式 tcpdump的参数众多,通过man tcpdump ...
- Linux下面如何用tcpdump抓包
很多时候我们的系统部署在Linux系统上面,在一些情况下定位问题就需要查看各个系统之间发送数据报文是否正常,下面我就简单讲解一下如何使用tcpdump抓包 tcpdump是Linux下面的一个开源的抓 ...
随机推荐
- HDU 3342 拓扑排序模板
Legal or Not Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- python 输入 与如何查看文档 小结
Python 2 中的输入小结 转载请声明本文的引用出处:仰望大牛的小清新 1.raw_input(prompt = None)与input(prompt = None) 两个都是默认参数类型,这个参 ...
- (寒假GYM开黑)2018-2019 ACM-ICPC Brazil Subregional Programming Contest
layout: post title: 2018-2019 ACM-ICPC Brazil Subregional Programming Contest author: "luowenta ...
- 网站模糊测试爆破工具Wfuzz
网站模糊测试爆破工具Wfuzz 模糊测试爆破使用模糊测试的方式对HTTP请求中的各个参数同时进行猜测爆破.例如,渗透测试人员可以采用不同的HTTP请求方式来访问由字典生成的网页路径,以判断网页目录 ...
- String和StringBuffer的机制差别
String是不可变的,StringBuffer是可变的:StringBuffer是线程安全的,StringBuilder是非线程安全的. 因而在大部分情况下字符串的拼接速度为:StringBuild ...
- map泛型 map不指定泛型 与 Map<Object,Object>的区别
map泛型 map不指定泛型 与 Map<Object,Object>的区别 private void viewDetail(){ Map map1 = new HashMap(); Ma ...
- 最新Mac安装CocoaPods详细教程及各种坑解决办法
网上有很多教程,但要么内容很老,要么不详细,要么各种坑的情况没写.最近买新电脑了,正好要走一遍这些流程,所以写下次教程. 一.安装RVM及更新Ruby 安装RVM的目的是为了更新Ruby,如果你的Ru ...
- Douglas Peucker算法的C#实现
一.算法原理 Douglas-Peucker算法 在数字化过程中,需要对曲线进行采样简化,即在曲线上取有限个点,将其变为折线,并且能够在一定程度 上保持原有的形状. 经典的Douglas-Peucke ...
- PHP将字符串首字母大小写转换
每个单词的首字母转换为大写:ucwords() <?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = ...
- Docker时间和宿主同步
通过date命令查看时间 查看主机时间 [root@localhost ~]# date 2016年 07月 27日 星期三 22:42:44 CST 查看容器时间 root@b43340ecf5ef ...