Ramkumar2545/iris-cortex-analyzer-docker

GitHub: Ramkumar2545/iris-cortex-analyzer-docker

一键部署 DFIR-IRIS 与 Cortex 的单机 Docker 集成方案,用于协同应急响应案件管理与自动化 IOC 威胁分析。

Stars: 0 | Forks: 0

# DFIR-IRIS + Cortex 分析器 — Docker 部署 [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![Docker](https://img.shields.io/badge/Docker-Compose%20v2-blue)](https://docs.docker.com/compose/) [![RAM](https://img.shields.io/badge/RAM-16%20GB-green)]() [![IRIS](https://img.shields.io/badge/DFIR--IRIS-v2.4.20-purple)](https://github.com/dfir-iris/iris-web) [![Cortex](https://img.shields.io/badge/Cortex-latest-orange)](https://github.com/TheHive-Project/Cortex) ## 架构 ``` +-------------------------------------------------------------+ | Host Machine | | | | +------------------------------------------------------+ | | | iris_frontend network | | | | +---------------------+ | | | | | iriswebapp_nginx | :443 <-- HTTPS browser | | | | +----------+----------+ | | | +-------------+----------------------------------------+ | | | | | +-------------v----------------------------------------+ | | | iris_backend network | | | | +--------------+ +----------+ +--------------+ | | | | |iriswebapp_app| | db | | rabbitmq | | | | | | :8000 | | postgres | | (broker) | | | | | +--------------+ +----------+ +--------------+ | | | | +--------------+ +------------------------------+ | | | | |iriswebapp_ | | cortex :9001 <-- browser | | | | | | worker | +------------------------------+ | | | | +--------------+ | | | +------------------------------------------------------+ | | | | +------------------------------------------------------+ | | | cortex_net network | | | | +------------------------------------------+ | | | | | cortex_es (Elasticsearch) :9200 internal| | | | | +------------------------------------------+ | | | +------------------------------------------------------+ | +-------------------------------------------------------------+ ``` ## 服务和 RAM 分配 | 容器 | 镜像 | 暴露端口 | RAM 限制 | |---|---|---|---| | `iriswebapp_nginx` | `ghcr.io/dfir-iris/iriswebapp_nginx:v2.4.20` | **443 (HTTPS)** | 256 MB | | `iriswebapp_app` | `ghcr.io/dfir-iris/iriswebapp_app:v2.4.20` | 8000 (内部) | 2 GB | | `iriswebapp_worker` | `ghcr.io/dfir-iris/iriswebapp_app:v2.4.20` | — | 1 GB | | `iriswebapp_db` | `ghcr.io/dfir-iris/iriswebapp_db:v2.4.20` | 5432 (内部) | 1 GB | | `iriswebapp_rabbitmq` | `rabbitmq:3-management-alpine` | 15672 (内部) | 512 MB | | `cortex` | `thehiveproject/cortex:latest` | **9001 (HTTP)** | 2 GB | | `cortex_es` | `docker.elastic.co/elasticsearch/elasticsearch:8.13.0` | 9200 (内部) | 3 GB | | **总计** | | | **~9.8 GB** (为操作系统留出 ~6 GB) | ## 前置条件 ``` # Docker Engine (Ubuntu/Debian) curl -fsSL https://get.docker.com | sh sudo usermod -aG docker $USER && newgrp docker # 验证 Docker Compose v2 docker compose version ``` ## 快速开始 ### 1. 克隆 ``` git clone https://github.com/Ramkumar2545/iris-cortex-analyzer-docker.git cd iris-cortex-analyzer-docker ``` ### 2. 配置 `.env` ``` cp .env.model .env nano .env ``` 替换 `.env` 中的所有 `__MUST_BE_CHANGED__` 值。 ### 3. 准备 Cortex 作业目录 Cortex 会生成分析器的 Docker 容器,并将作业数据写入主机的 `/tmp/cortex-jobs` 目录中。 此目录**必须在启动堆栈之前存在并具有开放权限**——否则所有分析器作业都将失败并提示 `AccessDeniedException`。 ``` sudo mkdir -p /tmp/cortex-jobs sudo chmod 777 /tmp/cortex-jobs ``` ### 4. 运行设置脚本 ``` bash scripts/setup.sh ``` 该脚本会自动执行以下操作: - 从 `.env.model` 创建 `.env` 并提示您填写密钥 - 为 nginx 生成自签名 TLS 证书 - 对证书文件设置 `chmod 644`(必需——nginx 容器以非 root 用户运行) - 从模板生成 Cortex 的 `secret.conf` 和 `index.conf` - 设置 `vm.max_map_count=262144`(Elasticsearch 要求) - 依次运行 `docker compose down --remove-orphans` 和 `docker compose up -d` ### 5. 等待约 90 秒完成启动 ``` # 观察 IRIS app — 当你看到以下内容时即表示就绪: # WARNING :: IRIS IS READY on port 443 docker compose logs -f iriswebapp_app # 检查所有 containers 是否已启动 docker compose ps ``` ## 访问入口 | 服务 | URL | 协议 | |---|---|---| | 🔵 **DFIR-IRIS UI** | `https://localhost` | HTTPS (自签名证书) | | 🟠 **Cortex UI** | `http://localhost:9001/cortex` | HTTP | | 🐇 **RabbitMQ 管理界面** | `http://localhost:15672` | HTTP | ### 默认凭据 | 服务 | 用户名 | 获取密码的方式 | |---|---|---| | **DFIR-IRIS** | `administrator` | 在首次启动时打印在应用日志中:`docker compose logs iriswebapp_app \| grep "password >>>"` | | **Cortex** | *(首次访问时创建)* | 访问 `http://localhost:9001/cortex` → 创建组织 + 管理员用户 | | **RabbitMQ** | `guest` | 默认:`guest` | ## 连接 IRIS ↔ Cortex ### 步骤 1 — 创建 Cortex API Key 1. 打开 `http://localhost:9001/cortex` 2. 创建一个**组织**(例如 `SOC`) 3. 在该组织内创建一个具有 `read` + `analyze` 角色的**用户** 4. 点击该用户 → **Create API Key** → 复制该 key ### 步骤 2 — 更新 `.env` ``` nano .env # 设置: CORTEX_API_KEY=your_copied_api_key_here # 重启以应用新密钥 docker compose restart iriswebapp_app iriswebapp_worker ``` ### 步骤 3 — 在 IRIS UI 中配置 1. 以 `administrator` 身份登录 `https://localhost` 2. 进入 **Admin → Advanced Settings → Modules** 3. 点击 **IrisCortexModule** → **Configure**: - **Cortex URL**:`http://cortex:9001` *(使用内部 Docker 主机名,而不是 localhost)* - **Cortex API Key**:粘贴自步骤 1 的 key 4. 点击 **Save** → 点击 **Test** — 应该返回绿色的 ✅ ## 启用 Cortex 分析器 1. 在 Cortex UI 中进入 **Organization → Analyzers** 2. 启用您需要的分析器(例如 `VirusTotal_GetReport`、`Shodan_Host`、`AbuseIPDB`、`MISP`) 3. 在 **Organization → Analyzers → (选择分析器) → Configure** 中为每个分析器配置其 API key 4. 分析器作为 Docker 容器运行——挂载 `/var/run/docker.sock` 会自动处理此操作 ## 实用命令 ``` # 所有 container 状态 docker compose ps # 每个 service 的实时日志 docker compose logs -f iriswebapp_app docker compose logs -f iriswebapp_nginx docker compose logs -f cortex docker compose logs -f cortex_es # 重启单个 service docker compose restart iriswebapp_app docker compose restart iriswebapp_nginx docker compose restart cortex # 停止 stack (保留 data volumes) docker compose down # 完全清除 + 重启 (销毁所有数据) docker compose down -v --remove-orphans docker compose up -d # 拉取最新 images docker compose pull && docker compose up -d ``` ## 故障排除 | 症状 | 原因 | 解决方法 | |---|---|---| | `could not translate host name "19#20@db"` | 数据库密码中的 `@` 破坏了 PostgreSQL DSN | 使用不包含 `@` 的密码。生成方式:`openssl rand -hex 16` | | 密码在 `#` 处被悄悄截断 | `.env` 中未加引号的 `#` 被视为注释 | 为值加上引号:`POSTGRES_PASSWORD="pass#word"` | | nginx `Permission denied: iris.key` | `openssl` 创建的 key 权限为 `600`(仅限所有者) | 执行 `chmod 644 certificates/web_certificates/iris.key` | | nginx 502 Bad Gateway | IRIS 应用仍在启动中 / 正在运行数据库迁移 | 等待 2–3 分钟。查看日志:`docker compose logs -f iriswebapp_app` | | `Conflict: container name already in use` | 之前运行遗留的已停止容器 | 执行 `docker compose down --remove-orphans && docker compose up -d` | | Elasticsearch OOM / 退出代码 137 | 内存不足 | 确保主机有 16 GB 内存。检查:`docker stats` | | `max virtual memory areas` 错误 | 未设置 ES 内核要求 | 执行 `sudo sysctl -w vm.max_map_count=262144` | | 浏览器中的 TLS 证书警告 | 自签名证书 | 点击 **Advanced → Proceed to localhost**(正常现象) | | `AccessDeniedException: /tmp/cortex-jobs/...` | 作业目录缺失或权限错误 | 执行 `sudo mkdir -p /tmp/cortex-jobs && sudo chmod 777 /tmp/cortex-jobs`,然后运行 `docker compose restart cortex` | | Cortex 分析器静默显示 **Failure** | 同上——作业文件夹创建失败 | 同上解决方法 | | Cortex 分析器容器未能生成 | Docker socket 不可访问 | 检查 `docker-compose.yml` 中是否配置了 `/var/run/docker.sock:/var/run/docker.sock` | | IRIS 首次启动密码未知 | 初始化时随机生成 | 运行 `docker compose logs iriswebapp_app \| grep "password >>>"` | | Cortex UI 显示空白 / 404 | 缺少 `/cortex` 路径前缀 | 使用 `http://localhost:9001/cortex` 而不是 `http://localhost:9001` | ## 目录结构 ``` iris-cortex-analyzer-docker/ ├── docker-compose.yml # Full 7-service stack ├── .env.model # Environment template — copy to .env ├── .env # Your secrets (gitignored) ├── cortex/ │ └── config/ │ ├── application.conf # Cortex main config (analyzers, responders) │ ├── secret.conf.template # Cortex Play secret key template │ ├── secret.conf # Auto-generated by setup.sh (gitignored) │ ├── index.conf.template # Elasticsearch index config template │ ├── index.conf # Auto-generated by setup.sh (gitignored) │ └── logback.xml # Cortex logging (file + console, 10MB rotation) ├── certificates/ │ ├── rootCA/ # Auto-generated TLS root CA │ └── web_certificates/ # Auto-generated iris.crt + iris.key └── scripts/ ├── setup.sh # One-shot setup + start └── generate_cortex_apikey.sh # Guide for wiring Cortex API key into IRIS ``` ## 参考 - [DFIR-IRIS 文档](https://docs.dfir-iris.org) - [DFIR-IRIS GitHub](https://github.com/dfir-iris/iris-web) - [Cortex 文档](https://docs.thehive-project.org/cortex/) - [Cortex GitHub](https://github.com/TheHive-Project/Cortex) - [Cortex-Analyzers 目录](https://github.com/TheHive-Project/Cortex-Analyzers) ## 许可证 MIT — 详见 [LICENSE](LICENSE)
标签:CIDR查询, Cortex, DAST, DFIR-IRIS, Docker, Docker-Compose, HTTPS, masscan, Nginx, NIDS, PostgreSQL, Python, RabbitMQ, SecOps, SOAR, TheHive, 云安全架构, 内存配置, 单机部署, 参数枚举, 威胁分析, 威胁情报平台, 安全运营, 安全防御评估, 容器化, 库, 应急响应, 开源安全工具, 微服务架构, 恶意软件分析, 扫描框架, 数字取证, 无后门, 测试用例, 消息队列, 版权保护, 网络安全, 自动化侦查工具, 自动化脚本, 请求拦截, 逆向工具, 逆向工程平台, 隐私保护, 黑客分析