Wireshark过滤DNS协议包语法实战

背景

现网DNS服务器发现CPU突增,发现有可能是客户恶意发起的随机子域名扫描,对服务器进行抓包分析,记录下当时的操作。

抓包

执行命令 tcpdump -iany port 53 and host '$ip' -nnv -w $ip.pcap进行抓包导出到本地,使用Wireshark进行打开分析

使用sz ip.pcap命令导出到本地

分析

Wireshark有自带的统计功能,非常好用,这里使用如下:

1、先找出请求量最大的客户端IP:

2、根据客户端IP找出请求量大的域名有哪些
1.模糊匹配域名

使用命令 ip.src == ip && dns.qry.name contains "域名"这个是模糊匹配域名
2.精确匹配域名
ip.src == ip && dns.qry.name == "域名"

处理

找出域名后,可以利用iptables对域名进行限频或者封禁
封禁
iptables -I INPUT -p udp --dport 53 -m string --hex-string "ipt|03|aol|03|com" --algo bm --icase --to 1480 -j DROP
iptables -I INPUT -p udp --dport 53 -m string --hex-string "|2a 2e 62 79 64 2a|" --algo bm --icase -j DROP
限频
iptables -I INPUT -p udp --dport 53 -m string --hex-string "|2a 2e 62 79 64 2a|" --algo bm --icase -m limit --limit 1000/s --limit-burst 100 -j ACCEPT

更多命令

1、dns.flags.response

dns.flags.response 的值为 0 时

表示该数据包是一个 DNS 查询

dns.flags.response 的值为 1 时

表示该数据包是一个 DNS 响应


2、包含9.146.178.132这个地址的
ip.addr == 9.146.178.132

3、指定目标地址
ip.dst == 221.182.227.3

4、指定请求方法
ip.addr == 113.31.104.71 and http.request.method == POST

5、根据http协议过滤包内容
http.request.method == POST and ip.src != 11.142.163.186 and http contains "vspRegistrantUpload"

6、过滤数据包内容包含的字符串
http.request.method == POST and ip.src != 11.142.163.186 and frame contains "cnRegistrantQuery" "

7、过滤时间
http.date >= "Tue, 15 Nov 2022 07:05:36 GMT" && http.date <= "Tue, 15 Nov 2022 07:05:37 GMT"

相关推荐
一只栖枝4 小时前
网络安全 vs 信息安全的本质解析:数据盾牌与网络防线的辩证关系关系
网络·网络安全·信息安全·it·信息安全认证
CertiK4 小时前
CertiK《Hack3d:2025年第二季度及上半年Web3.0安全报告》(附报告全文链接)
网络
一只小鱼儿吖6 小时前
进程代理单窗口单IP技术:原理、应用与实现
网络·网络协议·tcp/ip
稳联技术6 小时前
Ethernet IP与Profinet共舞:网关驱动绿色工业的智慧脉动
网络·网络协议·tcp/ip
学习3人组6 小时前
CentOS配置网络
linux·网络·centos
~山有木兮7 小时前
LiteHub中间件之限流实现
网络·http·中间件
cui_win7 小时前
【网络】Linux 内核优化实战 - net.core.flow_limit_table_len
linux·运维·网络
BD_Marathon8 小时前
虚拟机网络检查
网络
旷世奇才李先生9 小时前
Selenium 安装使用教程
selenium·测试工具
cocologin10 小时前
RIP 技术深度解析
运维·网络·网络协议