InfraGuard 是一个命令与控制(C2)重定向代理和管理器,可保护你的红队基础设施免受威胁归因。
红队基础设施跟踪器与C2重定向器——RedWarden的现代替代方案。
InfraGuard位于互联网与你的C2团队服务器之间,根据你的可塑C2配置文件验证每个入站请求,并阻止任何不符合要求的流量。扫描器、机器人和蓝队探测会被重定向到诱饵站点,而合法的beacon流量则通过代理转发至你的团队服务器。


mythic_file后端在干净的URL上代理Mythic的/direct/download/{uuid};支持固定UUID或代理模式;访问控制由InfraGuard的过滤栈提供/metrics端点暴露请求计数器、上游延迟直方图、熔断器状态、情报源新鲜度和活动连接on_event钩子、每插件配置和事件过滤.env文件.htaccess和robots.txt文件导入IP阻止列表和User-Agent模式.env文件;${VAR}语法适用于所有配置值和密钥查看Wiki页面了解安装方法
infraguard --version Show version infraguard --help Show help
infraguard run -c config.yaml Start the reverse proxy infraguard run -c config.yaml --port 8443 Override listen port infraguard run -c config.yaml --host 0.0.0.0 Override bind address
infraguard dashboard -c config.yaml Start the web dashboard infraguard dashboard -c config.yaml --port 9090 Override dashboard port
infraguard tui Launch TUI with login screen infraguard tui --url http://host:8080 --token TOK Auto-connect to dashboard infraguard tui -c config.yaml Read URL/token from config
infraguard command-post -c command-post.yaml Start multi-instance dashboard infraguard command-post --instance name:url:token Add instance via CLI (repeatable)
infraguard profile parse Parse and display a C2 profile infraguard profile parse --format json Output as JSON infraguard profile parse --type brute_ratel Force profile type infraguard profile convert -o out.json Convert profile to JSON
infraguard ingest <files...> Ingest .htaccess/robots.txt rules infraguard ingest <files...> --format blocklist Output as IP blocklist infraguard ingest <files...> --format json Output as JSON infraguard ingest <files...> -o banned_ips.txt Write blocklist to file
infraguard generate nginx -c config.yaml Generate Nginx config infraguard generate caddy -c config.yaml Generate Caddyfile infraguard generate apache -c config.yaml Generate Apache VirtualHost
infraguard init -o config.yaml Generate starter config infraguard validate -c config.yaml Validate config file
### 生成器选项
`generate` 命令接受额外的标志,供操作员自定义:
| 标志 | 描述 |
|---|---|
| `--listen-port PORT` | 覆盖监听端口(默认:来自配置) |
| `--ssl-cert PATH` | 覆盖 SSL 证书路径 |
| `--ssl-key PATH` | 覆盖 SSL 密钥路径 |
| `--redirect-url URL` | 覆盖被阻止请求的重定向 URL |
| `--default-action redirect\|404` | 对不匹配请求执行的操作 |
| `--no-ip-filter` | 省略 IP 允许/拒绝块 |
| `--no-header-check` | 省略标头验证规则 |
| `--alias DOMAIN:ALIAS` | 添加服务器名称别名(可重复) |
| `--header NAME:VALUE` | 添加自定义响应标头(可重复) |
## 指挥中心(多实例仪表板)
当在不同 VPS 或云提供商上运行多个 InfraGuard 实例时,指挥中心会将所有节点的统计信息、请求和实时事件聚合到单个仪表板中。```
┌─────────────────────────────┐
│ Command Post Dashboard │
│ http://localhost:9090 │
└──────────┬──────────────────┘
│ parallel fetch
┌─────┼──────┬──────────┐
▼ ▼ ▼ ▼
IG-1 IG-2 IG-3 ... IG-N

infraguard command-post -c config/command-post.yaml
infraguard command-post
--instance "prod:https://ig1.example.com:8080:TOKEN1"
--instance "staging:https://ig2.example.com:8080:TOKEN2"
--port 9090
docker compose --profile command-post up -d command-post
### 配置
创建 `config/command-post.yaml`:```yaml
instances:
- name: "prod-cs"
url: "https://ig1.example.com:8080"
token: "${IG_PROD_TOKEN}"
- name: "prod-mythic"
url: "https://ig2.example.com:8080"
token: "${IG_MYTHIC_TOKEN}"
- name: "staging"
url: "https://ig3.example.com:8080"
token: "${IG_STAGING_TOKEN}"
port: 9090
# auth_token: "${COMMAND_POST_TOKEN}"
cp .env.example .env
docker compose up -d
这会启动两个服务:
- **proxy** —— 位于 443 和 80 端口的重定向器
- **dashboard** —— 位于 8080 端口的 Web 界面
### 使用 Let's Encrypt```bash
# Set in .env:
# INFRAGUARD_LETSENCRYPT=true
# INFRAGUARD_DOMAIN=cdn.example.com
# [email protected]
# Obtain the initial certificate
docker compose --profile letsencrypt up certbot
# Start the proxy (will use the LE cert)
docker compose up -d proxy dashboard
# Start auto-renewal (checks every 12 hours)
docker compose --profile letsencrypt up -d certbot-renew
Requirements for Let's Encrypt:
INFRAGUARD_DOMAIN 必须解析到此主机的公网 IPINFRAGUARD_DOMAIN_EMAIL 必须是有效的电子邮件地址docker compose --profile geoip up geoip-update
docker compose up -d proxy dashboard
### 使用 PwnDrop(载荷投递)```bash
# Start PwnDrop alongside the proxy
docker compose --profile pwndrop up -d pwndrop
# Access PwnDrop admin UI at https://localhost:8443
# InfraGuard reaches it internally at http://pwndrop:80
然后,在你的配置中配置内容路由,将载荷路径代理到 PwnDrop:```yaml domains: cdn.example.com: content_routes: - path: "/downloads/*" backend: type: "pwndrop" target: "http://pwndrop:80" auth_token: "${PWNDROP_TOKEN}"
### 使用 Ollama(AI 辅助配置文件生成)```bash
# Start the Ollama service
docker compose --profile ollama up -d ollama
# Pull the default model (~5 GB)
docker compose --profile ollama exec ollama ollama pull qwen3:8b
# The dashboard's AI chat panel will connect automatically
仪表板环境变量 INFRAGUARD_OLLAMA_URL 已在 docker-compose.yml 中预先配置。当 Ollama 运行时,AI 助手开关会出现在仪表板的诱饵和配置文件页面中。
docker compose up -d --scale proxy-node=3
在 `docker-compose.yml` 中取消注释 `proxy-node` 服务即可启用。
### 卷
| 卷 | 用途 |
|---|---|
| `./config` | 配置文件(以只读方式挂载) |
| `./examples` | C2 配置文件(以只读方式挂载) |
| `./rules` | 已导入的封禁列表和规则源文件(以只读方式挂载) |
| `./data` | SQLite 数据库和生成的配置文件(持久化) |
| `certs` | TLS 证书(在代理和 certbot 之间共享) |
| `geoip` | GeoLite2 数据库(由 `geoip-update` 服务填充) |
| `pwndrop-data` | PwnDrop 上传的文件和数据库 |
| `ollama-data` | Ollama 模型权重和配置 |
## 架构```
infraguard/
__init__.py Package init
__main__.py python -m infraguard entry
main.py Click CLI
config/ YAML config loading, .env support, Pydantic validation
core/ ASGI proxy engine (app, proxy, router, TLS, drop actions, content delivery)
profiles/ C2 profile parsers and generators (8 types)
pipeline/ Request validation filters (JA3, IP, bot, header, DNS, geo, profile, replay, enumeration, sandbox)
intel/ IP intelligence (blocklists, GeoIP, rDNS, feeds, rule ingestion)
tracking/ SQLite persistence (request logging, stats, node registry)
plugins/ Plugin system (protocol, loader, builtins)
ui/
api/ REST API + WebSocket (Starlette)
web/ SPA dashboard (HTML/JS/CSS)
tui/ Terminal UI (Textual) with login screen
command_post/ Multi-instance aggregation dashboard
listeners/ Protocol listeners (HTTP, DNS, MQTT, WebSocket)
backends/ Config generators (Nginx, Caddy, Apache)
models/ Shared types and event models
如果您想为项目做出贡献,请创建一个以版本号命名的新分支,并在拉取请求中指定相同的版本号。例如:branch=v1.2.3 | [v1.2.3] 添加了某某功能。
BSD 2-Clause 许可证。详情请参阅 LICENSE。
版权所有(c)2026,Whispergate
| 端点 | 方法 | 描述 |
|---|
/api/instances | GET | 列出所有实例及其健康状态 |
/api/stats | GET | 所有实例的合并统计信息 |
/api/requests | GET | 所有实例的交错请求日志 |
/api/intel/whitelist | POST | 在所有实例上将某 IP 加入白名单 |
/api/intel/blocklist | POST | 在所有实例上拦截某 IP |
/api/intel/blocklist | DELETE | 在所有实例上解除对某 IP 的拦截 |
/ws/events | WS | 来自所有实例的多路复用实时事件 |
| 功能 | RedWarden | InfraGuard |
|---|
| 架构 | 单个约 99KB 文件 | 模块化软件包 |
| Profile 解析 | 正则状态机 | 结构化解析器,支持完整块/转换功能 |
| C2 支持 | 仅 Cobalt Strike | Cobalt Strike、Mythic、Brute Ratel C4、Sliver、Havoc、Nighthawk、PoshC2 |
| Profile 管理 | 手动编辑文件 | 仪表板向导,支持生成、导入、热切换和 AI 辅助 |
| 协议 | 仅 HTTP | HTTP、DNS、MQTT、WebSocket |
| 过滤模型 | 二元通过/失败 | 基于评分(0.0--1.0 阈值),10 重过滤链 |
| TLS 指纹识别 | 无 | JA3 拦截(Masscan、ZGrab2、Shodan、curl、Python requests、Nmap) |
| 沙箱检测 | 无 | 无头浏览器 / Safe Links / 沙箱 UA 和头部评分 |
| 枚举检测 | 无 | 路径枚举 + DNS NXDOMAIN 跟踪并自动拦截 |
| 暴露检测 | 无 | CT 日志监控、域名信誉、跨域分析人员检测、置信度评分 |
| 基础设施弹性 | 无 | 断路器、协议故障转移、死手开关、基础设施轮换 |
| Payload 投递 | 无 | PwnDrop、Mythic 文件存储、文件系统、带条件投递的 HTTP 代理 |
| Payload 保护 | 无 | 一次性令牌、按路由限速、投递防护 |
| 钓鱼防护 | 无 | 活动令牌验证(静态列表或 HMAC 签名) |
| 操作员 UI | 无 | Web 仪表板 + 终端 UI + 多实例指挥中心 |
| 可观测性 | 无 | Prometheus 指标、交战报告、结构化日志 |
| 配置生成 | 无 | Nginx、Caddy、Apache,支持完全自定义 |
| 规则导入 | 无 | .htaccess + robots.txt 解析器 |
| 威胁情报源 | 无 | 从 5 个公共来源自动更新 |
| 插件系统 | 基础 4 方法接口 | 事件驱动,支持 on_event 钩子 + 每插件配置 |
| SIEM 集成 | 无 | Elasticsearch、Wazuh、Syslog(CEF/JSON) |
| Webhook 告警 | 无 | Discord、Slack、通用 webhook |
| 白名单情报 | 无 | 启动时自动使用 ASN/组织/国家/地区丰富 CIDR 信息 |
| 防重放 | SQLite 哈希 | 持久化 SQLite,带内存 L1 缓存,重启后仍保留 |
| 丢弃操作 | redirect、reset、proxy | redirect、reset、proxy、tarpit |
| TLS 管理 | 仅手动 | 自动自签名 + Let's Encrypt 集成 |
| 边缘部署 | 无 | Cloudflare Worker + AWS Lambda 边缘代理,支持域名前置 |
| 配置安全 | 无 | age 和 SOPS 加密、验证检查、API 密钥管理 |
| 部署 | 手动 | Docker Compose,带健康检查 |
| 异步 | Tornado 回调 | 原生 async/await(ASGI + uvicorn) |