babayega286/SAP-Security-Monitor-Azure-Sentinel-Integration

GitHub: babayega286/SAP-Security-Monitor-Azure-Sentinel-Integration

一个将 SAP 安全审计日志接入 Azure Sentinel 的 Python 集成方案,填补 SAP 事件在 SIEM 中的监控盲区。

Stars: 0 | Forks: 0

# SAP Security Monitor — Azure Sentinel 集成 ![Python](https://img.shields.io/badge/Python-3.10+-blue?logo=python) ![Azure](https://img.shields.io/badge/Azure-Sentinel-0078D4?logo=microsoftazure) ![SAP](https://img.shields.io/badge/SAP-ERP%20Integration-0FAAFF?logo=sap) ![Status](https://img.shields.io/badge/Status-In%20Development-orange) ## 概述 大型企业在 SAP 上运行其核心业务流程。然而,SAP 安全事件很少被集成到现代 SIEM 平台中,这为 SOC 团队留下了关键盲区。此项目填补了这一空白。 **其功能:** - 从 SAP 提取与安全相关的事件(失败登录、权限提升、RFC 调用、基础架构事务) - 将日志规范化和格式化为 **CEF(通用事件格式)** - 通过 REST API 推送到 **Azure Log Analytics 工作区** - 触发 **Azure Sentinel 中的基于 KQL 的检测规则** 以生成告警 - 在 **Azure Workbook 仪表板** 中可视化事件 ## 架构 ``` ┌─────────────────────────────────────────────────────┐ │ SAP ERP System │ │ SM20 Audit Log · SU01 Auth · RFC calls · SE38 │ └──────────────┬──────────────────────────────────────┘ │ SAP RFC / file export ▼ ┌─────────────────────────────────────────────────────┐ │ Python Connector (this project) │ │ log_parser.py · normaliser.py · cef_formatter.py │ │ sentinel_pusher.py · scheduler (cron / daemon) │ └──────────────┬──────────────────────────────────────┘ │ HTTPS REST (Azure Data Collector API) ▼ ┌─────────────────────────────────────────────────────┐ │ Azure Sentinel / Log Analytics │ │ Custom log table: SAP_SecurityEvents_CL │ │ KQL detection rules · Alert incidents │ └──────────────┬──────────────────────────────────────┘ │ ┌───────┴────────┬──────────────┐ ▼ ▼ ▼ Azure Workbook Email Alert SOAR Playbook (Dashboard) (Logic App) (Auto-remediation) ``` ## 技术栈 | 层级 | 技术 | 原因 | |---|---|---| | 日志源 | SAP ERP(开发者试用版) | 真实的 SAP 事件 | | 连接器 | Python 3.10+ | 解析、格式化、REST 调用 | | 传输 | Azure Data Collector API | 官方日志摄入端点 | | SIEM | Azure Sentinel(免费学生层级) | | 查询 | KQL(Kusto 查询语言) | 原生 Sentinel 查询语言 | | 可视化 | Azure Workbook | 内置,无需额外工具 | | 可选 | Power BI | ## 项目结构 ``` sap-azure-sentinel/ │ ├── README.md ├── requirements.txt ├── .env.example # Template for credentials (never commit .env) ├── config/ │ └── settings.yaml # Log table names, field mappings │ ├── connector/ │ ├── __init__.py │ ├── sap_extractor.py # Reads SAP SM20 audit log (RFC or file) │ ├── log_parser.py # Parses raw SAP log format into dicts │ ├── normaliser.py # Maps SAP fields → standard schema │ ├── cef_formatter.py # Converts to CEF string format │ └── sentinel_pusher.py # POSTs to Azure Data Collector API │ ├── detection_rules/ │ ├── brute_force_login.kql # 5+ failed logins in 10 min │ ├── privilege_escalation.kql # SU01 role changes │ ├── suspicious_rfc.kql # RFC calls to sensitive function modules │ └── after_hours_access.kql # Logins outside business hours │ ├── dashboard/ │ └── sap_workbook_template.json # Azure Workbook ARM template │ ├── tests/ │ ├── test_parser.py │ ├── test_normaliser.py │ ├── test_cef_formatter.py │ └── sample_logs/ │ └── sm20_sample.txt # Anonymised SAP log samples for testing │ ├── docs/ │ ├── setup_azure.md # Step-by-step Azure Sentinel setup │ ├── setup_sap_trial.md # How to get SAP Developer trial │ └── screenshots/ # Dashboard screenshots │ └── scripts/ ├── run_connector.py # Entry point (can be run as daemon) └── test_connection.py # Verifies Azure + SAP connectivity ``` ## 快速开始 ### 前置条件 - Python 3.10+ - Azure 账户(在 [azure.microsoft.com/free/students](https://azure.microsoft.com/free/students) 免费试用) - SAP 开发者试用版(在 [developers.sap.com](https://developers.sap.com))— 免费,无需信用卡 - 已创建 Azure Sentinel 工作区(参见 `docs/setup_azure.md`) ### 安装 ``` git clone https://github.com/YOUR_USERNAME/sap-azure-sentinel.git cd sap-azure-sentinel pip install -r requirements.txt cp .env.example .env # 使用您的 Azure 工作区 ID 和共享密钥编辑 .env ``` ### 配置 ``` # .env AZURE_WORKSPACE_ID=your-workspace-id-here AZURE_SHARED_KEY=your-shared-key-here SAP_HOST=localhost # or your SAP trial host SAP_CLIENT=001 SAP_USER=your_sap_user SAP_PASSWORD=your_sap_password LOG_TABLE_NAME=SAP_SecurityEvents_CL ``` ### 运行 ``` python scripts/test_connection.py # Verify connectivity python scripts/run_connector.py # Start the connector ``` ## 检测规则 `detection_rules/` 中包含 KQL 示例: **暴力登录检测:** ``` SAP_SecurityEvents_CL | where EventType_s == "Failed_Login" | summarize FailedCount = count() by User_s, bin(TimeGenerated, 10m) | where FailedCount >= 5 | project TimeGenerated, User_s, FailedCount ``` **非工作时间的高权限访问:** ``` SAP_SecurityEvents_CL | where EventType_s == "Login_Success" | where User_s in (privileged_users) | where hourofday(TimeGenerated) !between (8 .. 18) | project TimeGenerated, User_s, SourceIP_s ``` ## 路线图 - [x] 项目结构和文档 - [ ] SAP 日志提取器(用于试用环境的 SM20 文件解析) - [ ] CEF 标准化器和 Azure REST 推送器 - [ ] KQL 检测规则(4 条初始规则) - [ ] Azure Workbook 仪表板模板 - [ ] 通过 Logic App 的邮件告警 - [ ] 单元测试和 CI(GitHub Actions) - [ ] 可能的 Power BI 集成;-) ## 展示的技能 本项目作为我在 M.Sc. in Cybersecurity(柏林 IU)学习旅程的一部分,旨在展示以下能力领域: - **SIEM 集成** — 真实的日志管道设计 - **SAP 安全** — 理解 SAP 审计架构(SM20、SU01、RFC) - **云安全** — Azure Sentinel、Log Analytics、Logic Apps - **Python 开发** — 面向对象编程、REST API 调用、日志解析 - **威胁检测** — 用于异常检测的 KQL 查询编写 - **GRC 对齐** — 检测规则映射到 ISO 27001 A.9(访问控制)和 A.12(操作安全) ## 关于 **JesweenS** — 柏林 IU International University of Applied Sciences 的网络安全硕士学生。 [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0A66C2?logo=linkedin)](https://www.linkedin.com/in/jesween-s-420masterstudent) [![GitHub](https://img.shields.io/badge/GitHub-babayega286-181717?logo=github)](https://github.com/babayega286) ## 免责声明 本项目使用 SAP 开发者试用系统和匿名/合成日志数据。不使用生产 SAP 数据。所有凭证存储在环境变量中且从未提交到仓库。
标签:Azure Log Analytics, Azure Sentinel, CEF, Common Event Format, KQL检测规则, Microsoft Defender SIEM, Mutation, Python, RFC调用, SAP, SAP审计, SIEM集成, 代理支持, 仪表盘, 企业审计, 协议分析, 可视化, 告警, 失败登录, 守护进程, 安全运营, 实时威胁检测, 扫描框架, 无后门, 日志规范化, 日志转发, 日志采集, 权限提升, 调度, 运维