标签:and http 其它 分析工具 sse 常见 利用 语句 byte
? TcpDump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮助你去掉无用的信息。tcpdump就是一种免费的网络分析工具,尤其其提供了源代码,公开了接口,因此具备很强的可扩展性,对于网络维护和入侵者都是非常有用的工具。tcpdump存在于基本的FreeBSD系统中,由于它需要将网络界面设置为混杂模式,普通用户不能正常执行,但具备root权限的用户可以直接执行它来获取网络上的信息。因此系统中存在网络分析工具主要不是对本机安全的威胁,而是对网络上的其他计算机的安全存在威胁。
tcpdump
? 表达式是一个正则表达式,tcpdump利用他过滤报文的条件,如果一个报文满足表达式的条件,则这个报文将会被捕获。如果表达式为空,则会捕获所有所有的信息包
表达式类型:
抓取当前主机所有数据包,tcpdump默认在当前终端运行
[root@mweb07 ~]# tcpdump
tcpdump: WARNING: eth0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
10:03:25.585291 IP 172.20.10.2.hsrp > all-routers.mcast.net.hsrp: HSRPv0-hello 20: state=active group=10 addr=172.20.10.1
10:03:26.680044
抓取100个数据包,并且在指定的文件存放起来,默认tcpdump文件是不允许直接查看的
[root@mweb07 ~]# tcpdump -c 100 -w tcpdump.out
tcpdump: WARNING: eth0: no IPv4 address assigned
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
100 packets captured # 抓取100个包后,他就会自动停止
100 packets received by filter
0 packets dropped by kernel
读取-w参数导出的文件
[root@mweb07 ~]# tcpdump -r 443_tcpdump.out
reading from file 443_tcpdump.out, link-type EN10MB (Ethernet)
10:22:49.771433 IP 180.168.69.242.50838 > mweb07.https: Flags [.], seq 1094068907:1094068908, ack 4179967795, win 16537, length 1
10:22:49.771447 IP mweb07.https > 180.168.69.242.50838: Flags [R], seq 4179967795, win 0, length 0
10:22:51.525702 IP 180.168.69.242.50836 > mweb07.https: Flags [F.], seq 932060733, ack 2342938202, win 16344, length 0
抓取6379端口的100个包
[root@mweb07 ~]# tcpdump -i bond0 -c 100 -w 443_tcpdump.out tcp port 443
tcpdump: listening on bond0, link-type EN10MB (Ethernet), capture size 65535 bytes
100 packets captured
102 packets received by filter
0 packets dropped by kernel
抓取源地址为180.168.69.242,端口为443的数据包
[root@mweb07 ~]# tcpdump -i bond0 -c 3 -w 443_tcpdump.out src 180.168.69.242 and tcp port 443
tcpdump: listening on bond0, link-type EN10MB (Ethernet), capture size 65535 bytes
3 packets captured
3 packets received by filter
0 packets dropped by kernel
抓取指定主机的数据包
# 抓取指定主机的数据包
[root@mweb07 ~]# tcpdump -i bond0 -c 10 host 172.20.10.17
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond0, link-type EN10MB (Ethernet), capture size 65535 bytes
10:28:40.375233 IP mweb07.34822 > mweb08.vrace: Flags [P.], seq 2258399624:2258400017, ack 3133621198, win 18960, options [nop,nop,TS val 941802562 ecr 941809211], length 393
10:28:40.375935 IP mweb08.vrace > mweb07.34822: Flags [.], seq 1:4345, ack 393, win 2841, options [nop,nop,TS val 941811328 ecr 941802562], length 4344
10:28:40.375945 IP mweb07.34822 > mweb08.vrace: Flags [.], ack 4345, win 18960, options [nop,nop,TS val 941802563 ecr 941811328], length 0
10:28:40.375957 IP mweb08.vrace > mweb07.34822: Flags [.], seq 4345:7241, ack 393, win 2841, options [nop,nop,TS val 941811328 ecr 941802562], length 2896
10:28:40.375960 IP mweb07.34822 > mweb08.vrace: Flags [.], ack 7241, win 18960, options [nop,nop,TS val 941802563 ecr 941811328], length 0
10:28:40.376008 IP mweb08.vrace > mweb07.34822: Flags [.], seq 7241:10137, ack 393, win 2841, options [nop,nop,TS val 941811328 ecr 941802562], length 2896
10:28:40.376012 IP mweb07.34822 > mweb08.vrace: Flags [.], ack 10137, win 18960, options [nop,nop,TS val 941802563 ecr 941811328], length 0
10:28:40.376015 IP mweb08.vrace > mweb07.34822: Flags [P.], seq 10137:10298, ack 393, win 2841, options [nop,nop,TS val 941811328 ecr 941802562], length 161
10:28:40.376017 IP mweb07.34822 > mweb08.vrace: Flags [.], ack 10298, win 18960, options [nop,nop,TS val 941802563 ecr 941811328], length 0
10:28:40.397701 IP mweb07.46871 > mweb08.6379: Flags [P.], seq 2597564002:2597564092, ack 617045751, win 1260, options [nop,nop,TS val 941802584 ecr 941811100], length 90
10 packets captured
10 packets received by filter
0 packets dropped by kernel
# 可以发现,如果两台主机之间没有通信,是无法抓取的
[root@mweb07 ~]# tcpdump -i bond0 -c 10 host 172.20.10.10
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on bond0, link-type EN10MB (Ethernet), capture size 65535 bytes四:日常场景
标签:and http 其它 分析工具 sse 常见 利用 语句 byte
原文地址:https://www.cnblogs.com/GXLo/p/9813742.html