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"

相关推荐
Bruce_Liuxiaowei1 小时前
MQTT协议在物联网环境中的安全风险与防范指南
运维·网络·物联网·安全·网络安全
Paul_09201 小时前
golang面经——内存相关模块
服务器·网络·golang
yenggd1 小时前
vxlan-bgp-evnp分布式网关配置案例
网络·分布式·华为
CiLerLinux6 小时前
第四十九章 ESP32S3 WiFi 路由实验
网络·人工智能·单片机·嵌入式硬件
摩羯座-185690305948 小时前
爬坑 10 年!京东店铺全量商品接口实战开发:从分页优化、SKU 关联到数据完整性闭环
linux·网络·数据库·windows·爬虫·python
YoungLime8 小时前
DVWA靶场之十三:CSP 绕过(Content Security Policy (CSP) Bypass)
网络·安全·web安全
2301_772093569 小时前
tuchuang_后端_前端_注册登录
数据库·后端·网络协议·mysql·wireshark
芝士小宇9 小时前
tcp 服务器的设计思路
服务器·网络·tcp/ip
智能化咨询10 小时前
【深度学习计算机视觉】10:转置卷积实战进阶——破解棋盘效应与工业级应用
网络
cililin10 小时前
第4章 文件管理
linux·服务器·网络·操作系统·unix