saifvector/cortex-nids

GitHub: saifvector/cortex-nids

基于 LightGBM 机器学习的企业级网络入侵检测与 SOC 平台,实时分类网络威胁并触发自动化缓解。

Stars: 0 | Forks: 0

# 企业网络入侵检测系统 (NIDS)

Python Version FastAPI React Docker License Build Status Test Pass Rate

**GitHub 仓库**:[`https://github.com/saifvector/cortex-nids`](https://github.com/saifvector/cortex-nids) ## 📌 执行摘要 **企业网络入侵检测系统 (`cortex-nids`)** 是一个商用级别的、基于机器学习的安全运营中心 (SOC) 平台,旨在实时检测、分类和缓解网络威胁。该平台构建于高吞吐量的 **LightGBM Classifier**(准确率 `99.87%`)、**FastAPI**、**Scapy Live Packet Capture**、**SIEM Connectors**(Elastic/Splunk/Sentinel)、**SOAR Playbooks** 以及 **React 18 Liquid Glass Dashboard** 之上,能够将原始的网络遥测数据转化为可执行的安全情报。 ## 🎯 问题陈述与目标 现代企业网络每秒处理数 GB 的遥测数据。传统的基于签名的 IDS 解决方案无法应对零日漏洞利用、新型 DDoS 攻击以及复杂的 Web 注入技术。 ### 核心目标: 1. **实时异常与威胁检测**:以亚毫秒级延迟(`20.4ms`)将传入的网络流量分类到 15 种攻击类别中。 2. **可执行的风险评分**:计算数字风险评分(0-100)并分配严重性级别(`Low`、`Medium`、`High`、`Critical`)。 3. **自动化缓解 (SOAR)**:触发自动化的防火墙规则执行(`netsh` / `iptables`),以立即消除高风险威胁。 4. **SIEM 与威胁情报融合**:将 CEF/LEEF 日志流式传输到 Elastic、Splunk 和 Sentinel,并结合 VirusTotal、AbuseIPDB 和 AlienVault OTX 的情报进行丰富。 ## 🏛️ 高层系统架构 ``` flowchart TD subgraph Ingestion["📡 Telemetry & Ingestion Layer"] Pcap["PCAP Dumps / NetFlow"] LiveScapy["Scapy Live Packet Sniffer"] FlowBuilder["Bidirectional Flow Builder (5-Tuple)"] Pcap --> FlowBuilder LiveScapy --> FlowBuilder end subgraph MLPipeline["🧠 Machine Learning Engine"] FeatureEng["20-Feature Extractor & Scaler"] LightGBM["LightGBM Classifier Engine"] RiskEngine["Risk Score & Severity Evaluator"] FlowBuilder --> FeatureEng FeatureEng --> LightGBM LightGBM --> RiskEngine end subgraph API["⚡ FastAPI REST & Middleware"] Router["FastAPI Application Router"] JWTAuth["JWT Bearer Auth & RBAC"] RateLimit["Sliding Window Rate Limiter"] RiskEngine --> Router JWTAuth -.-> Router RateLimit -.-> Router end subgraph SecurityOps["🛡️ SOC & Operations Layer"] SOCDash["React 18 Liquid Glass Dashboard"] SIEMExp["SIEM Exporter (Elastic/Splunk/Sentinel)"] SOARPlay["SOAR Firewall Response (netsh/iptables)"] Router --> SOCDash Router --> SIEMExp Router --> SOARPlay end ``` ## 📊 数据集与机器学习性能 该系统基于基准 CICIDS2017 数据集中的 **2,830,743 条网络流量记录** 进行训练,涵盖 15 种攻击向量。 ### 模型评估指标: | 分类器模型 | 准确率 | 精确率 | 召回率 | F1-Score | 推理延迟 | | :--- | :---: | :---: | :---: | :---: | :---: | | **LightGBM (主要)** | **99.87%** | **0.9984** | **0.9987** | **0.9005** | **20.4 ms** | | XGBoost | 99.84% | 0.9981 | 0.9984 | 0.8980 | 32.1 ms | | CatBoost | 99.82% | 0.9979 | 0.9982 | 0.8950 | 45.0 ms | | Random Forest | 99.79% | 0.9975 | 0.9979 | 0.8910 | 58.2 ms | ## 🚀 快速设置与安装 ``` # Clone the repository git clone https://github.com/saifvector/cortex-nids.git cd cortex-nids ``` ### 选项 1:自动化本地安装(无需 Docker) #### Windows (PowerShell): ``` powershell -ExecutionPolicy Bypass -File setup.ps1 ``` #### Linux / macOS (Bash): ``` chmod +x setup.sh && ./setup.sh ``` #### 启动双重本地技术栈(后端 + 前端): ``` powershell -ExecutionPolicy Bypass -File scripts\start_local.ps1 ``` ### 选项 2:Docker 容器化部署 ``` # Core Stack (Backend + Frontend) docker compose -f docker-compose.local.yml up -d --build # Full Stack (Backend + Frontend + Prometheus + Grafana) docker compose up -d --build ``` ## 🌐 应用程序访问点 | 服务 | 访问 URL | 描述 | | :--- | :--- | :--- | | **React SOC Dashboard** | [http://localhost:3000](http://localhost:3000) | 价值一亿美元的 Liquid Glass 安全运营平台 | | **FastAPI REST API** | [http://localhost:8000](http://localhost:8000) | 亚毫秒级 ML 预测 API | | **交互式 API 文档** | [http://localhost:8000/docs](http://localhost:8000/docs) | Swagger OpenAPI 参考 | | **Prometheus 指标** | [http://localhost:9090](http://localhost:9090) | 操作指标抓取 | | **Grafana 可视化工具** | [http://localhost:3001](http://localhost:3001) | 实时基础设施监控 | ## 🧪 自动化测试与 QA (`python scripts/run_tests.py`) 代码库在 70 个综合测试用例中实现了 **100% 的测试通过率**,涵盖了 REST API、JWT Auth、RBAC、ML 推理、Scapy 网络嗅探和 Docker 规范。 ``` ========================================== ENTERPRISE NIDS QA & TESTING SUMMARY ========================================== Total Test Cases Executed : 70 Passed Test Cases : 70 Failed Test Cases : 0 Pass Rate : 100.0% Test Reports Generated : reports/testing/test_report.md & test_report.html ========================================== ``` ## 📄 许可证与致谢 - **仓库**:[`https://github.com/saifvector/cortex-nids`](https://github.com/saifvector/cortex-nids) - **作者**:[@saifvector](https://github.com/saifvector) - **许可证**:基于 [MIT License](LICENSE) 发布。 - **数据集**:感谢加拿大网络安全研究所 (CIC) 提供的 CICIDS2017 网络入侵遥测数据。
标签:Apex, AV绕过, CISA项目, FastAPI, React, SOAR, Syscalls, 入侵检测系统, 后端开发, 安全数据湖, 安全运营中心, 机器学习, 网络映射, 自定义请求头, 请求拦截, 逆向工具, 配置错误