geo-hotzz/LogSentinel

GitHub: geo-hotzz/LogSentinel

一个专注于 SSH 日志分析的全栈安全检测平台,用于识别暴力破解攻击、关联攻击序列、检测横向移动并自动构建 MITRE ATT&CK 杀伤链。

Stars: 0 | Forks: 0

# 🛡️ LogSentinel [![Python](https://img.shields.io/badge/Python-3.8+-blue?style=flat-square&logo=python)](https://python.org) [![Flask](https://img.shields.io/badge/Flask-3.0-black?style=flat-square&logo=flask)](https://flask.palletsprojects.com) [![MITRE ATT&CK](https://img.shields.io/badge/MITRE%20ATT%26CK-T1110%20%7C%20T1078%20%7C%20T1021-red?style=flat-square)](https://attack.mitre.org) [![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)](LICENSE) ## 📌 概述 **LogSentinel** 是一个全栈网络安全检测平台,用于分析 SSH 认证日志以识别暴力破解攻击、关联攻击序列并检测横向移动——通过自动化风险评分组装完整的 MITRE ATT&CK 杀伤链 (Kill Chain)。 本项目是大学最后一年项目的成果,使用 Kali Linux → Metasploitable 2 实验室环境模拟真实世界的 SOC (Security Operations Center) 检测工作流程。 ## 🎯 功能 | 功能 | 描述 | |---|---| | 🔴 暴力破解检测 | 使用滑动窗口突发分析检测高频 SSH 登录失败 | | 🔗 序列关联 | 将失败连续记录 → 成功登录进行关联,以确认失陷 | | 🌐 横向移动检测 | 在可配置的时间窗口内追踪失陷后产生的新 SSH 连接 | | ⛓️ 杀伤链组装 | 自动构建 3 阶段 MITRE ATT&CK 杀伤链 | | 📊 风险评分引擎 | 基于 7 个指标进行加权评分,包含 CRITICAL/HIGH/SUSPICIOUS/NORMAL 等级 | | 🖥️ SOC 仪表盘 | 带有 Chart.js 可视化的交互式 Web 仪表盘 | | 📄 PDF 导出 | 生成多页专业 PDF 报告 | | 🔌 REST API | 用于程序化访问的 JSON API 端点 | ## 🗺️ MITRE ATT&CK 覆盖范围 ``` T1110.001 → Brute Force: Password Guessing T1078 → Valid Accounts (Post-Compromise) T1021.004 → Remote Services: SSH (Lateral Movement) ``` ## 🏗️ 架构 ``` ┌─────────────────────────────────────────────┐ │ Web Browser │ │ Upload logs / View Report │ └──────────────────┬──────────────────────────┘ │ ┌──────────────────▼──────────────────────────┐ │ Flask Web Service │ │ (app.py) │ └──────────────────┬──────────────────────────┘ │ ┌──────────────────▼──────────────────────────┐ │ Correlation Engine │ │ (correlation_engine.py) │ │ │ │ ┌────────────┐ ┌────────────────────────┐ │ │ │Log Parser │ │ Analysis Engine │ │ │ │ │→ │ - Burst Detection │ │ │ │ Regex │ │ - Sequence Correlation│ │ │ │ Patterns │ │ - Lateral Movement │ │ │ └────────────┘ │ - Off-Hour Anomaly │ │ │ │ - Session Anomaly │ │ │ └──────────┬─────────────┘ │ │ │ │ │ ┌──────────▼─────────────┐ │ │ │ Risk Scoring Engine │ │ │ │ Kill Chain Assembler │ │ │ └────────────────────────┘ │ └─────────────────────────────────────────────┘ ``` ## 🧪 实验室环境 ``` Attacker : Kali Linux (Hydra SSH brute force) Victim : Metasploitable 2 (auth.log collection) Network : Host-Only Adapter (isolated lab) ``` ## ⚙️ 安装说明 ### 前置条件 - Python 3.8+ - pip ### 设置 ``` # Clone 仓库 git clone https://github.com/YOUR_USERNAME/LogSentinel.git cd LogSentinel # 创建 virtual environment python -m venv .venv # 激活 virtual environment # Windows: .venv\Scripts\activate # Linux/Mac: source .venv/bin/activate # 安装依赖 pip install -r requirements.txt ``` ## 🚀 使用方法 ### Web 界面 ``` python app.py ``` 在浏览器中打开 `http://127.0.0.1:5000` —— 上传您的 `auth.log` 文件。 ### 命令行 ``` # 基本分析 python correlation_engine.py --file auth.log # 仅显示危险 IP python correlation_engine.py --file auth.log --risk-only # JSON 输出 python correlation_engine.py --file auth.log --json # 过滤特定 IP python correlation_engine.py --file auth.log --ip 192.168.56.101 ``` ### REST API ``` curl -X POST http://127.0.0.1:5000/api/analyze \ -F "logfile=@auth.log" ``` ## 📊 风险评分 | 指标 | 权重 | |---|---| | 登录尝试失败 | ×1 | | 被针对的用户数 | ×2 | | 非工作时间异常 | ×2 | | 检测到短会话 | ×3 | | 确认暴力破解序列 | ×4 | | 失败突发事件 | ×5 | | 检测到横向移动 | ×10 | | 分数 | 风险等级 | |---|---| | 0 – 4 | 🟢 NORMAL | | 5 – 9 | 🟡 SUSPICIOUS | | 10 – 19 | 🟠 HIGH | | 20+ | 🔴 CRITICAL | ## 📁 项目结构 ``` LogSentinel/ ├── app.py # Flask web service ├── correlation_engine.py # Core detection engine ├── requirements.txt # Python dependencies └── templates/ ├── index.html # Upload page └── dashboard.html # SOC dashboard + PDF export ``` ## 🔧 配置 可在 `correlation_engine.py` 顶部调整阈值: ``` BURST_WINDOW_MINUTES = 2 # Burst detection window BURST_COUNT_THRESHOLD = 5 # Failures to trigger burst SEQUENCE_MIN_FAILURES = 3 # Min failures before success = suspicious SEQUENCE_TIME_WINDOW_MINUTES = 10 # Max gap between failure and success LATERAL_WINDOW_MINUTES = 30 # Post-compromise monitoring window SESSION_SHORT_THRESHOLD_SEC = 10 # Short session anomaly threshold ``` ## 🛠️ 技术栈 | 层级 | 技术 | |---|---| | 后端 | Python 3, Flask | | 检测引擎 | 自定义 Python (Regex, Sliding Window, Correlation) | | 前端 | HTML5, CSS3, JavaScript | | 图表 | Chart.js 4.4 | | PDF 导出 | jsPDF + AutoTable | | 日志来源 | Linux auth.log (SSH / PAM) | ## 📚 参考资料 - [MITRE ATT&CK Framework](https://attack.mitre.org) - [Metasploitable 2](https://sourceforge.net/projects/metasploitable) - [Kali Linux](https://www.kali.org) - [Flask Documentation](https://flask.palletsprojects.com) ## 👤 作者 构建于大学最后一年项目 网络安全 — SOC / 蓝队 (Blue Team) 路线 ## 📄 许可证 本项目根据 MIT 许可证授权。
标签:Cloudflare, Flask, HTTP/HTTPS抓包, LogSentinel, MITRE ATT&CK, PDF报告生成, PE 加载器, Python, REST API, SSH暴力破解, Web仪表盘, 后端开发, 安全运营中心, 异常检测, 态势感知, 无后门, 杀伤链, 横向移动, 编程规范, 网络安全, 网络映射, 网络测绘, 计算机毕业设计, 隐私保护, 风险评分