CipherReaperX/cyforesight

GitHub: CipherReaperX/cyforesight

一个全栈网络威胁情报平台,提供实时威胁检测、IOC 管理、事件响应与 MITRE ATT&CK 映射能力。

Stars: 0 | Forks: 0

``` ██████╗██╗ ██╗███████╗ ██████╗ ██████╗ ███████╗███████╗██╗ ██████╗ ██╗ ██╗████████╗ ██╔════╝╚██╗ ██╔╝██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝██║██╔════╝ ██║ ██║╚══██╔══╝ ██║ ╚████╔╝ █████╗ ██║ ██║██████╔╝█████╗ ███████╗██║██║ ███╗███████║ ██║ ██║ ╚██╔╝ ██╔══╝ ██║ ██║██╔══██╗██╔══╝ ╚════██║██║██║ ██║██╔══██║ ██║ ╚██████╗ ██║ ██║ ╚██████╔╝██║ ██║███████╗███████║██║╚██████╔╝██║ ██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ``` ### 网络威胁情报平台 *实时威胁检测 · IOC 管理 · MITRE ATT&CK 映射 · 实时地理威胁地图* ![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=for-the-badge&logo=typescript&logoColor=white) ![React](https://img.shields.io/badge/React-18-61DAFB?style=for-the-badge&logo=react&logoColor=black) ![Vite](https://img.shields.io/badge/Vite-6.x-646CFF?style=for-the-badge&logo=vite&logoColor=white) ![Express](https://img.shields.io/badge/Express-4.x-000000?style=for-the-badge&logo=express&logoColor=white) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-16-4169E1?style=for-the-badge&logo=postgresql&logoColor=white) ![Redis](https://img.shields.io/badge/Redis-7-DC382D?style=for-the-badge&logo=redis&logoColor=white) ![Socket.IO](https://img.shields.io/badge/Socket.IO-4-010101?style=for-the-badge&logo=socketdotio&logoColor=white) ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge) ![Status](https://img.shields.io/badge/Status-Active-brightgreen?style=for-the-badge) ![PRs](https://img.shields.io/badge/PRs-Welcome-orange?style=for-the-badge)
## 什么是 CyForesight? **CyForesight** 是一个全栈网络威胁情报 (CTI) 平台,可实时聚合、丰富和可视化威胁数据。它从多个实时威胁源中提取危害指标 (IOC),将它们与您的资产清单进行关联,映射到 MITRE ATT&CK 技术,并显现异常——所有这些都在一个单一、现代的深色主题仪表板中完成。 ## 核心功能 | 模块 | 功能 | |--------|-----------| | **实时仪表板** | 实时脉冲条 (Socket.IO)、统计卡片、威胁压力指数、IOC 分布饼图、支持国家层级下钻的全球地理威胁地图 | | **IOC 管理** | 分页 IOC 表格、批量 CSV 导入、JSON/CSV 导出、严重程度/类型/状态筛选、复制到剪贴板、针对单个 IOC 的扩展查询 (VirusTotal, AbuseIPDB) | | **威胁源** | 添加/编辑/删除源 (JSON 和 CSV)、单独源同步、全量同步、暂停/恢复、健康评分、通过 BullMQ 自动定时提取 | | **提取异常检测器** | 在滚动的 7 天每小时窗口上进行 Z-score 检测;在 μ + 2σ 处标记突增;显示基线、标准差和阈值 | | **事件工作台** | 创建/编辑/删除事件、IOC 与资产关联、笔记时间线、状态工作流(新建 → 处理中 → 已解决)、从高风险 IOC 自动聚类 | | **MITRE ATT&CK** | 完整的战术/技术矩阵、检测覆盖率热力图、资产关联、IOC → TTP 映射 | | **资产清单** | 列表/网格视图、CSV 批量导入、针对单个资产扫描、VT 信誉复查、CVE 与威胁关联 | | **CVE 跟踪器** | 分页 CVE 数据库、CVSS 评分、漏洞利用与补丁状态跟踪、资产影响数量、CSV 导出 | | **威胁狩猎** | 兼容 KQL 的查询构建器、多源狩猎 (IOC + 资产 + CVE)、保存和定时查询、运行历史 | | **侦测工具** | WHOIS、DNS、GeoIP、SSL 证书查询 | | **报告** | 基于模板的报告生成和下载 | | **集成** | Webhook、Slack、SIEM 集成,支持实时测试和配置持久化 | | **设置** | 通用、通知、用户管理、数据源、安全(密码更改、审计日志)、API 密钥 | ## 架构 ``` ┌─────────────────────────────────────────────────────────────┐ │ Browser │ │ React 18 · Vite · TailwindCSS · Recharts · React Query │ │ Socket.IO client │ └────────────────────┬────────────────────────────────────────┘ │ HTTP /api + WS /socket.io │ (Vite proxy in dev · nginx in prod) ┌────────────────────▼────────────────────────────────────────┐ │ Express API Server (:9999) │ │ TypeScript · Drizzle ORM · Zod · JWT auth · BullMQ │ │ Socket.IO server · geoip-lite · VirusTotal · AbuseIPDB │ └─────────┬────────────────────────────┬───────────────────────┘ │ │ ┌─────────▼──────────┐ ┌────────────▼────────────┐ │ PostgreSQL 16 │ │ Redis 7 │ │ (Drizzle schema) │ │ (BullMQ job queues) │ └─────────────────────┘ └──────────────────────────┘ ``` ## 技术栈 **前端** - React 18 使用 `startTransition` 实现非阻塞 socket 更新 - Vite 6 支持 HMR 和路径别名 (`@/`) - TailwindCSS — 带有自定义 slate/cyan 色板的深色主题 - Recharts — 折线图、面积图、柱状图、饼图 - React Query (TanStack) — 服务器状态、缓存失效 - Socket.IO 客户端 — 纯 WebSocket 传输 - React Router v6 - Sonner — toast 通知 **后端** - Express 4 + TypeScript - 基于 PostgreSQL 16 的 Drizzle ORM - BullMQ + Redis — 源抓取任务队列 - Socket.IO 服务器 — 实时事件 (`dashboard:pulse`, `ioc:new`, `feed:synced`, `incident:*`) - 带有基于角色访问控制 (`admin`, `analyst`, `viewer`) 的 JWT 身份验证 - geoip-lite — 在插入时进行离线 IP 地理定位 - Zod — 请求验证 schema - Winston — 结构化日志 ## 快速开始 ### 前置条件 | 工具 | 版本 | |------|---------| | Node.js | 20+ | | PostgreSQL | 16+ | | Redis | 7+ | | npm | 10+ | ### 1 — 克隆并安装 ``` git clone https://github.com/CipherReaperX/cyforesight.git cd cyforesight # Frontend 依赖 npm install # Backend 依赖 cd tip-backend && npm install ``` ### 2 — 配置环境 **对于 Docker Compose** — 在项目根目录创建 `.env`: ``` cp .env.example .env # 然后编辑 .env,为 POSTGRES_PASSWORD 和 JWT_SECRET 设置强唯一值 ``` **对于手动开发设置** — 创建 `tip-backend/.env`: ``` DATABASE_URL=postgresql://user:password@localhost:5432/cyforesight REDIS_URL=redis://localhost:6379 JWT_SECRET=your-super-secret-key-change-this CORS_ORIGIN=http://localhost:3000 # 可选的 enrichment APIs VIRUSTOTAL_API_KEY= ABUSEIPDB_API_KEY= ALIENVAULT_API_KEY= ``` 在项目根目录创建 `.env`: ``` VITE_API_BASE_URL=/api ``` ### 3 — 数据库设置 ``` cd tip-backend npm run db:push # push Drizzle schema to Postgres npm run db:seed # optional: seed MITRE ATT&CK data ``` ### 4 — 在开发环境中运行 ``` # 终端 1 — Backend (端口 9999) cd tip-backend && npm run dev # 终端 2 — Frontend (端口 3000) npm run dev ``` 打开 **http://localhost:3000** — Vite 会将 `/api` 和 `/socket.io` 代理到端口 9999 上的后端。 ### 默认凭证 | 用户名 | 密码 | 角色 | |----------|----------|------| | `admin` | `admin123` | 管理员 | ## 项目结构 ``` cyforesight/ ├── src/ # React frontend │ ├── components/ │ │ ├── layout/ # TopBar, Sidebar, MainLayout │ │ ├── ui/ # Card, Button, Badge, Table, Input… │ │ ├── AnomalyPanel.tsx # Z-score ingestion anomaly detector │ │ ├── GeoMap.tsx # Leaflet world threat map │ │ └── NotificationPanel.tsx │ ├── hooks/ # React Query data hooks │ ├── pages/ # Route-level page components │ ├── providers/ │ │ └── SocketProvider.tsx # Socket.IO context + startTransition │ └── lib/ │ └── api.ts # Axios client with JWT interceptor │ └── tip-backend/src/ ├── controllers/ # Express request handlers ├── services/ # Business logic ├── routes/ # Express routers ├── models/schema.ts # Drizzle table definitions ├── validators/ # Zod schemas ├── jobs/feedFetch.job.ts # BullMQ worker for feed ingestion ├── services/socket.service.ts# Socket.IO init + notification buffer └── config/ # DB, Redis, logger ``` ## API 概览 除 `/api/auth/login` 外,所有端点都需要 `Authorization: Bearer `。 | 资源 | 端点 | |----------|-----------| | 身份验证 | `POST /auth/login` · `POST /auth/change-password` · `GET /auth/audit-log` | | IOC | `GET /iocs` · `POST /iocs` · `PUT /iocs/:id` · `DELETE /iocs/:id` · `GET /iocs/anomalies` · `POST /iocs/upload-csv` · `GET /iocs/export` | | 源 | `GET /feeds` · `POST /feeds` · `POST /feeds/:id/sync` · `POST /feeds/sync-all` · `POST /feeds/:id/pause` | | 仪表板 | `GET /dashboard/overview` · `GET /dashboard/geo-threats` · `POST /dashboard/invalidate-cache` | | 事件 | `GET /incidents` · `POST /incidents` · `PATCH /incidents/:id` · `DELETE /incidents/:id` · `POST /incidents/bootstrap` | | 资产 | `GET /assets` · `POST /assets` · `POST /assets/:id/scan` · `POST /assets/map-iocs` · `GET /assets/export` | | CVE | `GET /cves` · `PATCH /cves/:id` · `POST /cves/scan-assets` · `GET /cves/export` | | MITRE | `GET /mitre/tactics` · `GET /mitre/techniques` · `GET /mitre/coverage` · `POST /mitre/map-iocs` | | 狩猎 | `POST /hunting/run` · `POST /hunting/queries` · `GET /hunting/queries` · `POST /hunting/automation/run` | | 设置 | `GET/PUT /settings` · `POST /settings/api-keys` · `GET/PUT /settings/notification-prefs` | ## 实时事件 使用纯 WebSocket 传输的 Socket.IO。所有客户端处理程序都在 React 18 `startTransition` 内运行,以保持 UI 的响应性。 | 事件 | 方向 | 触发条件 | |-------|-----------|---------| | `dashboard:pulse` | 服务器 → 客户端 | 每 5 秒 — 实时 IOC 计数、威胁、风险资产 | | `ioc:new` | 服务器 → 客户端 | 从源同步中提取的新 IOC | | `feed:synced` | 服务器 → 客户端 | 源同步任务完成 | | `incident:created` | 服务器 → 客户端 | 创建了新事件 | | `incident:updated` | 服务器 → 客户端 | 事件状态或数据更改 | | `notification:new` | 服务器 → 客户端 | 推送了应用内通知 | | `pulse:request` | 客户端 → 服务器 | 请求立即获取脉冲快照 | ## 安全 - 带有可配置过期时间的 JWT 身份验证 - 基于角色的访问控制 — `admin` · `analyst` · `viewer` - Bcrypt 密码哈希 - 对所有修改性端点进行 Zod schema 验证 - 身份验证路由上的速率限制 - CORS 锁定到配置的源 - 此仓库已启用 Dependabot 漏洞警报 ## 许可证 MIT © 2025 [CipherReaperX](https://github.com/CipherReaperX)
*精准构建。为防御者设计。*
标签:Mutation, PostgreSQL, React, Syscalls, TypeScript, 可视化, 威胁情报, 安全插件, 开发者工具, 搜索引擎查询, 测试用例, 网络安全, 自动化攻击, 隐私保护