x-glacier/kali-pentest / kali-pentest-zh
kali-pentest-zh
Flagged通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。
references/exploitation/tools/dns2tcp.md
View on GitHub# dns2tcp
- **Category**: Exploitation / DNS Tunneling
- **Risk Level**: 🔴 High
---
## 描述
dns2tcp 是一个 DNS 隧道工具,将 TCP 流量封装在 DNS 查询和响应中。它用于绕过允许 DNS 流量但阻止其他协议的防火墙和网络限制。该工具由两个组件组成:
- `dns2tcpd` — 服务端守护进程,监听传入的 DNS 隧道连接
- `dns2tcpc` — 客户端,通过 DNS 发起隧道连接
dns2tcp 可以通过 DNS 隧道传输 SSH、HTTP 或任何 TCP 服务。它支持基于密钥的认证和可选的流量压缩。该工具使用 TXT 和 KEY 记录类型进行数据传输。
## 安装
```bash
sudo apt install dns2tcp
```
## 参数说明
### dns2tcpd(服务端)
| 参数 | 说明 |
|------|------|
| `-F` | 在前台运行(不进行守护进程化) |
| `-f` | 配置文件路径 |
| `-d` | 调试级别(1 = 基本,2 = 详细,3 = 冗余) |
| `-p` | PID 文件路径 |
| `-i` | 监听 IP 地址 |
| `-l` | 监听端口(默认:53) |
### dns2tcpc(客户端)
| 参数 | 说明 |
|------|------|
| `-c` | 启用压缩 |
| `-z` | 用于隧道的域名 |
| `-k` | 认证共享密钥 |
| `-e <cmd>` | 在客户端执行的程序 |
| `-l` | 隧道端点的本地监听端口 |
| `-r` | 要连接的远程资源(在服务端配置中定义) |
| `-d` | 调试级别(1 = 基本,2 = 详细,3 = 冗余) |
| `-f` | 配置文件路径 |
| `-t` | DNS 服务器最大应答延迟秒数(默认:3) |
| `-T` | DNS 请求类型(`KEY` 或 `TXT`) |
## 常用命令
### 服务端配置文件
```ini
# /etc/dns2tcpd.conf
listen = 0.0.0.0
port = 53
user = nobody
chroot = /tmp
domain = tunnel.example.com
key = s3cr3tK3y
resources = ssh:127.0.0.1:22, http:127.0.0.1:8080
```
### 启动服务端
```bash
# 在前台启动服务端并输出调试信息
dns2tcpd -F -f /etc/dns2tcpd.conf -d 1
# 以守护进程方式启动服务端
dns2tcpd -f /etc/dns2tcpd.conf
```
### 客户端:通过 DNS 隧道 SSH
```bash
# 通过 DNS 创建到远程 SSH 的本地隧道
dns2tcpc -z tunnel.example.com -k s3cr3tK3y -r ssh -l 2222 ns.example.com
# 通过隧道连接
ssh -p 2222 user@127.0.0.1
```
### 客户端:通过 DNS 隧道 HTTP
```bash
# 通过 DNS 创建到远程 HTTP 的本地隧道
dns2tcpc -z tunnel.example.com -k s3cr3tK3y -r http -l 8080 ns.example.com
```
### 客户端:启用压缩和调试
```bash
# 启用压缩和冗余调试输出
dns2tcpc -c -z tunnel.example.com -k s3cr3tK3y -r ssh -l 2222 -d 3 ns.example.com
```
### 客户端:指定 DNS 请求类型
```bash
# 使用 TXT 记录(可能绕过某些过滤器)
dns2tcpc -T TXT -z tunnel.example.com -k s3cr3tK3y -r ssh -l 2222 ns.example.com
# 使用 KEY 记录
dns2tcpc -T KEY -z tunnel.example.com -k s3cr3tK3y -r ssh -l 2222 ns.example.com
```
### 客户端配置文件
```ini
# ~/.dns2tcprc
domain = tunnel.example.com
resource = ssh
local_port = 2222
key = s3cr3tK3y
debug_level = 1
server = ns.example.com
```
```bash
# 使用客户端配置文件
dns2tcpc -f ~/.dns2tcprc
```
## 注意事项
1. 隧道运行需要一个专用域名,其 NS 记录指向服务端
2. DNS 隧道与直连相比速度较慢;预期吞吐量在 5-50 KB/s 范围内,取决于网络状况
3. 使用 `-d 3` 排查连接问题;这将显示所有 DNS 请求/响应的详细信息
4. 共享密钥(`-k`)在客户端和服务端之间必须匹配
5. 服务端定义的资源决定了哪些服务可以被隧道传输;客户端只能连接到预配置的资源
6. 压缩(`-c`)可以提高可压缩数据的吞吐量,但会增加 CPU 开销
7. 某些 DNS 解析器可能会缓存或修改响应,导致隧道中断;尽可能直接连接到权威 DNS 服务器
8. IDS/IPS 系统可能通过分析查询频率和 payload 大小来检测 DNS 隧道
---
## 官方参考
- Kali Tools: https://www.kali.org/tools/dns2tcp/
- GitHub: https://github.com/alex-sector/dns2tcp
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |