RedGuard - C2前置流量控制工具
字数 1362 2025-08-27 12:33:31
RedGuard - C2前置流量控制工具教学文档
0x00 工具介绍
RedGuard是一款C2设施前置流量控制工具,使用Go语言开发,具有轻量设计、高效流量交互和可靠兼容性等特点。主要解决红蓝对抗中C2基础设施隐匿问题,通过流量控制功能拦截恶意分析流量。
核心功能
- 拦截Blue Team、AVS、EDR和网络空间搜索引擎的检查
- 防止云沙箱环境下的恶意分析
- 阻止重放攻击,实现混淆上线
- 限制访问IP白名单
- 防范网络空间测绘扫描识别
- 支持多C2服务器前置流量控制
- 基于IP归属地的地域限制
- 请求拦截日志分析
- 自定义合法交互时间段
- Malleable C2 Profile解析器
- 内置安全厂商IP黑名单
- 自定义SSL证书和重定向URL
0x01 安装与初始化
安装方法
git clone https://github.com/wikiZ/RedGuard.git
cd RedGuard
go build -ldflags "-s -w" # 可使用upx压缩减小体积
chmod +x ./RedGuard
./RedGuard
初始化配置
首次运行会在用户目录生成配置文件:.RedGuard_CobaltStrike.ini
配置文件包含:
- cert配置:HTTPS流量交互证书信息
- proxy配置:反向代理流量控制选项
证书生成在cert-rsa/目录下,可使用自定义证书覆盖ca.crt和ca.key
每次启动会更新随机TLS JARM指纹,防止特征关联
0x02 配置说明
命令行参数
./RedGuard -h
Usage of ./RedGuard:
-allowIP string Proxy Requests Allow IP (default "*")
-allowLocation string Proxy Requests Allow Location (default "*")
-allowTime string Proxy Requests Allow Time (default "*")
-common string Cert CommonName (default "*.aliyun.com")
-country string Cert Country (default "CN")
-dns string Cert DNSName
-drop string Proxy Filter Enable DROP (default "false")
-host string Set Proxy HostTarget
-http string Set Proxy HTTP Port (default ":80")
-https string Set Proxy HTTPS Port (default ":443")
-ip string IPLookUP IP
-locality string Cert Locality (default "HangZhou")
-location string IPLookUP Location (default "风起")
-malleable string Set Proxy Requests Filter Malleable File (default "*")
-organization string Cert Organization (default "Alibaba (China) Technology Co., Ltd.")
-redirect string Proxy redirect URL (default "https://360.net")
-type string C2 Server Type (default "CobaltStrike")
-u Enable configuration file modification
0x03 工具使用
基础拦截机制
非法请求(无正确HOST请求头)会被拦截,默认重定向到https://360.net
拦截方式配置
-
重定向拦截(默认):
- 返回状态码200
- 从指定URL获取响应内容
- 配置文件设置:
Redirect = https://example.com
-
DROP拦截:
- 直接关闭HTTP连接
- 配置文件设置:
DROP = true - 命令行修改:
./RedGuard -u --drop true
代理端口修改
修改配置文件:
Port_HTTPS = :443 # HTTPS反向代理端口
Port_HTTP = :80 # HTTP反向代理端口
日志记录
拦截日志保存在RedGuard.log中
请求地域限制
配置示例:
AllowLocation = 济南,北京
IP归属地查询:
./RedGuard --ip 111.14.218.206
./RedGuard --ip 111.14.218.206 --location shandong
基于白名单拦截
配置示例:
AllowIP = 172.16.1.1,192.168.1.1
基于时间段拦截
配置示例:
AllowTime = 8:00 - 21:00 # 仅允许8:00-21:00进行流量交互
Malleable Profile支持
指定C2 Malleable配置文件路径:
MalleableFile = /path/to/Malleable.profile
推荐使用风起编写的profile:
https://github.com/wikiZ/CobaltStrike-Malleable-Profile
0x04 应用案例
对抗网络空间测绘
-
DROP模式:
- 测绘探针请求会被直接关闭连接
- 显示端口未开放
-
重定向模式:
- 测绘探针会收到重定向响应
- 防止目录扫描
域前置实现
-
传统域前置:
- 全站加速回源地址设置为反向代理端口
- HTTPS HOST头需与全站加速域名一致
-
自建域前置:
- 多个反向代理节点配置相同HOST头
- 指向后端真实C2服务器
- 防火墙仅开放代理端口
CobaltStrike上线配置
监听器设置:
- 上线端口设置为RedGuard反向代理端口
- 监听端口为本机实际上线端口
示例配置:
{
"360.net": "http://127.0.0.1:8080",
"360.com": "https://127.0.0.1:4433"
}
0x05 开发者信息
开发者:风起
相关项目:Kunyu (https://github.com/knownsec/Kunyu)
安全客主页:https://www.anquanke.com/member.html?memberId=148652
0x06 社区支持
- 提交issue:项目GitHub页面
- 联系作者:添加WeChat