tsmanral/lsadra

GitHub: tsmanral/lsadra

一款开源可解释的自托管 SIEM 平台,结合多层 ML 检测与 SHAP 可解释性,为安全团队提供实时多源日志分析和人类可读的威胁叙述。

Stars: 1 | Forks: 0

# 🛡️ LSADRA ### 本地安全异常检测与风险评估 — 开源、可解释、构建为可在任何地方运行。 **实时、多源日志检测,结合 ML 集成、SHAP 可解释性以及人类可读的威胁叙述 — 无需 LLM API 密钥。**
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg?style=flat-square)](LICENSE) [![Python 3.12](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat-square&logo=python&logoColor=white)](https://www.python.org/) [![FastAPI](https://img.shields.io/badge/FastAPI-API-009688.svg?style=flat-square&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/) [![React](https://img.shields.io/badge/React-Dashboard-61DAFB.svg?style=flat-square&logo=react&logoColor=black)](frontend/) [![Tests](https://img.shields.io/badge/smoke_tests-27%2F27_passing-brightgreen.svg?style=flat-square)](tests/test_v4_smoke.py) [![GitHub Stars](https://img.shields.io/github/stars/tsmanral/lsadra?style=flat-square)](https://github.com/tsmanral/lsadra/stargazers)
## 为什么选择 LSADRA? 像 Splunk 和 Microsoft Sentinel 这样的企业级 SIEM 功能强大 — 但同时也显得笨重、昂贵且不透明。轻量级的消费级工具虽然能监控网络,但缺乏真正的检测智能。**LSADRA 填补了这一空白**:这是一个可自托管的 SOC 平台,能够解释*为什么*会触发每一个警报。 - 🧠 **多层 ML 检测** — 统计基线(Z-score)、集成模型(Isolation Forest、LOF、One-Class SVM)和 PyTorch autoencoder,并通过 Population Stability Index 进行漂移跟踪。 - 🔍 **天生可解释** — SHAP 特征归因,带有每个警报的纯英文详细说明的复合严重性评分,以及带有置信度分数的 MITRE ATT&CK 技术映射。 - 🌐 **多源摄取** — 用于 SSH 身份验证日志、Syslog、Windows Events、网络流(NetFlow / 防火墙)和端点遥测的解析器,全部通过单一的原始日志 API 完成。 - 📖 **无需 LLM 的威胁叙述** — 一个纯模板的案件文件生成器将相关的异常转化为可读的事件故事。零 API 密钥,零经常性成本。 - 🚨 **关键的检测规则** — 暴力破解、撞库、端口扫描、数据泄露、LOLBin 滥用、持久化和横向移动,所有这些都带有可调阈值和分析师反馈循环。 - 📊 **全功能 SOC 仪表板** — 现代化的 React (Vite) 指挥中心,具有实时威胁源、事件钻取、多源健康状态、威胁情报(AbuseIPDB)、模型分析、设备行为、反馈和阈值调整,以及带有 RBAC + JWT 身份验证的管理功能。还包括传统的 Streamlit 界面。 ## 快速开始 ``` # 1. Clone 并设置 git clone https://github.com/tsmanral/lsadra.git cd lsadra py -3.12 -m venv venv # Linux/macOS: python3.12 -m venv venv venv/Scripts/pip install -r requirements.txt # Linux/macOS: venv/bin/pip # 2. 启动 API server(首次启动时创建数据库) venv/Scripts/python -m uvicorn server:app --host 0.0.0.0 --port 8000 # 3. 在第二个终端中,启动 React dashboard cd frontend npm install npm run dev ``` 打开 **http://localhost:5173**,注册一个账号,并从 **Connect Device** 页面连接你的第一台设备 — 它会为任何 Linux 主机生成一行安装命令。Linux agent 会自动检测系统使用的是 `/var/log/auth.log` 还是 `journalctl`。在 Windows 上,`python windows_agent_simulator.py` 会启动一个本地测试 agent。 验证完整 pipeline(解析器、规则、严重程度、叙述、数据库、调度程序): ``` venv/Scripts/python tests/test_v4_smoke.py # expected: 27/27 passed ``` ### Docker(生产环境) ``` cp .env.example .env # set JWT secrets, TLS flags, optional AbuseIPDB key docker compose up -d ``` 这将启动 API (`:8000`)、传统的 Streamlit 仪表板 (`:8501`) 和一个空闲的 agent 模拟器。每次发布时,还会将带有版本号的 Docker 镜像发布到 [GHCR](https://github.com/tsmanral/lsadra/pkgs/container/lsadra)。 ## 摄取日志 来自任何来源的任何日志行,都可以通过一个端点处理: ``` curl -X POST http://localhost:8000/api/events/raw \ -H "Content-Type: application/json" \ -H "X-Device-Id: " -H "X-Api-Key: " \ -d '{"lines": [{"raw_line": "Jan 5 12:34:56 server sudo[999]: root : COMMAND=/bin/bash", "source_hint": "syslog"}]}' ``` 每个来源的摄取健康状况可在 `GET /api/events/stats` 获取。 ## 架构 ``` graph TD A[Endpoint Agents] -->|HTTPS + API Key| B[Ingestion API] R[Raw Log Sources] -->|HTTPS + API Key| V[Raw Ingestion API] V --> IM[Ingestion Manager
Syslog · Windows · NetFlow · Endpoint · SSH] IM --> FE[Feature Extractor] B --> C[Detection Orchestrator
Z-Score · ML Ensemble · Autoencoder] FE --> RE[Rule Engine + Lateral Movement] RE --> SV[Dynamic Severity Scoring] C --> SV SV --> INC[Incident Grouping] INC --> NB[Narrative Builder
SHAP + MITRE ATT&CK] NB --> DB[(SQLite)] DB --> DASH[React SOC Dashboard] ``` 更深入的技术演练请参阅 [ARCHITECTURE.md](ARCHITECTURE.md),平台的设计演进记录在 [docs/V3_VS_V4_EVOLUTION.md](docs/V3_VS_V4_EVOLUTION.md) 中。 后台作业(APScheduler)处理跨源关联、横向移动扫描、指标预聚合、地理解析、威胁情报缓存、漂移检测和数据保留 — 无需外部队列或 cron。 ## 项目结构 ``` lsadra/ Core platform: auth, ingestion, detection, storage, scheduler, legacy UI frontend/ React (Vite + TypeScript) SOC dashboard tests/ Test suite + end-to-end smoke tests datasets/ Synthetic SSH log generator for local experimentation fleet_simulator.py Multi-device fleet traffic simulator windows_agent_simulator.py All-in-one Windows test agent windows_live_agent.py Live Windows event agent server.py FastAPI entry point ``` ## 许可证 基于 **GNU Affero General Public License v3.0** 分发。详情请参阅 [LICENSE](LICENSE)。 ## 项目状态 [![Latest Release](https://img.shields.io/github/v/release/tsmanral/lsadra?style=flat-square&logo=github&label=Release)](https://github.com/tsmanral/lsadra/releases) [![Last Commit](https://img.shields.io/github/last-commit/tsmanral/lsadra?style=flat-square&logo=git&logoColor=white)](https://github.com/tsmanral/lsadra/commits/main) [![Commit Activity](https://img.shields.io/github/commit-activity/m/tsmanral/lsadra?style=flat-square&label=Commits)](https://github.com/tsmanral/lsadra/graphs/commit-activity) [![Open Issues](https://img.shields.io/github/issues/tsmanral/lsadra?style=flat-square)](https://github.com/tsmanral/lsadra/issues) [![Repo Size](https://img.shields.io/github/repo-size/tsmanral/lsadra?style=flat-square)](https://github.com/tsmanral/lsadra) [![Container Image](https://img.shields.io/badge/GHCR-lsadra-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/tsmanral/lsadra/pkgs/container/lsadra) 正在积极开发中 — 路线图涵盖从强化的核心(安全修复、异步摄取)到 Rust 收集器 agent、Tauri 桌面 UI、本地 LLM 叙述以及移动端伴侣应用。请关注 [Releases](https://github.com/tsmanral/lsadra/releases) 了解进展。 ## 作者 **Tribhuwan Singh** [![GitHub](https://img.shields.io/badge/GitHub-tsmanral-181717?style=flat-square&logo=github)](https://github.com/tsmanral) [![LinkedIn](https://img.shields.io/badge/LinkedIn-singhtribh-0A66C2?style=flat-square&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/singhtribh/) [![Portfolio](https://img.shields.io/badge/Portfolio-tsmanral.github.io-24292F?style=flat-square&logo=githubpages&logoColor=white)](https://tsmanral.github.io/) [![Email](https://img.shields.io/badge/Email-tribhuwan.singh1108%40gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white)](mailto:tribhuwan.singh1108@gmail.com) ## 贡献者 感谢所有对 LSADRA 做出贡献的人: Contributors
⭐ 如果 LSADRA 对您有帮助,请考虑为该仓库加星 — 这有助于让更多人了解这个项目。
标签:Apex, AV绕过, FastAPI, Kubernetes, Python, React, Syscalls, 凭据扫描, 安全监控, 安全运营, 异常检测, 扫描框架, 无后门, 机器学习, 请求拦截, 逆向工具