SecurityRonin/dmg-forensic

GitHub: SecurityRonin/dmg-forensic

纯 Rust 编写的 macOS DMG/UDIF 磁盘映像取证库,支持虚拟磁盘读取与 koly trailer 完整性审计。

Stars: 0 | Forks: 0

[![Crates.io (dmg-core)](https://img.shields.io/crates/v/dmg-core.svg?label=dmg-core)](https://crates.io/crates/dmg-core) [![Crates.io (dmg-forensic)](https://img.shields.io/crates/v/dmg-forensic.svg?label=dmg-forensic)](https://crates.io/crates/dmg-forensic) [![Docs.rs](https://img.shields.io/docsrs/dmg-core)](https://docs.rs/dmg-core) [![Rust 1.85+](https://img.shields.io/badge/rust-1.85%2B-orange.svg)](https://www.rust-lang.org) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) [![赞助](https://img.shields.io/badge/sponsor-h4x0r-ea4aaa?logo=github-sponsors)](https://github.com/sponsors/h4x0r) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/SecurityRonin/dmg-forensic/actions/workflows/ci.yml) [![文档](https://img.shields.io/badge/docs-mkdocs-blue)](https://securityronin.github.io/dmg-forensic/) **使用纯 Rust 读取和审计 macOS 磁盘映像 (DMG/UDIF) —— 一个支持 `Read + Seek` 的虚拟磁盘,包含所有 block 编解码器,以及一个 koly-trailer 异常审计器。零 C 依赖。** 将其指向一个 `.dmg` 文件,即可从那些 happy-path 读取器盲目信任的结构中获取分级取证分析结果: ``` use std::path::Path; // The differentiator: audit the koly trailer for tampering / corruption. for a in dmg_forensic::audit_path(Path::new("evidence.dmg"))? { println!("[{:?}] {}: {}", a.severity, a.code, a.note); } // [High] DMG-KOLY-XML-OUT-OF-BOUNDS: koly XML block-table range [..] runs past the file … # Ok::<(), std::io::Error>(()) ``` ## 两个 crate ``` [dependencies] dmg-core = "0.1" # the reader (import as `dmg`) dmg-forensic = "0.1" # the koly-trailer auditor ``` ## 读取虚拟磁盘 ``` use dmg::DmgReader; use std::fs::File; use std::io::{Read, Seek, SeekFrom}; let mut reader = DmgReader::open(File::open("disk.dmg")?)?; println!("virtual disk: {} bytes", reader.virtual_disk_size()); let mut sector = [0u8; 512]; reader.read_exact(&mut sector)?; // first sector reader.seek(SeekFrom::Start(1 << 20))?; // seek anywhere # Ok::<(), dmg::DmgError>(()) ``` 由于 `DmgReader` 实现了 `Read + Seek`,它可以直接接入任何接受 reader 的分区或文件系统分析工具。 ## 异常代码 | 代码 | 严重性 | 含义 | |------|----------|---------| | `DMG-KOLY-SIGNATURE-INVALID` | 高 | trailer 签名不是 `koly` —— 不是 UDIF,或已被覆盖 | | `DMG-KOLY-VERSION-UNEXPECTED` | 低 | version 字段不是文档中记录的 4 | | `DMG-KOLY-DATAFORK-OUT-OF-BOUNDS` | 高 | data-fork 的 offset+length 超出了文件末尾 | | `DMG-KOLY-XML-OUT-OF-BOUNDS` | 高 | XML block-table 的 offset+length 超出了文件末尾 | | `DMG-KOLY-TRAILER-TOO-SMALL` | 高 | 文件大小小于 512 字节的 koly trailer | 每一条发现都是一个观察结果(“与……一致”,绝非最终裁定),其中包含了违规的值和字段作为证据。 ## 信任,但要验证 [隐私政策](https://securityronin.github.io/dmg-forensic/privacy/) · [服务条款](https://securityronin.github.io/dmg-forensic/terms/) · © 2026 Security Ronin Ltd
标签:DMG/UDIF, Rust, 可视化界面, 异常检测, 数字取证, 文件系统, 磁盘镜像解析, 网络流量审计, 自动化脚本, 通知系统