系统吧 专业的电脑操作系统,支持重装各种原版系统xp/win7/win8/win10 这个系统怎么样?试试系统吧系统,体验办公系统畅快愉悦感。 各种电脑系统安装过程一样,神一般的畅快!
-->
当前位置:主页 > 电脑技术 >

超详细的网络抓包神器 tcpdump 使用指南(6)

作者:谢金冉 分类:电脑技术 发布时间:2021-07-10 05:52:00

过滤 Nmap NSE 脚本测试结果 本例中 Nmap NSE 测试脚本  http-enum.nse  用来检测 HTTP 服务的合法 URL。 在执行脚本测试的主机上: $ nmap -p 80 --script=http-enum.nse t...

过滤 Nmap NSE 脚本测试结果

本例中 Nmap NSE 测试脚本 http-enum.nse 用来检测 HTTP 服务的合法 URL。

在执行脚本测试的主机上:

$ nmap -p 80 --script=http-enum.nse targetip

在目标主机上:

$ tcpdump -nn port 80 | grep "GET /"GET /w3perl/ HTTP/1.1GET /w-agora/ HTTP/1.1GET /way-board/ HTTP/1.1GET /web800fo/ HTTP/1.1GET /webaccess/ HTTP/1.1GET /webadmin/ HTTP/1.1GET /webAdmin/ HTTP/1.1

抓取 DNS 请求和响应

向 Google 公共 DNS 发起的出站 DNS 请求和 A 记录响应可以通过 tcpdump 抓取到:

$ tcpdump -i wlp58s0 -s0 port 53tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on wlp58s0, link-type EN10MB (Ethernet), capture size 262144 bytes14:19:06.879799 IP test.53852 > google-public-dns-a.google.com.domain: 26977+ [1au] A? play.google.com. (44)14:19:07.022618 IP google-public-dns-a.google.com.domain > test.53852: 26977 1/0/1 A 216.58.203.110 (60)

抓取 HTTP 有效数据包

抓取 80 端口的 HTTP 有效数据包,排除 TCP 连接建立过程的数据包(SYN / FIN / ACK):

$ tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

将输出内容重定向到 Wireshark

通常 Wireshark(或 tshark)比 tcpdump 更容易分析应用层协议。一般的做法是在远程服务器上先使用 tcpdump 抓取数据并写入文件,然后再将文件拷贝到本地工作站上用 Wireshark 分析。

还有一种更高效的方法,可以通过 ssh 连接将抓取到的数据实时发送给 Wireshark 进行分析。以 MacOS 系统为例,可以通过 brew cask install wireshark 来安装,然后通过下面的命令来分析:

$ ssh root@remotesystem 'tcpdump -s0 -c 1000 -nn -w - not port 22' | /Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i -

例如,如果想分析 DNS 协议,可以使用下面的命令:

$ ssh root@remotesystem 'tcpdump -s0 -c 1000 -nn -w - port 53' | /Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i -

抓取到的数据:

超详细的网络抓包神器 tcpdump 使用指南(6)

-c 选项用来限制抓取数据的大小。如果不限制大小,就只能通过 ctrl-c 来停止抓取,这样一来不仅关闭了 tcpdump,也关闭了 wireshark。

找出发包最多的 IP

找出一段时间内发包最多的 IP,或者从一堆报文中找出发包最多的 IP,可以使用下面的命令:

$ tcpdump -nnn -t -c 200 | cut -f 1,2,3,4 -d '.' | sort | uniq -c | sort -nr | head -n 20tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on enp7s0, link-type EN10MB (Ethernet), capture size 262144 bytes200 packets captured261 packets received by filter0 packets dropped by kernel    108 IP 10.10.211.181     91 IP 10.10.1.30      1 IP 10.10.1.50
cut -f 1,2,3,4 -d '.' : 以 . 为分隔符,打印出每行的前四列。即 IP 地址。sort | uniq -c : 排序并计数sort -nr : 按照数值大小逆向排序

抓取用户名和密码

本例将重点放在标准纯文本协议上,过滤出于用户名和密码相关的报文:

$ tcpdump port http or port ftp or port smtp or port imap or port pop3 or port telnet -l -A | egrep -i -B5 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user '

抓取 DHCP 报文

最后一个例子,抓取 DHCP 服务的请求和响应报文,67 为 DHCP 端口,68 为客户机端口。

xp 更多>>
win7 更多>>
win8 更多>>
win10 更多>>
U盘 更多>>
电脑技术 更多>>
网站地图 | 豫ICP备2021035069号-4 | 友情链接qq:191064436
系统吧

版权所有 © 2012-2023 系统吧 免责声明:本站资源均收集于互联网,其著作权归原作者所有,如果有侵犯您权利的资源,请来信告知,我们将及时删除相应资源。