Data-Unix/tfg-soc-zerotrust

GitHub: Data-Unix/tfg-soc-zerotrust

基于纯开源工具构建的零信任架构 SOC 实验项目,实现了分布式威胁检测与自动化主动响应,并附带多阶段攻击验证工具。

Stars: 1 | Forks: 0

# SOC Zero Trust ### 基于 Open Source 的主动检测与响应 SOC 实现 #### 作者:Álvaro Carmena Díaz & Ilie Scripca *分布式检测 · 自动化主动响应 · Honeypots · 应用 Zero Trust* *软件许可证成本:**0 €** · 市场上同等功能成本:**>35.000 €/年*** [![Wazuh](https://img.shields.io/badge/Wazuh-4.14.1-005571?style=for-the-badge&logo=elasticsearch&logoColor=white)](config/wazuh/) [![OPNsense](https://img.shields.io/badge/OPNsense-Firewall_NGFW-d94f00?style=for-the-badge&logo=opnsense&logoColor=white)](config/opnsense/) [![T‑Pot](https://img.shields.io/badge/T--Pot-v24.04.1-8b0000?style=for-the-badge&logo=docker&logoColor=white)](config/) [![Suricata](https://img.shields.io/badge/Suricata-8.0.4_IDS-EF3B2D?style=for-the-badge&logo=suricata&logoColor=white)](config/opnsense/) [![Fail2Ban](https://img.shields.io/badge/Fail2Ban-0.11.1-FF6600?style=for-the-badge&logo=gnubash&logoColor=white)](config/fail2ban/) [![Nginx](https://img.shields.io/badge/Nginx-1.18.0-009639?style=for-the-badge&logo=nginx&logoColor=white)](config/nginx/) [![Tool ZTT](https://img.shields.io/badge/Tool_ZTT-Verificación-cc0000?style=for-the-badge&logo=python&logoColor=white)](src/ztt_framework.py) [![Python](https://img.shields.io/badge/Python-3.13-3776AB?style=for-the-badge&logo=python&logoColor=white)](src/) [![XML](https://img.shields.io/badge/XML-Wazuh_Rules-005571?style=for-the-badge)](config/wazuh/local_rules.xml) [![Shell](https://img.shields.io/badge/Shell-Bash_Scripts-4EAA25?style=for-the-badge&logo=gnubash&logoColor=white)](src/preparar.sh) [![MIT 许可证](https://img.shields.io/badge/Licencia-MIT-yellow?style=for-the-badge)](LICENSE) [![CI](https://img.shields.io/badge/Security_Scan-Activo-2ea44f?style=for-the-badge&logo=githubactions&logoColor=white)](.github/workflows/security-scan.yml) [![TFG](https://img.shields.io/badge/TFG-2025--2026-6f42c1?style=for-the-badge)](#) [![ASIR](https://img.shields.io/badge/ASIR-Ciclo_Superior-6f42c1?style=for-the-badge)](#) [![IES Valle Inclán](https://img.shields.io/badge/IES_Valle_Inclán-Madrid-6f42c1?style=for-the-badge)](#) [![SOC](https://img.shields.io/badge/SOC-Security_Operations_Center-dc3545?style=for-the-badge)](#) [![SIEM](https://img.shields.io/badge/SIEM-Detección_Distribuida-005571?style=for-the-badge)](#) [![IDS](https://img.shields.io/badge/IDS-Detección_Intrusiones-EF3B2D?style=for-the-badge)](#) [![Zero Trust](https://img.shields.io/badge/Zero_Trust-NIST_800--207-0075ca?style=for-the-badge)](#) [![网络安全](https://img.shields.io/badge/Ciberseguridad-Open_Source-198754?style=for-the-badge)](#)
[![快速开始](https://img.shields.io/badge/🚀_Inicio_Rápido-2ea44f?style=for-the-badge)](#instalación-del-laboratorio) [![架构](https://img.shields.io/badge/Arquitectura-0075ca?style=for-the-badge)](#arquitectura) [![11 个虚拟机](https://img.shields.io/badge/11_Máquinas_Virtuales-343a40?style=for-the-badge)](#infraestructura) [![ZTT 9 个阶段](https://img.shields.io/badge/9_Fases_de_Ataque-dc3545?style=for-the-badge)](#fases-de-la-tool-ztt-v11) [![ZTT 演示](https://img.shields.io/badge/Demo_ZTT-Espectáculo-e83e8c?style=for-the-badge)](#demo-tool-ztt-v11) [![TFG 文档](https://img.shields.io/badge/Memoria_TFG-PDF-6f42c1?style=for-the-badge)](docs/TFG-SOC-ZeroTrust-2026.pdf) [![配置文件](https://img.shields.io/badge/Configuraciones-Completas-fd7e14?style=for-the-badge)](config/)
## 这是什么项目? 本仓库包含了一个完全基于 **Zero Trust 架构的安全运营中心(SOC)** 的完整实现,完全采用 open source 工具构建于虚拟化基础设施之上。该系统运行在单一的物理服务器上,包含分布在四个分段网络中的 **11 台虚拟机**,这些网络具有不同的信任级别。 该项目核心是 **检测与主动响应链**:Wazuh 作为中心 SIEM 接收来自所有 agent 的遥测数据,使用自定义规则评估警报,并自动触发针对 OPNsense 的 Active Response——通过 pfctl 在 5 秒内封锁攻击者的 IP。此链路集成了高级 honeypots (T-Pot)、网络 IDS (Suricata)、应用层防护 (Fail2Ban + Nginx) 以及集中身份认证 (Authentik SSO)。 **Tool ZTT** 是为了验证系统响应而专门开发的验证工具:它遍历 9 个渐进式攻击阶段,并实时确认每个组件在面对每个威胁向量时都能正确地检测、封锁和发出警报。 该系统复制了 **NIST SP 800-207**(*Zero Trust Architecture*)的原则,并在功能上涵盖了 **NIS2 指令**和 **ENS BÁSICA 类别**的技术要求,且软件许可费用为 **0 €**。 ## 演示 — Tool ZTT
![Tool ZTT v1.1 演示](https://raw.githubusercontent.com/Data-Unix/tfg-soc-zerotrust/master/media/demo_ztt.gif)
| 阶段 | 向量 | 工具 | 结果 | |------|--------|-------------|-----------| | **0** | 状态检查 | ping / socket | `3/3 ONLINE` | | **1** | 端口侦察 | RustScan 2.3.0 | 发现 7 个端口 | | **2** | Web 枚举 | ffuf v2.1.0-dev | `100014` ×19 个警报 | | **3** | Honeypot SSH 成功 | Hydra v9.6 | `100011` → **AR 在 < 5 秒内封锁** | | **4** | Honeypot SSH 失败 | ssh -b (IP alias) | `100040` → **AR 封锁边界** | | **5** | Rollback PF | rollback-demo.sh | 表 `__wazuh_agent_drop` 已清空 | | **6** | Fail2Ban 双层防护 | ssh -b (IP alias) | `100040` → **iptables + PF 同时执行** | | **7** | Rollback Fail2Ban | fail2ban-client | 释放 jail sshd | | **8** | Dionaea SMB+MSSQL | impacket | `100020` ×2 个警报 | *该工具在从头到尾的可重复序列中激活了 Cowrie、Dionaea、Fail2Ban、Suricata 以及 Wazuh→OPNsense 的 Active Response。*
``` # 为评审团运行完整 demo(包含解释性暂停) sudo python3 src/ztt_framework.py --tribunal # 无暂停演示模式(用于录制) sudo python3 src/ztt_framework.py --espectaculo # 检查 demo 前置状态 sudo python3 src/ztt_framework.py --status # 运行特定阶段 sudo python3 src/ztt_framework.py --fase 8 ``` ## 架构 该架构将网络划分为 **四个不同信任级别的区域**:
![SOC Zero Trust 架构图](https://raw.githubusercontent.com/Data-Unix/tfg-soc-zerotrust/master/media/architecture.png)
| 网络 | 网段 | 信任级别 | 主机 | |-----|----------|--------------------|-------| | WAN | 203.0.113.0/24 | 不可信 | 模拟的 Internet (RFC 5737) | | LAN_DMZ | 172.17.0.0/24 | 低 | 攻击者 · Honeypots · Proxy · Mail | | LAN_INTERNA | 172.18.0.0/24 | 中-高 | SIEM · AD · IdP · Endpoints | | LAN_MNG | 172.16.0.0/24 | 高 | Proxmox · 远程访问 | OPNsense 作为所有网络之间的唯一网关,在 WAN 接口上运行 IDS 模式的 Suricata 8.0.4,并以 PF 作为 Wazuh 的 Active Response 封锁后端。 ## 基础设施 | VM | IP | 角色 | 技术 | Wazuh Agent | |----|----|-----|------------|--------------| | VM100 | 172.17.0.167 | 模拟攻击者 | Kali 2025.4 · Tool ZTT · Python 3.13 | — | | VM101 | 172.18.0.1 | 边界防火墙 | OPNsense · PF · Suricata 8.0.4 · AR | 009 | | VM102 | 172.18.0.12 | 中心 SIEM | Wazuh Manager 4.14.1 · OpenSearch | — | | VM103 | 172.17.0.13 | Web honeypot + 主机 IDS | Nginx 1.18.0 · Fail2Ban 0.11.1 · Ubuntu 20.04 | 008 | | VM104 | 172.18.0.56 | Windows Endpoint | Win10 LTSC 21H2 · Active | 011 | | VM105 | 172.18.0.20 | Active Directory | WinServer 2022 CORE · DC01 lab.tfg.local | 012 | | VM106 | 172.17.0.16 | 高级 Honeypot | T-Pot v24.04.1 · Cowrie · Dionaea · ELK | 010 | | VM107 | 172.18.0.14 | Identity Provider | Authentik 2026.2.2 · LDAP Outpost · SSO | — | | VM108 | 172.17.0.15 | 反向代理 | NPM 2.14.0 · SSL wildcard *.lab.tfg.local | — | | VM109 | 172.17.0.20 | 邮件服务器 | docker-mailserver v15.1.0 · Roundcube | — | | VM110 | 172.16.0.11 | 远程访问 | Apache Guacamole 1.6.0 · RDP+SSH | — | ## Tool ZTT 阶段 | 阶段 | 攻击向量 | 源 IP | 工具 | Wazuh 警报 | 响应 | |------|-----------------|-----------|-------------|--------------|-----------| | 0 | 状态检查 (3/3 ONLINE) | 172.17.0.167 | ping | — | — | | 1 | 端口侦察 | 172.17.0.167 | RustScan 2.3.0 | — | — | | 2 | Web 枚举 | 172.17.0.167 | ffuf v2.1.0-dev | **100014** lvl 10 | — | | 3 | Honeypot SSH 成功 | 172.17.0.167 | Hydra v9.6 + ssh | **100011** lvl 14 | AR → PF 封锁 | | 4 | Honeypot SSH 失败 × 3 | 172.17.0.200* | ssh -b (alias) | **100040** lvl 15 | AR → PF 封锁 | | 5 | Rollback PF | — | rollback-demo.sh | — | — | | 6 | Fail2Ban 双层防护 | 172.17.0.200* | ssh -b (alias) | **100040** lvl 15 | iptables + PF | | 7 | 完全 Rollback | — | fail2ban-client | — | — | | 8 | Dionaea SMB + MSSQL | 172.17.0.167 | impacket | **100020** × 2 | — | *\* 在 VM100 的 eth0 上运行时创建的 IP 池 172.17.0.200-209 中的别名 IP。* ### Active Response 流程 ``` Cowrie (T-Pot VM106) │ ▼ Wazuh Agente 010 ──► Wazuh Manager (VM102) │ regla 100011 / 100040 (lvl ≥ 14) │ AR: opnsense-fw ──► Agente 009 (VM101) │ pfctl tabla __wazuh_agent_drop │ IP atacante BLOQUEADA (latencia < 5 segundos) ``` ## 验证结果 验证于 **2026 年 5 月 16 日**使用 `--tribunal` 执行,共 5 个活跃 agent (008-012): | 指标 | 数值 | |---------|-------| | 真阳性 (TP) | **~29** | | 假阳性 (FP) | **0** | | 假阴性 (FN) | **1** *(规则 100005 — ffuf→503 触发 rate-limit)* | | Active Response 延迟 | **< 5 秒** | | 已验证的功能需求 | **10 / 10** | | 活跃的 Wazuh Agent | **5** (008 · 009 · 010 · 011 · 012) | ## 自定义 Wazuh 规则 完整文件位于 [`config/wazuh/local_rules.xml`](config/wazuh/local_rules.xml) | Rule ID | 描述 | 级别 | 动作 | |---------|-------------|-------|--------| | 100005 | Web 枚举频率 (ffuf/nikto) | 10 | — | | 100010 | Cowrie SSH 登录失败 | 10 | — | | 100011 | Cowrie SSH 登录成功 (honeypot 被攻陷) | 14 | **Active Response** | | 100014 | 在 Nginx 日志中检测到 ffuf/fuzzer | 10 | — | | 100020 | Dionaea:SMB/MSSQL exploit 连接 | 10 | — | | 100040 | 严重:多向量复合威胁 | 15 | **Active Response** | ## 安装实验室环境 ### 前置要求 - 物理服务器:CPU × 6 核,内存 32 GB,SSD 256 GB + HDD 1 TB - 已安装 Proxmox VE 并配有 4 个网桥 (vmbr0-3) - 需要连接互联网以下载 ISO 镜像 ### 部署顺序 ``` # 1. 基础设施 # VM101 OPNsense → VM102 Wazuh → VM103 Fail2Ban+Nginx # 2. Honeypots # VM106 T-Pot v24.04.1 → 在 Wazuh 中注册 agent 010 # 3. 身份与访问 # VM105 Windows Server (AD DC01) → VM107 Authentik → VM108 NPM # 4. Endpoints # VM104 Windows 客户端 → VM109 Mail → VM110 Guacamole # 5. 模拟攻击者 # VM100 Kali → 复制 ztt_framework.py → 安装依赖 # 6. 验证 sudo python3 src/ztt_framework.py --status # 3/3 targets ONLINE sudo python3 src/ztt_framework.py --tribunal # demo completa ``` ### Tool ZTT 依赖项 (VM100 Kali) ``` # 外部工具 sudo apt install -y hydra ffuf rustscan sshpass impacket-scripts # 可视化界面库 pip install rich # Wordlist gunzip /usr/share/wordlists/rockyou.txt.gz ``` ## 仓库结构 ``` tfg-soc-zerotrust/ ├── src/ │ ├── ztt_framework.py # Tool ZTT — 866 líneas, Python 3.13 │ └── preparar.sh # Limpieza de alias IP pre-demo ├── config/ │ ├── wazuh/ │ │ ├── local_rules.xml # 6 reglas de detección personalizadas │ │ └── tpot_decoders.xml # Decoder Dionaea (T-Pot v24.04.1) │ ├── nginx/ │ │ ├── nginx.conf # Configuración base Nginx (VM103) │ │ └── vm103-nginx.conf # Virtual host con rate limiting │ ├── fail2ban/ │ │ ├── jail.local # Jails: sshd + nginx-req-limit │ │ ├── nginx-req-limit.conf # Filtro Fail2Ban para rate limit │ │ └── wazuh-syslog.conf # Acción custom: iptables + logger→Wazuh │ └── opnsense/ │ └── rollback-demo.sh # Script de rollback post-demo ├── web/ │ └── el-heraldo-pyongyang/ │ └── index.html # Web señuelo para demostración ffuf ├── media/ │ ├── architecture.png # Diagrama de arquitectura de red │ └── demo-ztt-espectaculo.gif # Grabación demo completa ├── docs/ │ ├── instalacion.md │ └── fases-ztt.md └── README.md ``` ## 技术
![Wazuh](https://img.shields.io/badge/-Wazuh_SIEM_4.14.1-005571?style=for-the-badge) ![OPNsense](https://img.shields.io/badge/-OPNsense_Firewall-D94F00?style=for-the-badge) ![T-Pot](https://img.shields.io/badge/-T--Pot_v24.04.1-8B0000?style=for-the-badge) ![Suricata](https://img.shields.io/badge/-Suricata_8.0.4_IDSF3B2D?style=for-the-badge) ![Fail2Ban](https://img.shields.io/badge/-Fail2Ban_0.11.1-FF6600?style=for-the-badge) ![Authentik](https://img.shields.io/badge/-Authentik_2026.2.2_SSO-FD4B2D?style=for-the-badge) ![NPM](https://img.shields.io/badge/-Nginx_Proxy_Manager-009639?style=for-the-badge) ![Proxmox](https://img.shields.io/badge/-Proxmox_VE-E57000?style=for-the-badge) ![Python](https://img.shields.io/badge/-Python_3.13-3776AB?style=for-the-badge&logo=python&logoColor=white) ![Kali](https://img.shields.io/badge/-Kali_Linux_2025.4-268BEE?style=for-the-badge)
**IES Valle Inclán · ASIR 2025-2026** Álvaro Carmena Díaz · Ilie Scripca *导师:Manuel Antonio Reyes Cañizal*
标签:CISA项目, Metaprompt, Wazuh, 入侵检测系统, 安全数据湖, 安全运营中心, 应用安全, 网络信息收集, 网络映射, 自动化响应, 蜜罐, 证书利用, 请求拦截, 逆向工具, 零信任架构