HunterBFranklin/helm-siem

GitHub: HunterBFranklin/helm-siem

基于 Docker + Wazuh + ELK Stack 构建的自托管 SIEM 系统,实现端点威胁检测、MITRE ATT&CK 映射和自动化邮件报告的一体化安全监控。

Stars: 0 | Forks: 0



一个使用 Docker、Wazuh 和 Elasticsearch/Logstash/Kibana (ELK) Stack 从零开始构建的自托管安全信息与事件管理 (SIEM) 系统。 该系统实时监控活跃的端点,检测包括暴力破解尝试、权限提升、文件完整性违规和 CVE 漏洞在内的各种威胁,并自动将每个警报映射到 MITRE ATT&CK 框架。 安全事件从两个活跃端点(一台 Apple Silicon MacBook Pro M3 和一台在 UTM 中运行的 Ubuntu 22.04 LTS 虚拟机)收集,并被输入到在 Docker 中运行的集中式 Wazuh 管理器中。模块化的 Python 自动化层直接查询 Elasticsearch API,以生成跨三个严重级别(严重、高和所有警报)的分层报告,提供格式完整的 HTML 电子邮件报告,其中包含严重性细分、MITRE 技术条形图和颜色编码的警报详细信息。 除了检测之外,该系统还集成了 Fail2Ban 用于自动威胁响应——自动封禁触发重复 SSH 失败的 IP——并将安装的软件包与美国国家漏洞数据库进行交叉引用,以进行持续的 CVE 监控。针对 PCI DSS、HIPAA、NIST 800-53 和 GDPR 的合规性映射在每个受监控端点的后台被动运行。 _这是一个持续进行的个人项目,记录了我深入探索网络安全工程、安全自动化、网络工程和基础设施的旅程。它最初只是一个基础的 Wazuh 部署,现在已经发展成为一个结构化、带有版本控制的安全运营平台,并计划将家庭实验室、家庭服务器和 VPN 集成作为下一阶段的扩展。_ ## 截图

v2.0 — 当前版本

v1.0 — 初始版本

## 它的功能 - 从两个端点收集安全事件:我的 MacBook Pro M3 和一台在 Apple Silicon 上的 UTM 中运行的 Ubuntu 22.04 LTS VM - 检测威胁,包括暴力破解尝试、登录失败、权限提升、文件完整性违规和未经授权的 SSH 访问 - 在多次 SSH 登录失败后,通过 Fail2Ban 集成自动封禁恶意 IP - 自动将每个警报映射到 MITRE ATT&CK 技术和战术 - 扫描受监控端点,查找与 NVD 数据库交叉引用的已知 CVE - 运行三个严重级别的 Python 脚本(严重、高、全部),通过 REST API 直接查询 Elasticsearch - 交付格式完整的 HTML 电子邮件报告,包含严重性细分、MITRE 条形图和颜色编码的警报详细信息 - 自动将所有时间戳从 UTC 转换为本地时间 - 根据 PCI DSS、HIPAA、NIST 800-53 和 GDPR 框架监控合规性 - 主运行器通过单个命令按顺序执行所有三个报告层级 ## 技术栈 | 工具 | 用途 | |---|---| | Wazuh 4.14.5 | HIDS、日志收集、漏洞检测 | | Elasticsearch | 事件存储和索引 | | Docker + Compose | 在容器中运行整个技术栈 | | Ubuntu 22.04 LTS ARM64 | 受监控的 Linux VM 端点 | | UTM | Apple Silicon 上的虚拟化 | | Python 3 | 警报自动化和电子邮件报告 | | macOS (M3 Pro) | 宿主机 | ## 我是如何设置的 ### 要求 - Docker Desktop (Apple Silicon) - Python 3 - UTM - Ubuntu 22.04.5 LTS ARM64 Server ISO ### 启动 Wazuh: ``` git clone https://github.com/wazuh/wazuh-docker.git -b v4.14.5 cd wazuh-docker/single-node docker compose -f generate-indexer-certs.yml run --rm generator docker compose up -d ``` ### 仪表盘: ``` https://localhost Username: admin Password: SecretPassword ``` ### Python 警报脚本: ``` pip3 install -r requirements.txt cp scripts/.env.example scripts/.env # 填写您的 credentials python3 scripts/alert_notifier.py ``` ## 一个真正起作用的案例 在系统运行期间,Wazuh 自动在 Ubuntu VM 上标记了 **CVE-2026-26066**;这是一个中等严重性的 ImageMagick 漏洞 (CVSS 6.2),可通过精心设计的图像配置文件导致拒绝服务。我并没有手动触发任何东西——它就出现在了仪表盘中。 我在 NVD 上查阅了它,确认它是真实的,使用 `sudo apt upgrade` 进行了修补,并看着它从发现列表中清除。这整个周期——检测、研究、修复、验证——让我体会到了这个项目的意义所在。 ## 项目结构 ``` selfhosted-siem-system/ ├── scripts/ │ ├── run.py # master runner — executes all three reports in sequence │ ├── critical_alerts.py # level 12+ severity only │ ├── high_alerts.py # level 7-11 severity │ ├── all_alerts.py # all alerts level 1+ │ ├── config.py # centralized configuration and env variables │ ├── elasticsearch_client.py # Elasticsearch API queries │ ├── formatter.py # HTML report formatting and template building │ ├── email_reporter.py # HTML email construction and delivery │ ├── utility.py # shared helper functions and terminal output │ ├── daily_recap.py # main daily recap orchestrator (v3.0) │ ├── recap_formatter.py # builds the daily recap HTML email (v3.0) │ ├── scheduler.py # toggle on/off, handles 8 PM PST scheduling (v3.0) │ ├── .env # local credentials — never committed │ └── .env.example # credential template — safe to commit ├── templates/ │ └── email_template.html # HTML email template (v3.0) ├── logs/ │ └── alert.log # script output log (v3.0) ├── screenshots/ │ ├── wazuh-dashboard.png │ ├── vm-desktop.png │ ├── neofetch.png │ ├── terminal-report.png │ └── email-report.png ├── docs/ # additional documentation ├── requirements.txt # Python dependencies ├── .gitignore # protects credentials from Git └── README.md ``` ## 已完成和接下来的计划 已完成: - Wazuh + ELK Stack 在 Docker 中运行 - Ubuntu VM 和 MacBook Pro 均受监控 - Fail2Ban 已安装,带有子网白名单,用于自动化的 SSH 封禁检测 - 模块化的 Python 架构 — config、elasticsearch_client、formatter、email_reporter、utility - 三个严重级别的运行器 — 严重 (12-15)、高 (7-11)、全部 (1+) - 主运行器按顺序执行所有三个报告 - 全面重新设计的 HTML 电子邮件,带有兼容 Gmail 的表格布局 - 严重性细分卡片匹配 Wazuh 规则级别标准 (1-3/4-6/7-11/12-15) - 用于 MITRE ATT&CK 技术的 CSS 水平条形图 - 警报详情中颜色编码的严重性徽章和技术气泡 - 所有时间戳上的 UTC 到本地时区转换 - 真实 CVE 的检测、调查和修复 (CVE-2026-26066) - 使用 python-dotenv 保护凭证 - 记录 v1.0 和 v2.0 进展的版本化截图 接下来: - 用于自动定时报告的 Cron job - 针对新设备加入网络的 SMS 警报 (Twilio) - 自定义 Wazuh 检测规则 - 用于网络流量分析的 Suricata - JavaScript 自定义仪表盘 - 今年晚些时候拿到 PC 后加入 Windows 端点 - 最终将其连接到带有家庭服务器和 VPN 的完整家庭实验室 ## 路线图 ``` - [x] Wazuh + ELK stack deployed via Docker - [x] Ubuntu VM monitored endpoint - [x] MacBook Pro agent connected - [x] Python alert notifier querying the Elasticsearch API - [x] Modular Python architecture - [x] Three severity tier runners - [x] HTML email with severity charts and MITRE breakdown - [x] Fail2Ban integration - [x] Real CVE detected and remediated (CVE-2026-26066) - [x] Credentials secured with python-dotenv - [x] Published to GitHub - [ ] Cron job scheduling - [ ] SMS alerting via Twilio - [ ] Custom Wazuh detection rules - [ ] Suricata network traffic analysis - [ ] JavaScript custom dashboard - [ ] Windows endpoint agent - [ ] Home server integration - [ ] VPN monitoring ``` ## 版本 **v3.0 — 开发中** - 每日回顾电子邮件 — 晚上 8 点 PST 发送的 24 小时回顾摘要 - 专用的回顾编排器 (daily_recap.py),独立于实时警报运行器 - 专用的回顾 HTML 格式化器 (recap_formatter.py),带有扩展部分 - 包含完整详情的最重要的前 10 个警报 — 规则级别、MITRE 技术、战术、合规框架 - 完整的 MITRE ATT&CK 摘要 — 检测到的技术总数及完整细分和条形图 - Fail2Ban 活动部分 — 封禁总数、被封禁的 IP、受影响的代理、时间戳 - 网络活动部分 — 端口更改、新连接、监听端口 - 活跃代理摘要 — 所有报告代理及其 24 小时警报计数 - 其余警报活动 — 前 10 名之外的所有警报,按规则和计数汇总 - 调度器 (scheduler.py),带有简单的 ENABLED 开关用于开启/关闭控制 - 通过 schedule 库实现晚上 8 点 PST 自动调度 - 调度器日志记录到 logs/scheduler.log - HTML 电子邮件模板提取到 templates/email_template.html - 用于自动定时报告的 Cron job - 用于网络流量分析的 Suricata - 自定义 Wazuh 检测规则 **v2.0 — 2026 年 5 月** - 模块化的 Python 架构 — config、elasticsearch_client、 formatter、email_reporter、utility - 三个严重级别的运行器 — 严重 (12-15)、高 (7-11)、全部 (1+) - 主运行器 (run.py) 按顺序执行所有三个运行器 - 全面重新设计的 HTML 电子邮件,带有兼容 Gmail 的表格布局 - 严重性细分卡片匹配 Wazuh 规则级别标准 - 用于 MITRE ATT&CK 技术的 CSS 水平条形图 - 技术:警报详情中颜色编码的气泡 - 所有时间戳的 UTC 到本地时间转换 - 带有回溯窗口上下文的活跃代理列表 - 用于自动 SSH 封禁检测的 Fail2Ban 集成 - 使用 python-dotenv 确保凭证安全 **v1.0 — 2026 年 5 月** - 通过 Docker 部署 Wazuh + ELK Stack - Ubuntu VM 和 MacBook Pro 受到监控 - 查询 Elasticsearch API 的单个 Python 脚本 - 通过 Gmail SMTP 传递纯文本电子邮件 - 检测并修复了真实的 CVE (CVE-2026-26066) ## 参考 **基础设施:** - [Wazuh 文档](https://documentation.wazuh.com) - [Wazuh Docker 部署](https://documentation.wazuh.com/current/deployment-options/docker/wazuh-container.html) - [Wazuh GitHub](https://github.com/wazuh/wazuh-docker) - [Wazuh 代理注册](https://documentation.wazuh.com/current/user-manual/agent/agent-enrollment/index.html) - [Docker 文档](https://docs.docker.com) - [Docker Compose 参考](https://docs.docker.com/compose/) - [UTM 虚拟化](https://docs.getutm.app) - [Ubuntu Server ARM64](https://cdimage.ubuntu.com/releases/22.04/release/) - [Fail2Ban 文档](https://www.fail2ban.org/wiki/index.php/Main_Page) - [Fail2Ban GitHub](https://github.com/fail2ban/fail2ban) - [Fail2Ban — Wazuh 集成](https://documentation.wazuh.com/current/user-manual/capabilities/active-response/default-active-response-scripts.html) - [LightDM 显示管理器](https://wiki.ubuntu.com/LightDM) - [XFCE 桌面环境](https://www.xfce.org) **ELK Stack:** - [Elasticsearch REST API](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html) - [Elasticsearch 查询 DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) - [Elasticsearch 范围查询](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html) - [Elasticsearch Python 客户端](https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/index.html) - [Kibana 文档](https://www.elastic.co/guide/en/kibana/current/index.html) - [Logstash 文档](https://www.elastic.co/guide/en/logstash/current/index.html) **安全框架:** - [MITRE ATT&CK 框架](https://attack.mitre.org) - [MITRE ATT&CK — 暴力破解 T1110](https://attack.mitre.org/techniques/T1110/) - [MITRE ATT&CK — Sudo 缓存 T1548.003](https://attack.mitre.org/techniques/T1548/003/) - [MITRE ATT&CK — 密码猜测 T1110.001](https://attack.mitre.org/techniques/T1110/001/) - [NVD — 国家漏洞数据库](https://nvd.nist.gov) - [CVE 数据库](https://cve.mitre.org) - [NIST 网络安全框架](https://www.nist.gov/cyberframework) - [NIST 800-53 控制措施](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final) - [CVE-2026-26066 公告](https://github.com/advisories/GHSA-v994-63cg-9wj3) - [PCI DSS 标准](https://www.pcisecuritystandards.org) - [HIPAA 安全规则](https://www.hhs.gov/hipaa/for-professionals/security/index.html) - [GDPR 官方文本](https://gdpr-info.eu) **Python 库:** - [Requests](https://docs.python-requests.org) - [urllib3](https://urllib3.readthedocs.io) - [python-dotenv](https://pypi.org/project/python-dotenv/) - [smtplib](https://docs.python.org/3/library/smtplib.html) - [email.mime](https://docs.python.org/3/library/email.mime.html) - [datetime](https://docs.python.org/3/library/datetime.html) - [json](https://docs.python.org/3/library/json.html) - [schedule](https://schedule.readthedocs.io) **电子邮件开发:** - [Gmail SMTP 设置](https://support.google.com/mail/answer/7126229) - [Gmail 应用密码](https://support.google.com/accounts/answer/185833) - [HTML 电子邮件兼容性 — Can I Email](https://www.caniemail.com) - [HTML 电子邮件最佳实践](https://www.litmus.com/blog/html-email-best-practices) - [Gmail CSS 支持](https://developers.google.com/gmail/design/css) **桌面环境:** - [XFCE](https://www.xfce.org) - [LightDM GTK Greeter](https://github.com/Xubuntu/lightdm-gtk-greeter) - [Oh My Zsh](https://ohmyz.sh) - [Neofetch](https://github.com/dylanaraps/neofetch) - [Terminator 终端](https://gnome-terminator.org) - [Firefox for Linux](https://www.mozilla.org/en-US/firefox/linux/) **Git & GitHub:** - [Git 文档](https://git-scm.com/doc) - [GitHub 个人访问令牌](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) - [Git Stash](https://git-scm.com/docs/git-stash) - [Git Rebase](https://git-scm.com/docs/git-rebase) **README 设计:** - [Shields.io](https://shields.io) - [GitHub Markdown 语法](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) - [GitHub 表格格式化](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables) - [Best README 模板](https://github.com/othneildrew/Best-README-Template) - [Awesome README](https://github.com/matiassingers/awesome-readme) **社区:** - [r/homelab](https://reddit.com/r/homelab) - [r/selfhosted](https://reddit.com/r/selfhosted) - [r/cybersecurity](https://reddit.com/r/cybersecurity) - [r/netsec](https://reddit.com/r/netsec) - [Wazuh 社区](https://wazuh.com/community) - [ServeTheHome](https://www.servethehome.com) [@HunterBFranklin](https://github.com/HunterBFranklin) — MIT 许可证
标签:AMSI绕过, ATT&CK框架, CISA项目, Cloudflare, CSV导出, CVE漏洞监控, Docker, Elasticsearch, ELK Stack, Fail2Ban, GDPR, HIPAA, Homelab, HTML邮件报告, IP 地址批量处理, Logstash, MacBook监控, MITRE ATT&CK, NIDS, NIST 800-53, PCI DSS, PE 加载器, PoC, Python, SSH安全, Wazuh, x64dbg, 个人安全项目, 内容过滤, 协议分析, 合规监控, 威胁检测, 安全信息与事件管理, 安全可视化, 安全工程, 安全运营, 安全防御评估, 家庭实验室, 容器化, 扫描框架, 搜索引擎爬取, 无后门, 暴力破解, 权限提升, 端点监控, 红队行动, 网络安全, 网络工程, 自动化报告, 自动封禁, 自建SIEM, 请求拦截, 越狱测试, 逆向工具, 隐私保护