Mystique-cmd/ulinzimesh

GitHub: Mystique-cmd/ulinzimesh

一个模块化网络安全遥测平台,协调多平台底层探针、中央收集器、分析 API 和仪表板,实现实时威胁检测与响应。

Stars: 0 | Forks: 0

# UlinziMesh — 真实威胁遥测平台 UlinziMesh 是一个模块化的网络安全框架,它统筹协调底层探针、中央遥测收集器、分析 API 以及自适应仪表板,用于实时的威胁检测与响应。 ## 架构概述 ``` ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ C Agent │────▶│ │ │ PHP API │ │ (Linux /proc) │ │ │ │ (JSON REST) │ ├─────────────────┤ │ Go Collector │────▶├─────────────────┤ │ C++ Decoy │────▶│ (port 9090) │ │ PostgreSQL │ │ (Honeypot) │ │ │ │ ───────────── │ ├─────────────────┤ │ │ │ hosts │ │ PowerShell │────▶│ │ │ network_flows │ │ Agent (Win) │ │ │ │ findings │ ├─────────────────┤ │ │ │ indicators │ │ ASM Probe │────▶│ │ │ decoys │ │ + bash wrapper │ └──────────────────┘ └─────────────────┘ └─────────────────┘ │ ┌────▼────┐ │ Web UI │ │ (8082) │ └─────────┘ ``` ## 组件 ### 收集器 (Go) — 端口 `9090` 通过 HTTP POST 从探针接入流遥测数据。默认绑定到 `0.0.0.0`,以便远程探针可以访问它。 - `POST /ingest/flow` — 接收流事件 (JSON,通过 `COLLECTOR_TOKEN` 进行身份验证) - `GET /healthz` — 存活检查 - `GET /readyz` — 就绪检查 (包含数据库 ping) ### PHP API — 端口 `8081` 提供由 PostgreSQL 支持的 REST 端点。绑定到 `0.0.0.0` 以供远程访问。 - `GET /findings` — 最新的 100 条发现 - `GET /flows` — 最新的 100 条网络流 (包含主机名) - `GET /indicators` — 最新的 100 条指标 ### Web UI — 端口 `8082` 静态 HTML/CSS/JS 仪表板,每 5 秒轮询一次 API。自动检测同源 `/api` 或回退到 `http://127.0.0.1:8081`。 ### 探针 (真实遥测,非沙盒环境) | 探针 | 平台 | 数据源 | 输出 | |-------|----------|-------------|--------| | **C Agent** | Linux | `/proc/net/tcp`, `/proc/net/udp` | 真实的 TCP/UDP 连接 (JSON Lines) | | **C++ Decoy** | Linux | Socket accept | SSH 蜜罐,将交互 POST 到收集器 | | **PowerShell Agent** | Windows | `Get-NetTCPConnection` | 真实的 TCP 连接,发布到收集器 | | **ASM Probe** | Linux x86_64 | 通过汇编获取 `/proc` | 主机名/PID 输出 + 用于获取 `ss` 数据的 bash 包装器 | | **Shell Agent** | Linux | `ss` 命令 | 通过 bash/curl 获取真实连接遥测 | ### 协调器 (Python) 针对遥测数据库运行 YAML playbook,以检测诸如撞库之类的威胁。 - 直接连接到 PostgreSQL - 运行 SQL 查询并根据阈值插入发现 ## 快速开始 ``` # 前提条件 # - Go 1.20+,PHP 8.1+(带有 pgsql PDO),Python 3.8+,PostgreSQL 13+ # - psql 和 createdb CLI 工具 # 配置环境 # 复制或编辑 repo 根目录下的 .env: # PGHOST=lpghost # PGPORT=5432 # PGDATABASE=pgdatabase # PGUSER=pguser # PGPASSWORD=pgpassword # COLLECTOR_TOKEN="your-secret-token" # Bootstrap 所有内容 bash scripts/dev_bootstrap.sh ``` 引导启动后: - **收集器**: http://0.0.0.0:9090/healthz - **PHP API**: http://0.0.0.0:8081/findings - **仪表板**: http://127.0.0.1:8082/index.html ## 远程探针配置 探针可以从网络上的任何地方连接: ``` # 在构建了 C agent 的任何 Linux 机器上: export COLLECTOR_URL="http://:9090/ingest/flow" bash agents/scripts/agent_linux.sh --loop # 或者只运行一次: bash agents/scripts/agent_linux.sh --once ``` 对于 Windows 探针: ``` $env:COLLECTOR_URL = "http://:9090/ingest/flow" .\agents\scripts\agent_windows.psl ``` 对于 C++ 诱饵 (蜜罐): ``` export COLLECTOR_URL="http://:9090/ingest/flow" export HOSTNAME="$(hostname)" ./agents/cpp_decoy/decoy 2222 ``` ## 手动运行 (不使用 bootstrap) ``` # 1. 运行 migrations bash scripts/migrate_up.sh # 2. 启动 collector cd collector COLLECTOR_BIND="0.0.0.0:9090" go run main.go # 3. 启动 PHP API(在单独的终端中) cd web/api php -S 0.0.0.0:8081 # 4. 提供 UI 服务(在单独的终端中) cd web/ui python3 -m http.server 8082 # 5. 打开 http://127.0.0.1:8082/index.html ``` ## 发送测试事件 ``` # Linux/macOS bash scripts/send_test_event.sh # Windows (PowerShell) .\scripts\Send-Test-Event.psl ``` ## 运行协调器 ``` cd orchestrator pip install pyyaml psycopg2-binary python playbook_runner.py ``` ## API 端点 | 方法 | 路径 | 描述 | |--------|------|-------------| | `GET` | `/findings` | 最新的 100 条发现 | | `GET` | `/flows` | 最新的 100 条流 | | `GET` | `/indicators` | 最新的 100 条指标 | | `POST` | `/ingest/flow` | 接入流事件 (需要 `Authorization: Bearer `) | | `GET` | `/healthz` | 存活检查 | | `GET` | `/readyz` | 就绪检查 | ## 流事件 Schema 探针将 JSON 事件发送到 `POST /ingest/flow`: ``` { "hostname": "server-01", "platform": "linux", "src_ip": "10.0.0.5", "src_port": 54321, "dst_ip": "8.8.8.8", "dst_port": 53, "protocol": "udp", "direction": "egress", "bytes_tx": 512, "bytes_rx": 1024 } ``` ## 安全说明 - **CORS 是开放的** — 旨在供内部网络使用。在暴露给互联网之前,请使用反向代理 (nginx, Caddy) 进行加固。 - **收集器使用 Bearer token 身份验证** — 在您的 `.env` 文件中设置 `COLLECTOR_TOKEN`。 - **PostgreSQL 应配置防火墙** — API 是唯一应直接连接到它的组件。 - **默认无 TLS** — 在生产环境中,请使用反向代理进行 HTTPS 终止。 ## 故障排除 - **日志**: `logs/collector.log`, `logs/api.log`, `logs/ui.log` - **端口冲突**: 默认端口为 9090 (收集器), 8081 (API), 8082 (UI) - **数据库不可用**: API 会优雅降级并返回空列表 - **C agent 无法构建**: 确保已安装 `gcc`。该探针使用标准的 POSIX API。
标签:AI合规, 安全遥测, 应用安全, 微服务架构, 插件系统, 日志审计, 测试用例, 网络安全, 网络安全审计, 自动回退, 蜜罐, 证书利用, 逆向工具, 隐私保护