philipzangara/linux-stig-siem-monitoring

GitHub: philipzangara/linux-stig-siem-monitoring

这是一个结合 OpenSCAP 系统加固与 Splunk 可视化分析的项目,基于 Ubuntu 24.04 构建了一套映射至 MITRE ATT&CK 的持续安全监控与合规追踪流水线。

Stars: 0 | Forks: 0

# Linux 安全监控仪表板 — Ubuntu 24.04 STIG 加固 一个基于 STIG 加固的 Ubuntu 24.04 虚拟机构建的 Linux 安全监控管道,其检测项映射至 MITRE ATT&CK。该项目结合了 OpenSCAP 系统强化与 Splunk SIEM 仪表板,以持续监控安全事件。 ## 项目概述 起点是一个全新的 Ubuntu 24.04 安装,使用 OpenSCAP 针对 DoD STIG V1R1 基准进行评估。该基准涵盖了数百个涉及访问控制、审计日志、身份验证和网络安全等方面的控制项。在应用自动修复和手动配置之后,Splunk Universal Forwarder 会将四个实时日志源转发到一个专用索引。一个包含八个面板的仪表板将这些遥测数据映射到具体的 MITRE ATT&CK 技术。 随后通过禁用防火墙和添加可疑 cron 任务来模拟配置漂移。这两个事件都会在仪表板中显现,早于计划扫描发现它们的时间。一个 cron 任务每天运行 OpenSCAP 并自动记录合规性分数,因此分数历史记录会自动更新,无需人工干预。 ## 架构 ``` Ubuntu 24.04 VM (192.168.10.240) │ ├── OpenSCAP (STIG V1R1 hardening + daily scheduled scan) │ └── /var/log/openscap/compliance-scores.log │ ├── auditd (kernel-level audit logging) │ └── /var/log/audit/audit.log │ ├── USER_CMD events (sudo commands, hex-encoded) │ └── PATH events (file integrity via watch rules) │ ├── UFW (firewall with SSH rate limiting) │ └── /var/log/ufw.log │ ├── Chrony (NTP time synchronization) │ └── /var/log/syslog │ └── Splunk Universal Forwarder 9.4.0 └── Forwards to Splunk indexer (192.168.6.60:9997) │ └── index: siem_monitoring └── Eight-panel MITRE ATT&CK dashboard ``` ## STIG 合规分数历史 | 扫描 | 分数 | 描述 | |---|---|---| | stig-baseline | 50.48% | 全新 Ubuntu 24.04 安装 | | stig-post-auto-remediation | 76.82% | 已应用 OpenSCAP 自动修复 | | stig-final | 77.88% | 手动修复 UFW 和 Chrony | | stig-drift-ufw-disabled | 76.83% | 漂移模拟:UFW 已禁用 | | stig-recovered | 77.88% | 已修复,分数已恢复 | ## 仪表板面板 — MITRE ATT&CK 映射 | 面板 | ATT&CK 技术 | 数据源 | |---|---|---| | 失败的 SSH 登录尝试 | T1110 — Brute Force | auth.log (linux_secure) | | Sudo / 提权 | T1548.003 — Sudo and Sudo Caching | audit.log (linux_audit) | | 日志源心跳 | T1562.006 — Indicator Removal on Host | 所有 sourcetypes | | 身份验证成功与失败对比 | T1078 — Valid Accounts | auth.log (linux_secure) | | UFW 阻断的连接 | T1046 — Network Service Discovery | ufw.log | | 文件完整性更改 | T1543 — Create or Modify System Process | audit.log PATH 记录 | | 时间同步完整性 | T1070 — Indicator Removal | syslog (Chrony) | | STIG V1R1 合规分数趋势 | N/A | compliance-scores.log | ## 仓库结构 ``` linux-stig-siem-monitoring/ ├── README.md ├── openscap/ │ ├── openscap-scan.sh # Daily automated scan script │ └── compliance-scores.log # Example score history log format ├── splunk/ │ ├── dashboard.xml # Splunk Classic Dashboard XML │ ├── inputs.conf # Forwarder input configuration │ └── props.conf # Timestamp parsing configuration ├── auditd/ │ └── file-integrity.rules # auditd watch rules for sensitive paths └── screenshots/ └── dashboard.png # Full dashboard screenshot ``` ## 设置 ### 前置条件 - Ubuntu 24.04 LTS 虚拟机(已在 VMware 上测试) - Splunk Enterprise 或 Free 9.4.x,并已配置接收端口(默认为 9997) - Splunk Universal Forwarder 9.4.0 - ComplianceAsCode v0.1.78 SCAP 内容 ### 步骤 1 — 安装 OpenSCAP 并下载内容 ``` sudo apt update && sudo apt install -y openscap-scanner unzip wget https://github.com/ComplianceAsCode/content/releases/download/v0.1.78/scap-security-guide-0.1.78.zip -P ~/ unzip ~/scap-security-guide-0.1.78.zip -d ~/scap-content ``` ### 步骤 2 — 运行基线扫描 ``` sudo oscap xccdf eval \ --profile xccdf_org.ssgproject.content_profile_stig \ --results /tmp/stig-baseline-results.xml \ --report /tmp/stig-baseline-report.html \ ~/scap-content/scap-security-guide-0.1.78/ssg-ubuntu2404-ds.xml ``` ### 步骤 3 — 应用自动修复 ``` sudo oscap xccdf eval \ --profile xccdf_org.ssgproject.content_profile_stig \ --remediate \ ~/scap-content/scap-security-guide-0.1.78/ssg-ubuntu2404-ds.xml sudo reboot ``` ### 步骤 4 — 运行修复后扫描 ``` sudo oscap xccdf eval \ --profile xccdf_org.ssgproject.content_profile_stig \ --results /tmp/stig-after-results.xml \ --report /tmp/stig-after-report.html \ ~/scap-content/scap-security-guide-0.1.78/ssg-ubuntu2404-ds.xml ``` ### 步骤 5 — 安装并配置 Splunk Universal Forwarder ``` # 安装 forwarder sudo dpkg -i splunkforwarder-9.4.0-6b4ebe426ca6-linux-amd64.deb # 指向 Splunk indexer sudo /opt/splunkforwarder/bin/splunk add forward-server SPLUNK_IP:9997 -auth admin:password # 复制 inputs 和 props config sudo cp splunk/inputs.conf /opt/splunkforwarder/etc/system/local/inputs.conf sudo cp splunk/props.conf /opt/splunkforwarder/etc/system/local/props.conf # 启用 boot start 并 start sudo /opt/splunkforwarder/bin/splunk enable boot-start sudo /opt/splunkforwarder/bin/splunk start ``` ### 步骤 6 — 配置 auditd 文件完整性规则 ``` sudo cp auditd/file-integrity.rules /etc/audit/rules.d/file-integrity.rules sudo augenrules --load ``` ### 步骤 7 — 部署每日扫描脚本 ``` sudo cp openscap/openscap-scan.sh /usr/local/bin/openscap-scan.sh sudo chmod +x /usr/local/bin/openscap-scan.sh echo "0 2 * * * root /usr/local/bin/openscap-scan.sh" | sudo tee /etc/cron.d/openscap-daily ``` ### 步骤 8 — 导入 Splunk 仪表板 在 Splunk Web 界面中转到 Dashboards,创建一个新的 Classic Dashboard,点击 Edit,然后点击 Edit Source,并粘贴 `splunk/dashboard.xml` 的内容。 ## 关键技术决策 **为什么选择 ComplianceAsCode 而不是 apt?** `ssg-debderived` 软件包不包含适用于 Ubuntu 24.04 的 STIG 配置文件。ComplianceAsCode v0.1.78 附带了适用于 Noble Numbat 的完整 STIG V1R1 内容。 **为什么使用单独的合规性索引?** 按项目隔离日志源可以加快 Splunk 的搜索速度,并将合规性遥测数据与其他实验室虚拟机的数据分离开来。 **为什么将合规性分数记录到扁平日志文件而不是索引 XML?** OpenSCAP 生成的 XML 结果文件每个高达 8MB。Splunk 的 Universal Forwarder 会将它们作为分块事件发送,无法跨越事件边界使用单一正则表达式进行解析。结构化的 key=value 日志文件彻底解决了这个问题。 **为什么在 SPL 中解码 auditd 十六进制命令?** Linux 的 auditd 会将命令参数进行十六进制编码,以保留特殊字符。SPL 中的 `urldecode(replace())` 模式可以将它们解码为纯文本,而无需查找表或外部脚本。 ## 工具 - OpenSCAP - ComplianceAsCode STIG V1R1 (v0.1.78) - Splunk Enterprise 9.4.0 - Splunk Universal Forwarder 9.4.0 - auditd - UFW - Chrony - Ubuntu 24.04 LTS (Noble Numbat) - VMware Workstation ## 备注 本项目是在个人实验室环境中亲自动手构建的。Claude (Anthropic) 在开发过程中被用作技术资源,用于故障排除、SPL 查询指导和文档协助。所有配置、实施和测试均是手动执行的。
标签:ATT&CK映射, auditd, Chrony NTP, Cloudflare, DevSecOps, DNS 解析, DoD STIG V1R1, MITRE ATT&CK, OpenSCAP, SIEM仪表盘, Splunk Universal Forwarder, STIG安全加固, Ubuntu 24.04, UFW防火墙, x64dbg, 上游代理, 合规性评分, 子域名变形, 安全事件监控, 安全合规, 安全基线, 安全运营, 应用安全, 扫描框架, 教学环境, 无线安全, 时间同步, 系统加固, 网络代理, 网络安全审计, 网络安全防御, 速率限制处理, 配置偏移模拟