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"

相关推荐
群联云防护小杜8 分钟前
深度隐匿源IP:高防+群联AI云防护防绕过实战
运维·服务器·前端·网络·人工智能·网络协议·tcp/ip
惜.己12 分钟前
使用python读取json数据,简单的处理成元组数组
开发语言·python·测试工具·json
_丿丨丨_5 小时前
XSS(跨站脚本攻击)
前端·网络·xss
一只栖枝6 小时前
HCIA-Security 认证精讲!网络安全理论与实战全掌握
网络·web安全·网络安全·智能路由器·hcia·it·hcia-security
FileLink跨网文件交换7 小时前
文件摆渡系统十大软件|文件摆渡系统如何构建网络安全呢?
网络
晨欣9 小时前
大型语言模型(LLM)在网络安全中最具商业价值的应用场景(Grok3 回答 DeepSearch模式)
网络·web安全·语言模型
有书Show10 小时前
个人IP的塑造方向有哪些?
网络·网络协议·tcp/ip
HHRL-yx10 小时前
C++网络编程 5.TCP套接字(socket)通信进阶-基于多线程的TCP多客户端通信
网络·c++·tcp/ip
迈威通信10 小时前
接口黑洞?破!安全堡垒?筑!冰火炼狱?战!MES7114W终极掌控
网络·安全
baynk11 小时前
wireshark的常用用法
网络·测试工具·wireshark·ctf