原文链接

本文原文来自: A tcpdump Tutorial with Examples — 50 Ways to Isolate Traffic

TCPDUMP 简介

TCPDUMP 在一个界面中既提供了强大的功能又简单易用,无疑已经是网络分析工具中的老大。

本教程将介绍如何以各种方式隔离流量:从IP,端口到协议,再到应用层流量。以确使用者保能够尽快找到所需内容。

查看所有流量

查看指定接口上的所有流量

tcpdump -i eth0

查看所有接口上的所有流量

tcpdump -i any

通过IP找流量

这是最常用的查询之一,使用 host 指定主机,就会看到 从指定IP的进流量和出流量

tcpdump host 1.1.1.1 -i ens33

通过源地址和/或目的地址进行过滤

如果你只想一个方向上的流量,可以使用 srcdst 指定。

tcpdump src 192.168.27.100 -i ens33
tcpdump dst 192.168.27.100 -i ens33

通过网段过滤流量

使用 net 选项查看进出一个网段或子网的进出流量。

tcpdump net 1.2.3.0/24

使用十六进制输出流量包的内容

当要对一些包进行仔细审查其内容的时候,使用十六进制输出的方式来查看包就很有用了。

tcpdump -c 1 -X icmp -i ens33
tcpdump -c 1 -X tcp port 443 -i ens33

-c 1 是指定只抓取一个包。

[root@centos7 ~]#tcpdump -c 1 -X icmp -i ens33
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
15:25:37.519985 IP ming-machine > centos7-scm: ICMP echo request, id 40906, seq 1154, length 640x0000:  4500 0054 61af 4000 4001 20c8 c0a8 1b7d  E..Ta.@.@......}0x0010:  c0a8 1b64 0800 5ec2 9fca 0482 007a f35c  ...d..^......z.\0x0020:  0000 0000 3547 0d00 0000 0000 1011 1213  ....5G..........0x0030:  1415 1617 1819 1a1b 1c1d 1e1f 2021 2223  .............!"#0x0040:  2425 2627 2829 2a2b 2c2d 2e2f 3031 3233  $%&'()*+,-./01230x0050:  3435 3637                                4567
1 packet captured
2 packets received by filter
0 packets dropped by kernel
[root@centos7-scm ~]#tcpdump -c 1 -X tcp port 443 -i ens33
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
15:25:40.084912 IP ming-machine.53006 > tsa03s01-in-f14.1e100.net.https: Flags [S], seq 908528803, win 29200, options [mss 1460,sackOK,TS val 4054248663 ecr 0,nop,wscale 7], length 00x0000:  4500 003c 747a 4000 4006 48f3 c0a8 1b7d  E..<tz@.@.H....}0x0010:  d83a c8ee cf0e 01bb 3627 0ca3 0000 0000  .:......6'......0x0020:  a002 7210 668e 0000 0204 05b4 0402 080a  ..r.f...........0x0030:  f1a6 ecd7 0000 0000 0103 0307            ............
1 packet captured
1 packet received by filter
0 packets dropped by kernel
[root@centos7-scm ~]#

查看指定端口上的流量

通过 port 选项,可以找到指定端口上的进出流量。

tcpdump port 3389 -i ens33   # 3389 是 windows 远程链接的端口
tcpdump src port 1025 -i ens33

查看指定协议类型的流量

如果想要查看某一种类型协议的流量,可以通过 tcpudpicmo 或其他协议类型。

tcpdump icmp

只查看 IPv6 流量

https://hauweele.net/~gawen/blog/?p=1053

tcpdump src fe80::1e55:bb34:ae1:fd08 -i ens33
tcpdump dst fe80::1e55:bb34:ae1:fd08 -i ens33

抓包示例

[root@centos7 ~]#tcpdump -nn dst fe80::1e55:bb34:ae1:fd08 -i ens33 -c 2
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
16:04:08.318748 IP6 fe80::20c:29ff:fe20:a3f5 > fe80::1e55:bb34:ae1:fd08: ICMP6, echo request, seq 250, length 64
16:04:09.342193 IP6 fe80::20c:29ff:fe20:a3f5 > fe80::1e55:bb34:ae1:fd08: ICMP6, echo request, seq 251, length 64
2 packets captured
2 packets received by filter
0 packets dropped by kernel

使用 ipv6 地址ping使用的是 ping6 命令
命令格式为

ping6 ipv6地址%网卡名     #要通过 "%" 指定网卡名
ping -6 ipv6地址%网卡名   #要通过 "%" 指定网卡名, ping -6 在ubuntu上无效,需要使用ping6

示例

[root@centos7 ~]#ping6 fe80::20c:29ff:fe20:a3f5%ens33
PING fe80::20c:29ff:fe20:a3f5%ens33(fe80::20c:29ff:fe20:a3f5%ens33) 56 data bytes
64 bytes from fe80::20c:29ff:fe20:a3f5%ens33: icmp_seq=1 ttl=64 time=0.265 ms
64 bytes from fe80::20c:29ff:fe20:a3f5%ens33: icmp_seq=2 ttl=64 time=0.319 ms
64 bytes from fe80::20c:29ff:fe20:a3f5%ens33: icmp_seq=3 ttl=64 time=0.510 ms
[root@centos7 ~]#ping -6 fe80::20c:29ff:fe20:a3f5%ens33 -c 2
PING fe80::20c:29ff:fe20:a3f5%ens33(fe80::20c:29ff:fe20:a3f5%ens33) 56 data bytes
64 bytes from fe80::20c:29ff:fe20:a3f5%ens33: icmp_seq=1 ttl=64 time=0.231 ms
64 bytes from fe80::20c:29ff:fe20:a3f5%ens33: icmp_seq=2 ttl=64 time=0.402 ms

通过端口范围过滤

tcpdump portrange 21-23

查看指定大小的数据包

可以查看指定大小的数据包,指定数据包的大小的时候还可以使用比较运算符。

tcpdump less 32
tcpdump greater 64
tcpdump <= 128

读/写抓取的信息从/到文件

将抓取到的数据包信息存储到文件以便将来进行分析是很必要的。文件格式为 PCAP (PEE-cap) files格式。这种文件可以被众多的应用程序解析,包括网络分析工具、入侵检测系统、当然还有tcpdump自己。

保存抓包信息到文件

使用 -w 选项写入文件(后缀是 .cap 就可以使用 wireshark 识别分析)

sudo tcpdump -i eth0 -c 100 -w catcher.cap
$ sudo tcpdump -i eth0 -c 100 -w catcher.cap
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
100 packets captured
213 packets received by filter
0 packets dropped by kernel
$ 

从文件中读取抓包信息

使用 -r 选项从文件中读取,在读取文件的时候,我们可以像正常抓包时一样使用tcpdump.需要注意的是,文件中不存在的数据是抓取不到和解析的。

tcpdump -r capture_file

示例

tcpdump -r capture_file dst 192.168.27.125
tcpdump -r capture_file src 192.168.27.100
tcpdump -r capture_file -i ens33 icmp6

以下是进阶内容

下面是 tcpdump 的一些其他进阶选项,工抓包时候进行进一步调整。

  • -A : Print each packet (minus its link level header) in ASCII. Handy for capturing web pages.
  • -X : 十六进制的ASCII编码方式输出显示包内容
  • -XX : 同 -X , 但是同时显示一台帧头部信息。
  • -D : 显示可用的接口列表。
  • -l : 显示行号输出。
  • -q : 静默输出(显示最少的信息)。
  • -t : 输出的时间戳为人类可读格式(经实验无时间戳输出)。
  • -tttt : 输出最详细的时间戳为人类可读格式。
  • -i eth0 : 监听 eth0 网卡抓包。
  • -vv : 比 -v 有更详细的输出。
  • -c : 指定的抓包的数量,之后停止。
  • -s : 指定每个抓取的数据包的字节长度,默认是262144字节. 使用 -s0 获取整个数据包的内容。
  • -S : 输出绝对数据包的绝对序列号。
  • -e : 同时获取以太帧头信息。
  • -E : 通过给定的密钥解密 IPSEC 数据流。

关于组合(或与非)

tcpdump 除了支持上面的单独的功能,还提供了更加强大的组合功能,可以让我们创造出各种组合形式来得到我们想要的结果。如果学习果编程,你会发现下面的内容似曾相识。

  • AND:and or &&
  • OR:or or ||
  • EXCEPT:not or !

裸视图输出

下面的组合输出的是:没有主机名和端口解析、使用绝对序号、人类可读时间戳的详细输出。

[root@centos7 ~]#tcpdump -ttnnvvS -i ens33 -c 1
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
1559468718.414926 IP (tos 0x10, ttl 64, id 35965, offset 0, flags [DF], proto TCP (6), length 216)192.168.27.100.22 > 192.168.27.2.14154: Flags [P.], cksum 0xb881 (incorrect -> 0x7999), seq 580563511:580563687, ack 2138271063, win 339, length 176

指定源IP和目的端口的流量

tcpdump -nnvvS src 10.5.2.3 and dst port 3389

网段到网段的流量

下面阿组合输出为:从源为192.168.0.0/16目的为10.0.0.0/8或172.16.0.0/16、不解析主机名、十六进制格式、详细级别为-v级别的抓包信息。

tcpdump -nvX src net 192.168.0.0/16 and dst net 10.0.0.0/8 or 172.16.0.0/16

到指定地址的非ICMP的流量

tcpdump dst 192.168.0.2 and src net and not icmp

指定源主机和排除目的端口的流量

下面的输出为:源为指定的主机 mars, 目的端口不是 22 端口的流量信息。

tcpdump -vv src mars and not dst port 22

关于分组的小结

我们可以看到,通过合理的组合,我们就可以得到任何想要的结果,关键是要搞清楚想要的信心,并且构建合适的查询语法。

在构建复杂查询时,可能必须使用单引号对选项进行分组,在下例中是在“()”括号下面。单引号用于告诉tcpdump忽略某些特殊字符。同样的技术也可以用于使用其他表达式(如host、port、net等)进行分组。

tcpdump 'src 10.0.2.4 and (dst port 3389 or 22)'

隔离指定TCP标记的流量

TCP 报头

# TCP 报头简图 ,一个 TCP 头为 20 字节0                            15                              31
-----------------------------------------------------------------
|          source port          |       destination port        |
-----------------------------------------------------------------
|                        sequence number                        |
-----------------------------------------------------------------
|                     acknowledgment number                     |
-----------------------------------------------------------------
|  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
-----------------------------------------------------------------
|         TCP checksum          |       urgent pointer          |
-----------------------------------------------------------------# 下面是标志位的部分,位置处在包头20字节中的第 13 字节的位置。0             7|             15|             23|             31
----------------|---------------|---------------|----------------
|  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
----------------|---------------|---------------|----------------
|               |  13th octet   |               |               |

通过二进制计算可以得到

  • FIN 的值为 1 (2^0)
  • SYN 的值为 2 (2^1)
  • RST 的值为 4 (2^2)
  • PSH 的值为 8 (2^3)
  • ACK 的值为 16(2^4)
  • URG 的值为 32(2^5)
  • ECE 的值为 64(2^6)
  • CWR 的值为 128(2^7)

TCP RST 标记的隔离

tcpdump 'tcp[13] & 4!=0'
tcpdump 'tcp[tcpflags] == tcp-rst'

TCP SYN 标记的隔离

tcpdump 'tcp[13] & 2!=0'
tcpdump 'tcp[tcpflags] == tcp-syn'

TCP ACK 和 SYN 标记的隔离

tcpdump 'tcp[13]=18'

TCP URG 标记的隔离

tcpdump 'tcp[13] & 32!=0'
tcpdump 'tcp[tcpflags] == tcp-urg'

TCP ACK 标记的隔离

tcpdump 'tcp[13] & 16!=0'
tcpdump 'tcp[tcpflags] == tcp-ack'

TCP PSH 标记的隔离

tcpdump 'tcp[13] & 8!=0'
tcpdump 'tcp[tcpflags] == tcp-psh'

TCP FIN 标记的隔离

tcpdump 'tcp[13] & 1!=0'
tcpdump 'tcp[tcpflags] == tcp-fin'

快速过滤 TCP FLAG

可以通过上文中计算出的各个标志位的对应值,直接计算出组合的值来设置组合对应的值。

Both SYN and RST Set

  • SYN 的值为 2 (2^1)
  • RST 的值为 4 (2^2)
tcpdump 'tcp[13] = 6'

过滤 HTTP的 User Agents

tcpdump -vvAls0 -i ens33| grep 'User-Agent:'
[root@centos7-scm ~]#curl --head www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 277
Content-Type: text/html
Date: Sun, 02 Jun 2019 10:42:35 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
[root@centos7-scm ~]#tcpdump -vvAls0 -i ens33| grep 'User-Agent:'
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytesUser-Agent: curl/7.29.0
User-Agent: curl/7.29.0

过滤 HTTP的 明文 HTTP 请求头

tcpdump -vvAls0 -i ens33 | grep 'GET'
[root@centos7-scm ~]#curl -X GET www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
[root@centos7-scm ~]#tcpdump -vvAls0 -i ens33 | grep 'GET'
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytesGET / HTTP/1.1
E..u@|@.@......dg..'...P601.....P...r...GET / HTTP/1.1

过滤 HTTP的 Hosts

tcpdump -vvAls0 -i ens33 | grep 'Host:'
[root@centos7-scm ~]#curl -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 277
Content-Type: text/html
Date: Sun, 02 Jun 2019 10:48:40 GMT
Etag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
[root@centos7-scm ~]#tcpdump -vvAls0 -i ens33 | grep 'Host:'
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytesHost: www.baidu.com
Host: www.baidu.com

过滤 HTTP Cookies

tcpdump -vvAls0 -i ens33 | grep -E 'Set-Cookie:|Host:|Cookie:'
[root@centos7-scm ~]#wget  www.baidu.com
--2019-06-02 19:34:49--  http://www.baidu.com/
Resolving www.baidu.com (www.baidu.com)... 220.181.38.149, 220.181.38.150
Connecting to www.baidu.com (www.baidu.com)|220.181.38.149|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2381 (2.3K) [text/html]
Saving to: ‘index.html.5’100%[==================================================================>] 2,381       --.-K/s   in 0s      2019-06-02 19:34:49 (191 MB/s) - ‘index.html.5’ saved [2381/2381]
[root@centos7-scm ~]#tcpdump -vvAls0 -i ens33 | grep -E 'Set-Cookie:|Host:|Cookie:'
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytesHost: www.baidu.com
Host: www.baidu.comSet-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/

过滤 SSH Connections

This one works regardless of what port the connection comes in on, because it’s getting the banner response.

tcpdump 'tcp[(tcp[12]>>2):4] = 0x5353482D' -i ens33
[root@centos7 ~]#tcpdump 'tcp[(tcp[12]>>2):4] = 0x5353482D' -i ens33
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
18:36:23.490464 IP gateway.fronet > centos7.ssh: Flags [P.], seq 960612390:960612432, ack 497953643, win 2053, length 42
18:36:23.502672 IP centos7.ssh > gateway.fronet: Flags [P.], seq 1:22, ack 42, win 229, length 21

过滤 DNS 流量

tcpdump -vvAs0 port 53 -i ens33
[root@centos7-scm ~]#ping www.google.com
PING www.google.com (74.86.235.236) 56(84) bytes of dat
[root@centos7-scm ~]#tcpdump -vvAs0 port 53 -i ens33
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
19:39:12.520747 IP (tos 0x0, ttl 64, id 6789, offset 0, flags [DF], proto UDP (17), length 60)centos7-scm.40966 > google-public-dns-a.google.com.domain: [bad udp cksum 0xec55 -> 0xbfb1!] 9453+ A? www.google.com. (32)
E..<..@.@.4....d.......5.(.U$............www.google.com.....
19:39:12.521795 IP (tos 0x0, ttl 64, id 6790, offset 0, flags [DF], proto UDP (17), length 66)centos7-scm.59105 > google-public-dns-a.google.com.domain: [bad udp cksum 0xec5b -> 0x3a7d!] 55476+ PTR? 8.8.8.8.in-addr.arpa. (38)
E..B..@.@.4     ...d.......5...[.............8.8.8.8.in-addr.arpa.....
19:39:12.537071 IP (tos 0x0, ttl 60, id 27911, offset 0, flags [DF], proto UDP (17), length 76)google-public-dns-a.google.com.domain > centos7-scm.40966: [udp sum ok] 9453 q: A? www.google.com. 1/0/0 www.google.com. A 74.86.235.236 (48)
E..Lm.@.<..}.......d.5...8G.$............www.google.com.................JV..
19:39:12.537087 IP (tos 0x0, ttl 48, id 0, offset 0, flags [none], proto UDP (17), length 76)google-public-dns-a.google.com.domain > centos7-scm.40966: [udp sum ok] 9453 q: A? www.google.com. 1/0/0 www.google.com. A 69.63.186.30 (48)
E..L....0..........d.5...8~.$............www.google.com.................E?..

过滤 FTP 流量

tcpdump -vvAs0 port ftp or ftp-data -i ens33

过滤NTP流量

tcpdump -vvAs0 port 123 -i ens33

过滤明文密码

tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -lA | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd= |password=|pass:|user:|username:|password:|login:|pass |user '
test@machine:~$ curl -X GET  http://www.baidu.com/?pass=123456
<!DOCTYPE html>
<!--STATUS OK--><html> ... </html>
test@machine:~$ sudo tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -lA | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd= |password=|pass:|user:|username:|password:|login:|pass |user '
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
.Q.!........
19:49:57.328294 IP 103.235.46.39.http > 192.168.27.125.47334: Flags [S.], seq 2439930931, ack 2291696402, win 8192, options [mss 1440,sackOK,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,nop,wscale 5], length 0
E..<d*@.,.xZg..'...}.P...nd3...... ..O......................
19:49:57.328365 IP 192.168.27.125.47334 > 103.235.46.39.http: Flags [.], ack 1, win 229, length 0
E..(d+@.@.dm...}g..'...P.....nd4P...rR..
19:49:57.328474 IP 192.168.27.125.47334 > 103.235.46.39.http: Flags [P.], seq 1:90, ack 1, win 229, length 89: HTTP: GET /?pass=123456 HTTP/1.1
E...d,@.@.d....}g..'...P.....nd4P...r...GET /?pass=123456 HTTP/1.1

过滤包含"邪恶位"的包

IP 包头中有 3个bit的标志位(Flag),3bit的标识字段每一位都有特定的含义,该字段主要用来分片和重组。第1个bit为保留位(Reserved Bit),一般置位0。第2个bit为不分片位(Don’t ragment),该位在置1时表示不分片。第3个bit为更多片位(More Fragment),该位表示后面是否还有更多的分片,置位1时表示后面还有,所以除了最后一片报文,其他分片报文该位全部置1。

这里指的邪恶位就是第一个bit的位置。 处在IP包头中的第6个字节位置。

tcpdump 'ip[6] & 128 != 0'

几种重要流量的抓取

本节内容参考自 tcpdump简明教程: https://github.com/mylxsw/growing-up/blob/master/doc/tcpdump%E7%AE%80%E6%98%8E%E6%95%99%E7%A8%8B.md

这里有一些重要的代码片段你可能需要,它们用于过滤指定的流量,例如畸形的或者恶意的流量。

过滤同时设置SYN和RST标识的包(这在正常情况下不应该发生)

tcpdump 'tcp[13] = 6'

过滤明文的HTTP GET请求

tcpdump 'tcp[32:4] = 0x47455420'

通过横幅文本过滤任意端口的SSH连接

tcpdump 'tcp[(tcp[12]>>2):4] = 0x5353482D'

过滤TTL小于10的包(通常情况下是存在问题或者在使用traceroute)

tcpdump 'ip[8] < 10'

过滤恶意的包

tcpdump 'ip[6] & 128 != 0'

可能出现问题的解决

在RHEL7下,如果不用-i参数指定网络接口,则会报如下错误:
tcpdump: Bluetooth link-layer type filtering not implemented

转载于:https://www.cnblogs.com/shichangming/p/10964238.html

tcpdump 用法相关推荐

  1. 抓包工具 tcpdump 用法说明

    点击上方"方志朋",选择"设为星标" 做积极的人,而不是积极废人 转自:骏马金龙 www.cnblogs.com/f-ck-need-u/p/7064286.h ...

  2. 【网络】TCP抓包|RDMA抓包|ibdump、tcpdump用法说明

    目录 一.抓包命令 ibdump 抓包命令 tcpdump抓包命令 二.RDMA抓包 Mellanox 网卡 1.ibdump 2.tcpdump (docker,Linux内核从4.9以上) 3.O ...

  3. Linux下tcpdump用法

    根据使用者的定义对网络上的数据包进行截获的包分析工具.tcpdump将网络中传送的数据包的"头"完全截获下来提供分析.它支持针对网络层.协议.主机.网络或端口的过滤,并提供了and ...

  4. Linux系统安全工具tcpdump用法

    1.安装     yum install tcpdump -y 2.监视数据包     tcpdump -i eth0      --监控本机的eth0网卡          tcpdump host ...

  5. linux过滤端口抓包_Linux抓包工具tcpdump使用总结,WireShark的过滤用法

    tcpdump与WireShark是Linux下的两个常用,功能强大的抓包工具,下面列出这两个工具的简单用法. tcpdump用法 tcpdump用法: sudo tcpdump -i ens33 s ...

  6. linux --- TCPdump 工具

    一.TCPdump TCPdump[dump the traffic on a network],根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的&qu ...

  7. 【计算机网络】 0、各网络命令 + tcpdump + Wireshark、抓包实战、TCP 握手挥手、防火墙、保活、MTU

    文章目录 一.各层网络工具 应用层 找到服务器的 IP 查接口.对象的耗时 删除指定网站的Cookie 表示层.会话层 tcpdump.wireshard 传输层 telnet: 路径可达性测试 nc ...

  8. android中使用tcpdump拦截分析网络数据包

    1.下载tcpdump http://pan.baidu.com/s/1c0vkU2k 2.通过adb命令上传到手机里 adb push tcpdump /system/bin 3.adb shell ...

  9. 聊一聊Java 泛型中的通配符 T,E,K,V,?

    点击上方"方志朋",选择"设为星标" 回复"1024"获取独家整理的学习资料 作者:glmapper juejin.im/post/5d57 ...

最新文章

  1. SpringBoot项目的几种创建方式,启动、和访问
  2. python多进程打印输出_多进程打印日志
  3. 关于health的原理
  4. 【腾讯优测干货分享】从压测工具谈并发、压力、吞吐量
  5. 慌的一批!新手妹子一个命令把公司服务器数据删没了...
  6. selenium WebDriverWait类等待机制的实现
  7. 别乱用,这样打日志定位 Bug 又快又准!
  8. 用贝叶斯定理解决三门问题并用Python进行模拟(Bayes‘ Rule Monty Hall Problem Simulation Python)
  9. 【原】IOS合并lib(.a)库的终极可用方法(可用于解决duplicate symbol静态库冲突)
  10. stm31.js下拉菜单说明(转)
  11. a人工智能b大数据c云计算_解读云计算、大数据、AI 对数据中心的影响,最全面的解说分析!...
  12. 如何挑选和购买适合自己的示波器
  13. 周五送码 | MS08067实验室攻防平台
  14. vue中使用highCharts的drilldown钻取图、3D等图
  15. 文件生成Md5值方法
  16. Ruby编程语言简介
  17. css字体设置为白色,css怎么将字体设置成白色
  18. Tableau实现世界GDP排名动态图
  19. 基于动态空间滤波的受损EEG信号的鲁棒性学习
  20. vue为什么需要nodejs 的环境

热门文章

  1. 深度学习(31)随机梯度下降九: Himmelblau函数优化实战
  2. uilabel 自行撑开高度_UILabel文本高度计算的那些事儿
  3. 疯子的算法总结(六) 复杂排序算法 ② 桶排序
  4. 微软NNI---AutoFeatureENG
  5. 数据库设计新手容易掉进的陷阱(不断更新中)
  6. React.js开发生态系统概览 [译-转]
  7. 机器学习 数据模型_使用PyCaret将机器学习模型运送到数据—第二部分
  8. ci/cd heroku_在Heroku上部署Dash或Flask Web应用程序。 简易CI / CD。
  9. PC如何控制device进入suspend模式
  10. 记住北京历史上的灾难