---
title: "53 - DNS"
weight: 53
date: "2026-03-09T09:23:30+08:00"
lastmod: "2026-03-10T13:26:55+08:00"
---

💡 **学习提示**: 本文档介绍 **53 - DNS** 的渗透测试方法，适合信息安全初学者和从业人员参考。

⚠️ **法律声明**: 本文档仅供学习和授权测试使用。未经授权的系统测试可能违反法律法规。

---

## 53 - DNS 服务

### 基本信息

**DNS (Domain Name System，域名系统)** 是互联网的核心服务，负责将域名解析为 IP 地址。DNS 使用 UDP/TCP 53 端口，是网络侦察和信息收集的重要目标。

**默认端口:** 53/UDP (查询), 53/TCP (区域传输)

```
PORT   STATE SERVICE
53/udp open  domain
53/tcp open  domain
```

**常见 DNS 服务器软件:**
- **BIND** - 最流行的开源 DNS 服务器
- **Windows DNS** - Windows Server 内置
- **Unbound** - 轻量级递归解析器
- **PowerDNS** - 高性能 DNS 服务器
- **CoreDNS** - 云原生 DNS 服务器

### 信息收集

#### 基本查询

```bash
# 查询 A 记录
nslookup example.com <DNS_IP>
dig @<DNS_IP> example.com A

# 查询 MX 记录
dig @<DNS_IP> example.com MX

# 查询 TXT 记录
dig @<DNS_IP> example.com TXT

# 反向查询
dig @<DNS_IP> -x 8.8.8.8
```

#### 区域传输

```bash
# 尝试区域传输
dig @<DNS_IP> example.com AXFR
host -t axfr example.com <DNS_IP>

# 使用 Nmap
nmap --script dns-zone-transfer --script-args dns-zone-transfer.domain=example.com -p 53 <DNS_IP>
```

#### 子域名枚举

```bash
# dnsenum
dnsenum --dnsserver <DNS_IP> --enum -p 0 -s 0 -o subdomains.txt -f subdomains-1000.txt example.com

# dnsrecon
dnsrecon -D subdomains-1000.txt -d example.com -n <DNS_IP>

# dnscan (递归爆破)
dnscan -d example.com -r -w subdomains-1000.txt
```

#### 反向 DNS 枚举

```bash
# dnsrecon 反向枚举
dnsrecon -r 192.168.1.0/24 -n <DNS_IP>

# reverse-scan 工具
# https://github.com/amine7536/reverse-scan
```

#### Active Directory 枚举

```bash
# 查询 AD 相关记录
dig -t _gc._tcp.lab.domain.com
dig -t _ldap._tcp.lab.domain.com
dig -t _kerberos._tcp.lab.domain.com

# nslookup
nslookup -type=srv _kerberos._tcp.domain.com
```

### 常见攻击

#### 1. DNS 缓存投毒

```bash
# 攻击者伪造 DNS 响应
# 将恶意 IP 注入 DNS 缓存
```

#### 2. DNS 隧道

```bash
# 使用 DNS 协议传输数据
dnscat2
iodine
```

#### 3. DDoS 放大攻击

```bash
# 如果 DNS 递归开启，可能被用于放大攻击
# 检查递归是否开启
dig google.com A @<DNS_IP>
# 查看响应中是否有 "ra" (recursion available) 标志
```

#### 4. DNSSEC 枚举

```bash
# 使用 NSEC 记录枚举子域名
nmap -sSU -p53 --script dns-nsec-enum \
  --script-args dns-nsec-enum.domains=example.com \
  <DNS_IP>
```

### 搜索引擎语法

#### FOFA

```bash
# FOFA 搜索语法
port="53" && protocol="dns"
port="53" && service="dns"
app="BIND"
app="PowerDNS"
```

#### Shodan

```bash
# Shodan 搜索语法
port:53 dns
port:53 product:"BIND"
port:53 product:"PowerDNS"
```

#### ZoomEye

```bash
# ZoomEye 搜索语法
port:53 service:dns
app:"BIND"
app:"PowerDNS"
```

### 防御建议

- ✅ 禁用不必要的区域传输
- ✅ 限制递归查询（仅对可信客户端）
- ✅ 部署 DNSSEC
- ✅ 使用响应速率限制 (RRL)
- ✅ 监控异常 DNS 流量
- ✅ 定期更新 DNS 服务器软件
- ✅ 分离权威和递归 DNS 服务

---

## 📖 参考资料

- [HackTricks - 53-dns](https://book.hacktricks.wiki/en/network-services-pentesting/53-dns.html)
- dnsrecon: https://github.com/darkoperator/dnsrecon
- dnsenum: https://github.com/fwaeytens/dnsenum
- OWASP DNS Security: https://cheatsheetseries.owasp.org/cheatsheets/DNS_Security_Cheat_Sheet.html
