Flor1an-B/sentinelone-macos-log-analyzer
GitHub: Flor1an-B/sentinelone-macos-log-analyzer
针对 SentinelOne macOS 诊断日志的离线取证分析工具,内置 33 条 MITRE ATT&CK 映射检测规则并生成多格式交互报告。
Stars: 1 | Forks: 0
# SentinelOne macOS 日志分析器
[](https://www.python.org/)
[](LICENSE)
[]()
[]()
[]()
**作者:** Florian Bertaux · **要求:** Python 3.11+
## 目录
- [概述](#overview)
- [环境要求与安装](#requirements--installation)
- [快速开始](#quick-start)
- [CLI 参考](#cli-reference)
- [输出文件](#output-files)
- [HTML 报告](#html-report)
- [检测规则](#detection-rules)
- [风险评分](#risk-score)
- [预期的转储结构](#expected-dump-structure)
- [架构](#architecture)
- [开发](#development)
## 概述
**SentinelOne macOS Log Analyzer** 用于处理 SentinelOne 诊断转储,并在无需访问管理控制台的情况下生成完整的安全分析报告。它专为以下场景设计:
- **L1/L2/L3 分流** — 快速评估 macOS 端点上的 SentinelOne agent 是否健康,是否存在活动威胁
- **事件响应** — 将行为检测、进程链和 agent 日志错误关联起来,生成优先级排序的发现结果
- **合规性检查** — 验证 SIP 状态、agent 版本、策略执行情况和配置完整性
该工具完全**离线且自包含**:HTML 报告是一个没有外部依赖的单文件。
### 如何获取诊断转储
从 SentinelOne 管理控制台:**Endpoints → 选择设备 → Actions → Fetch Logs**。下载的压缩包包含本工具所需的转储目录。
## 环境要求与安装
**运行时要求:**
| 需求 | 版本 |
|---|---|
| Python | 3.11+ |
| `biplist` | ≥ 1.0.3 |
| `rich` | ≥ 13.0 |
```
# 克隆 repository
git clone https://github.com/Flor1an-B/sentinelone-macos-log-analyzer.git
cd sentinelone-macos-log-analyzer
# 安装
pip install -e .
# 或者直接安装 dependencies
pip install -r requirements.txt
```
## 快速开始
```
# 分析 dump — 生成 HTML + Markdown + JSON
macloganalyzer ./SentinelLog_2026.03.19_17.40.14_root
# 不安装(从 repo root 运行)
python -m macloganalyzer ./SentinelLog_2026.03.19_17.40.14_root
```
报告将写入转储旁边的 `SentinelLog_2026.03.19_17.40.14_root_report/` 目录。
## CLI 参考
```
macloganalyzer [options]
```
### 参数
| 参数 | 描述 |
|---|---|
| `dump_path` | SentinelOne 转储目录的路径 |
### 选项
| 选项 | 默认值 | 描述 |
|---|---|---|
| `-o, --output-dir PATH` | `_report/` | 输出目录(如不存在则创建) |
| `--format {md,json,html,all}` | `all` | 要生成的报告格式 |
| `--severity {CRITICAL,HIGH,MEDIUM,LOW,INFO}` | `LOW` | 最低严重性阈值 |
| `--since YYYY-MM-DD` | — | 仅包含此日期 (UTC) 之后的事件 |
| `--until YYYY-MM-DD` | — | 仅包含此日期 (UTC) 之前的事件 |
| `--process NAME` | — | 按进程名过滤(部分匹配,不区分大小写) |
| `-v, --verbose` | — | 启用详细解析日志 |
| `--version` | — | 显示版本并退出 |
| `--update` | — | 检查更新并从 GitHub 下载更改的文件 |
### 示例
```
# 检查更新(仅下载已更改的文件)
macloganalyzer --update
# 仅 HTML 报告,HIGH 严重级别及以上
macloganalyzer ./dump --format html --severity HIGH
# 限定到特定日期范围
macloganalyzer ./dump --since 2026-03-15 --until 2026-03-19
# 聚焦于特定 process
macloganalyzer ./dump --process curl
# 自定义 output directory
macloganalyzer ./dump -o ./reports/incident-2026-03-19
# Verbose 模式(显示解析 debug logs)
macloganalyzer ./dump --verbose
```
## 输出文件
所有输出均写入 `_report/`(或使用 `-o` 指定的路径):
| 文件 | 格式 | 描述 |
|---|---|---|
| `_report.html` | HTML | 交互式报告 — 侧边栏导航、时间段过滤、图表 |
| `_report.md` | Markdown | 用于文档或分享的静态报告 |
| `_findings.json` | JSON | 机器可读的发现结果导出(适配 SIEM) |
## HTML 报告
HTML 报告是一个**自包含的单文件**,没有外部依赖。它包括:
- **分析时间段过滤器** — 侧边栏按钮(24小时 / 7天 / 30天 / 全部)动态重新渲染所有时间敏感部分,无需重新加载
- **安全风险仪表** — 0–100 分,带有动画弧线,随选定时间段更新
- **运营警报** — 自动生成的优先级警报(CRITICAL → INFO),附带补救措施
- **侧边栏导航** — 直接跳转到任何部分;发现结果徽章和风险评分随选定时间段更新
- **深色 / 浅色模式** — 侧边栏提供切换开关
### 报告章节
**概览**
| 章节 | 内容 |
|---|---|
| 分析师简报 | 单页分流摘要 — 关键发现、agent 健康状况、连接性、扫描状态 |
| 高管摘要 | 严重性细分,包含环形图和发现计数 |
**系统**
| 章节 | 内容 |
|---|---|
| 系统上下文 | 硬件型号、OS 版本、架构、SIP 状态、主要用户 |
| 性能 | CPU 负载、内存压力、磁盘使用情况、电源状态 |
| 网络 | 接口、活动连接、DNS 服务器、代理配置 |
| 服务 | Launch daemons、launch agents、第三方内核扩展 |
| 系统活动 | 启动/关机事件、软件包安装、登录/登出历史 |
**SentinelOne Agent**
| 章节 | 内容 |
|---|---|
| S1 Agent 健康状况 | 版本、daemon 状态、资产完整性、DB 健康状况、排除项 |
| 通信分析 | 管理连接性、RCP 请求、keep-alive 事件、DV 配置错误 |
**安全分析**
| 章节 | 内容 |
|---|---|
| 进程 | 进程配置文件,附带关联的检测事件和 MITRE 技术手段 |
| 发现结果 | 所有规则发现结果,可按严重性和关键词过滤 |
| IOC | 从行为检测中提取的入侵指标 |
| 时间线 | 跨所有来源的按时间顺序排列的事件时间线 |
| 统计数据 | 检测频率、进程排名、热力图、行为趋势 |
| 威胁情报 | 来自 agent 的威胁情报资产版本 |
| 盲点 | 被分析端点的覆盖缺口和检测限制 |
## 检测规则
涵盖 8 个映射到 MITRE ATT&CK 类别的 33 条规则:
| 类别 | 规则数 | 示例 |
|---|---|---|
| **CONF** — 配置 | 9 | SIP 已禁用、agent 降级、双重 AV、未签名内核扩展 |
| **RECON** — 侦察 | 5 | 账户枚举、服务发现、`/etc/hosts` 访问 |
| **PRIV** — 权限提升 | 2 | 权限修改、sudo 模式 |
| **PERSIST** — 持久化 | 4 | Crontab、登录钩子、plist 持久化、未发现的 daemons |
| **CRED** — 凭据访问 | 3 | Keychain 访问、私钥文件、库验证绕过 |
| **EXFIL** — 渗出 | 3 | 归档创建、数据暂存、入口工具 (curl/wget) |
| **EVADE** — 规避 | 4 | 日志篡改、时间戳修改、隐藏的 Mach-O 二进制文件 |
| **CHAIN** — 攻击链 | 2 | 多进程侦察链、与崩溃相关的检测 |
每项发现包括:规则 ID · 严重性 · MITRE ATT&CK 技术手段 · 描述 · 建议 · 带有时间戳的关联证据事件。
完整规则参考请参见 [`docs/rules.md`](docs/rules.md)。
## 风险评分
报告显示一个由发现结果加权和计算得出的 **0–100 风险评分**:
| 严重性 | 权重 | 标签阈值 |
|---|---|---|
| CRITICAL | 25 分 | ≥ 75 → CRITICAL |
| HIGH | 10 分 | ≥ 50 → HIGH |
| MEDIUM | 4 分 | ≥ 25 → MEDIUM |
| LOW | 1 分 | > 0 → LOW |
| INFO | 0 分 | 0 → MINIMAL |
评分上限为 100。在 HTML 报告中更改分析时间段时,评分会动态更新。
## 预期的转储结构
该工具期望一个由 `sentinelctl` 或 SentinelOne 控制台日志获取操作生成的目录。自动检测会查找 `match_reports/`、`sentinelctl-status.txt` 或 `csrutil_status.txt` — 如果提供的是封装目录,则会深入一层查找。
```
SentinelLog_2026.03.19_17.40.14_root/
├── sentinelctl-status.txt ← Agent status & management config
├── sentinelctl-config.txt ← Communication timing config
├── sentinelctl-config_policy.txt ← Policy feature settings
├── sentinelctl-config_local.txt ← Local config overrides (if any)
├── sentinelctl-scan-info.txt ← Last scan status
├── sentinelctl-stats.txt ← DB read/write statistics
├── sentinelctl-policies.txt ← Detection rule actions
├── csrutil_status.txt ← System Integrity Protection state
├── ifconfig.txt ← Network interfaces
├── lsof-i.txt ← Active network connections
├── netstat-anW.txt ← All sockets (listening + established)
├── df.txt ← Disk volumes and capacity
├── ps.txt ← Running processes at dump time
├── top.txt ← System load and memory summary
├── vm_stat.txt ← Memory pressure metrics
├── pmset-live.txt / pmset-ps.txt ← Power and battery state
├── scutil_proxy.txt ← Proxy configuration
├── scutil_dns.txt ← DNS servers
├── kextstat.txt ← Loaded kernel extensions
├── mount.txt ← Mounted volumes
├── pkgutil.txt ← Security packages (XProtect, Gatekeeper)
├── ioreg.txt ← Hardware serial number
├── users.txt ← Local user accounts
├── Applications.txt ← Installed applications
├── LaunchDaemons.txt ← System launch daemons
├── LaunchAgents.txt ← User launch agents
├── KernelExtensions.txt ← Kernel extension list
├── PrivilegedHelperTools.txt ← Privileged helper tools
├── SentinelDirectorySize.txt ← Agent DB directory sizes
├── match_reports/ ← Behavioral detections (JSONL)
│ └── *.jsonl
├── logs/
│ ├── sentinelctl-log.txt ← SentinelOne agent internal log
│ ├── install.log ← Package installation history
│ ├── asl.log ← Boot/shutdown/login events
│ └── ui-logs/ ← Agent UI state logs
├── crashes/ ← Crash reports (.diag)
├── assets/ ← Protection policies & exclusions
│ ├── pathExclusion.plist
│ ├── dvExclusionsConsole.plist
│ └── mgmtConfig.plist
├── config_s1/ ← Agent configuration plists
├── global-assets/ ← ML models & threat intelligence
│ └── *-metadata.plist
└── bundle/
└── sentinel-agent.plist ← Agent version and UUID
```
## 架构
完整技术参考请参见 [`docs/architecture.md`](docs/architecture.md)。
**Pipeline 概览:**
```
Dump directory
│
▼
┌─────────────────┐
│ 1. Ingest │ text_parser · plist_parser · extended_text_parser
│ │ install_log_parser → SystemContext
└────────┬────────┘
│
▼
┌─────────────────┐
│ 2. Parse │ jsonl_parser (match_reports/) → [Event]
│ │ ui_log_parser · crash_parser
└────────┬────────┘
│
▼
┌─────────────────┐
│ 3. Correlate │ Timeline · ProcessIndex · GroupIndex
└────────┬────────┘
│
▼
┌─────────────────┐
│ 4. Rules │ 33 rules × AnalysisContext → [Finding]
└────────┬────────┘
│
▼
┌─────────────────┐
│ 5. Filter │ severity · date range · process
└────────┬────────┘
│
▼
┌─────────────────┐
│ 6. Report │ HTML · Markdown · JSON · Console
└─────────────────┘
```
## 开发
```
# 运行测试
pytest
# 运行带 coverage 的测试
pytest --cov=macloganalyzer
# 分析本地 dump(不安装,从 repo root 运行)
python -m macloganalyzer ./dump_path
# Verbose 模式(debug 级别解析 logs)
python -m macloganalyzer ./dump_path --verbose
```
### 项目布局
```
macloganalyzer/
├── __main__.py Entry point & CLI
├── pipeline.py 6-step analysis pipeline
├── config.py Shared constants
├── models/ Event · Finding · SystemContext
├── ingest/ 7 source parsers
├── correlate/ Timeline · ProcessIndex · GroupIndex
├── analyze/ Operational alert engine
├── rules/ 33 detection rules (8 categories)
└── report/ HTML · Markdown · JSON · Console
```
## 免责声明
本工具是一个独立的社区项目,不隶属于、不由 SentinelOne, Inc. 认可或支持。SentinelOne 是 SentinelOne, Inc. 的注册商标。
标签:AMSI绕过, Cloudflare, DNS 解析, EDR, HTML报告, JSON报告, Mac安全, Markdown报告, MITRE ATT&CK, Python, SentinelOne, SIP状态, Triage, 云计算, 威胁检测, 库, 应急响应, 数字取证, 无后门, 离线取证, 端点安全, 网络信息收集, 脆弱性评估, 自动化分析, 自动化脚本, 补丁管理, 规则引擎, 诊断日志, 跨站脚本, 逆向工具