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"

相关推荐
上海云盾安全满满28 分钟前
高防IP线路质量重要吗
网络·网络协议·tcp/ip
hoududubaba1 小时前
ORAN共享小区的基本概念
网络·网络协议
山峰哥2 小时前
数据库工程核心:SQL调优让查询效率飙升的实战密码
网络·汇编·数据库·sql·编辑器
梁辰兴4 小时前
计算机网络基础:网络地址转换
网络·计算机网络·计算机·nat·计算机网络基础·梁辰兴·网络地址转换协议
Q16849645155 小时前
红帽Linux-进程、ssh、网络、软件包、文件系统
linux·运维·网络
tobias.b5 小时前
408真题解析-2009-39-网络-TCP拥塞控制
网络·网络协议·tcp/ip·计算机考研·408考研·408真题解析
数通工程师5 小时前
IPv4和IPv6 地址分配:从划分到工具全解析
网络·网络协议·tcp/ip·华为
小白电脑技术6 小时前
玩客云OneCloud插入内存卡之后,开机自动挂载教程
网络·电脑
南烟斋..6 小时前
嵌入式系统(51单片机)核心外设详解:UART通信与DS18B20温度采集
linux·运维·网络
e***98576 小时前
跨平台虚拟机网络故障排查指南
运维·网络