mandiant/macos-UnifiedLogs
GitHub: mandiant/macos-UnifiedLogs
一个用 Rust 编写的跨平台 Apple Unified Log 解析库,支持将 macOS 和 iOS 的 tracev3 日志文件导出为 JSON 或 CSV 格式,适用于数字取证和应急响应场景。
Stars: 332 | Forks: 42
# macos-unifiedlogs
一个简单的 Rust 库,可以帮助解析 macOS Unified Log 文件。
Unified Logs 是在 macOS 10.12 版本(Sierra,2016 年)中引入的。这是 Apple 为所有 Apple 产品创建统一日志格式目标的一部分。它们存在于 macOS、iOS、watchOS 和 tvOS 中。Unified Logs 取代了 Apple 过去使用的许多旧日志格式。该库可用于解析这些日志文件。
目前提取的数据包括:
- Process ID
- Thread ID
- Activity ID
- Log Message
- Timestamp(支持 Intel 和 ARM)
- Effective User ID (EUID)
- Log Type
- Event Type
- Library
- Subsystem
- Category
- Process
- Raw message - 从 UUID 文件提取的消息
- Message entries - 来自 tracev3 文件的消息部分。与 Raw message 结合以获取 Log Message
- Library UUID
- Process UUID
- Boot UUID
- Timezone
## 运行
有一个示例二进制文件可供下载
- `unifiedlog_iterator` - 可以将 logarchive 解析为 JSON 或 CSV 文件。它也可以解析实时系统上的日志。输出文件会非常大
## 限制
它已经过数百万条日志条目的测试。但是,由于 Unified Log 格式的复杂性,存在一些限制:
1. 不支持 printf 样式的错误代码查找。此库不对日志消息进行任何错误代码查找。macOS 上的原生 `log` 命令在遇到 printf 样式的 `%m` 消息时支持错误代码查找。
例如日志消息:'Failed to open file, error: %m'
a. 此库输出:
Failed to open file, error: 1
b. macOS Log 命令输出:
Failed to open file, error: no such file or directory
2. 此库支持日志消息中的大多数自定义对象。但是,不支持的对象将被 base64 编码
# 参考资料
- https://github.com/ydkhatri/UnifiedLogReader
- https://github.com/libyal/dtformats/blob/main/documentation/Apple%20Unified%20Logging%20and%20Activity%20Tracing%20formats.asciidoc
- https://eclecticlight.co/2018/03/19/macos-unified-log-1-why-what-and-how
- https://www.crowdstrike.com/blog/how-to-leverage-apple-unified-log-for-incident-response
标签:Apple, CSV, Intel, iOS, JSON, Rust, Sierra, tracev3, tvOS, watchOS, 二进制发布, 可视化界面, 域环境安全, 开源工具, 数字取证, 数据提取, 日志解析, 统一日志, 网络流量审计, 自动化脚本, 证书伪造, 通知系统