Mukunda09/py-sentinel
GitHub: Mukunda09/py-sentinel
PySentinel 是一个基于 Python 和 FastAPI 构建的轻量级 SIEM 与 SOAR 平台,用于安全日志解析、威胁检测、事件关联及自动化响应。
Stars: 0 | Forks: 0
# PySentinel:自定义 Microsoft Sentinel SIEM 与 SOAR 引擎
[](https://www.python.org/)
[](https://fastapi.tiangolo.com/)
[](LICENSE)
[](https://attack.mitre.org/)
**PySentinel** 是一个轻量级、云原生启发的**安全信息与事件管理 (SIEM)** 和**安全编排、自动化与响应 (SOAR)** 平台,以 **Microsoft Sentinel** 为原型。
它专为安全分析师、威胁猎手和检测工程师设计,旨在帮助他们了解企业级 SIEM 平台如何摄取原始安全遥测数据、使用 ASIM 标准规范化数据、根据 MITRE ATT&CK 矩阵评估威胁分析、将原始告警关联为可操作的事件,以及执行自动化的遏制 playbook。
## 💡 为什么选择 PySentinel?
对于想要测试检测规则或学习 SOC 工作流的用户来说,搭建像 Microsoft Sentinel、Splunk 或 Elastic SIEM 这样的企业级 SIEM 可能既复杂又昂贵。
**PySentinel** 通过提供以下功能弥补了这一空白:
* **完整的 5 层 SIEM 架构**,在本地使用 Python 运行,零重型云端依赖。
* **ASIM 规范化**,用于标准化多供应商日志(Windows Event ID 4688 Process Creation、Sysmon、Syslog)。
* **实时威胁分析引擎**,直接映射到 MITRE ATT&CK TTP。
* **事件关联引擎**,将共享主机/用户实体的多个告警聚合为单一事件用例。
* **交互式 SVG 节点调查图谱**,直观追踪攻击者跨主机、身份和进程树的活动轨迹。
* **SOAR 自动化引擎**,用于执行一键或自动化的遏制操作(主机隔离、撤销用户会话、IP 黑名单)。
* **内置网络攻击模拟器**,用于实时测试检测工程。
## 🏗️ 平台架构
```
+---------------------------------------+
| 1. Log Collectors / Telemetry |
| (Windows Event 4688, Sysmon, CSV) |
+-------------------+-------------------+
|
v
+---------------------------------------+
| 2. ASIM Log Normalizer & Parser |
| (sentinel_core/parser.py) |
+-------------------+-------------------+
|
v
+---------------------------------------+
| 3. Storage & KQL Search Engine |
| (sentinel_core/storage.py) |
+---------+-------------------+---------+
| |
+----------------------+ +----------------------+
| |
v v
+---------------------------------------+ +---------------------------------------+
| 4. Threat Detection Engine | | 5. Incident & Investigation Engine |
| (sentinel_core/detection_engine.py)| | (sentinel_core/incident_manager.py)|
+--------------------+------------------+ +--------------------+------------------+
| |
+----------------------+ +----------------------+
| |
v v
+---------------------------------------+
| 6. SOAR Playbook Automation Engine |
| (sentinel_core/soar_playbooks.py) |
+-------------------+-------------------+
|
v
+---------------------------------------+
| 7. Security Operations Center Web UI |
| (FastAPI + Dark Glassmorphic Dashboard)|
+---------------------------------------+
```
## 📊 MITRE ATT&CK 检测覆盖范围
PySentinel 包含映射到真实世界攻击者战术和技术的内置检测规则:
| 规则 ID | 检测名称 | MITRE 战术 | 技术 ID | 严重程度 | 描述 |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **RULE-001** | Office Spawning PowerShell | Execution | `T1059.001` | **高** | Microsoft Word/Excel/Outlook 生成 PowerShell 解释器(宏恶意软件执行)。 |
| **RULE-002** | Encoded PowerShell Command | Defense Evasion | `T1027`, `T1059.001` | **中** | Base64 混淆的 PowerShell 执行(`-EncodedCommand` / `-enc`)。 |
| **RULE-003** | Living-off-the-Land Download | Command & Control | `T1105` | **高** | 通过 `certutil.exe`、`curl` 或 `bitsadmin` 进行入站工具传输,下载远程 payload。 |
| **RULE-004** | LSASS Memory Dumping | Credential Access | `T1003.001` | **严重** | 通过 `procdump`、`mimikatz` 或直接 LSASS 内存访问获取明文凭据。 |
| **RULE-005** | User-Writable Execution | Defense Evasion | `T1204` | **低** | 直接从 `%AppData%`、`%Temp%` 或 `/tmp` 目录执行二进制文件。 |
| **RULE-006** | Volume Shadow Copy Deletion | Impact | `T1490` | **严重** | 通过 `vssadmin delete shadows` 阻止系统恢复(勒索软件指标)。 |
## 📁 仓库结构
```
py_sentinel/
├── sentinel_core/
│ ├── __init__.py
│ ├── parser.py # ASIM Normalizer (Normalizes Windows 4688 / Sysmon telemetry)
│ ├── attack_map.py # MITRE ATT&CK Matrix mapping definitions
│ ├── detection_engine.py # Rule engine evaluating events against attack TTPs
│ ├── incident_manager.py # Correlates alerts into Incidents & generates SVG node-link graphs
│ ├── soar_playbooks.py # SOAR Playbooks (Host Isolation, User Revocation, IP Block)
│ ├── storage.py # Log storage engine & KQL query simulator
│ └── server.py # FastAPI REST API backend & static UI server
├── static/
│ ├── index.html # Glassmorphic Dark-Mode SOC Operations Center UI
│ ├── style.css # Custom CSS Design System (Glowing cards, badges, layouts)
│ └── app.js # Real-time dashboard updates & SVG graph renderer
├── main.py # PySentinel main server launcher
├── .gitignore # Git ignore configuration
└── README.md # Documentation
```
## ⚡ 快速入门指南
### 1. 前置条件
确保你已安装 Python 3.9+:
```
python --version
```
### 2. 安装所需依赖
```
pip install fastapi uvicorn
```
### 3. 启动 PySentinel SOC 服务器
```
python main.py
```
输出:
```
======================================================================
PySentinel: Custom Microsoft Sentinel SIEM & SOAR Platform
======================================================================
[*] Ingesting Windows Event 4688 Process Telemetry...
[*] Initializing ASIM Normalizer & Storage Engine...
[*] Loading Threat Analytics & MITRE ATT&CK Rules Engine...
[*] Starting Incident Correlation & Graph Visualization Engine...
[*] Arming SOAR Automated Response Playbooks...
----------------------------------------------------------------------
Launching PySentinel Web Security Operations Center at:
-> http://127.0.0.1:8000
======================================================================
```
### 4. 打开安全运营中心 (SOC)
打开浏览器并导航至:
👉 **`http://127.0.0.1:8000`**
## 🧪 测试攻击模拟器
PySentinel 包含一个交互式攻击模拟实验室,用于测试实时检测、告警关联和自动化 playbook 执行:
### 选项 A:通过 Web UI
1. 点击页眉或概览选项卡中的 **“⚡ Simulate Attack”** 按钮。
2. 选择任意攻击向量(*宏恶意软件*、*混淆的 PowerShell*、*凭据转储*、*勒索软件*)。
3. 观察实时的日志摄取、告警创建、事件升级以及自动执行的 SOAR 操作。
### 选项 B:通过 REST API
```
curl -X POST "http://127.0.0.1:8000/api/simulate-attack" \
-H "Content-Type: application/json" \
-d '{"attack_type": "credential_dump", "host": "FINANCE-SRV-01", "user": "sec_admin"}'
```
## 📜 License
基于 **MIT License** 分发。查看 `LICENSE` 了解更多信息。
标签:AMSI绕过, AV绕过, FastAPI, Python, SOAR, 威胁检测, 安全运营中心 (SOC), 无后门, 逆向工具