SecurityRonin/vhdx-core

GitHub: SecurityRonin/vhdx-core

纯 Rust 实现的 VHDX 虚拟磁盘容器读取库,支持动态、固定、差分磁盘及脏日志恢复,提供标准 Read + Seek 接口。

Stars: 0 | Forks: 0

[![Crates.io](https://img.shields.io/crates/v/vhdx-core.svg)](https://crates.io/crates/vhdx-core) [![Docs.rs](https://img.shields.io/docsrs/vhdx-core)](https://docs.rs/vhdx-core) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/SecurityRonin/vhdx-core/actions/workflows/ci.yml) [![Sponsor](https://img.shields.io/badge/sponsor-h4x0r-ea4aaa?logo=github-sponsors)](https://github.com/sponsors/h4x0r) **纯 Rust 实现的 VHDX (Hyper-V) 虚拟磁盘容器库(读取器;写入器计划中)—— 支持动态、固定、差分磁盘以及脏日志 (dirty-log) 恢复。** 解码 Microsoft VHDX 容器格式(Hyper-V、Windows 8+、WSL2、Azure),并对虚拟扇区流提供 `Read + Seek` 接口。在打开时自动重放脏日志,并支持差分磁盘的父链 —— 无 unsafe 代码、无 C 语言绑定、无需外部工具。 ``` [dependencies] vhdx-core = "0.2" # published as vhdx-core, imported as `vhdx` ``` ## 用法 ### 打开 VHDX 并读取扇区 ``` use vhdx::VhdxReader; use std::io::{Read, Seek, SeekFrom}; let mut reader = VhdxReader::open("disk.vhdx")?; println!("Virtual disk size: {} bytes", reader.virtual_disk_size()); println!("Logical sector size: {} bytes", reader.logical_sector_size()); // Read the first sector let mut sector = vec![0u8; reader.logical_sector_size() as usize]; reader.seek(SeekFrom::Start(0))?; reader.read_exact(&mut sector)?; ``` ### 传递给文件系统 crate `VhdxReader` 实现了 `Read + Seek`,因此可以直接插入任何接受 reader 的 crate 中: ``` use vhdx::VhdxReader; let reader = VhdxReader::open("disk.vhdx")?; // e.g. ext4fs_forensic::Filesystem::open(reader)?; ``` ### 从内存缓冲区读取 ``` use vhdx::VhdxReader; let data: Vec = std::fs::read("disk.vhdx")?; let reader = VhdxReader::from_bytes(data)?; ``` ### 打开具有父镜像的差分(子)磁盘 ``` use vhdx::VhdxReader; let parent = VhdxReader::from_bytes(std::fs::read("base.vhdx")?)?; let reader = VhdxReader::from_bytes_with_parent(std::fs::read("child.vhdx")?, parent)?; // Reads absent blocks in the child are transparently served from parent. ``` ## 命令行 `vhdx-cli` crate(包含在此工作区中)提供了一个 `vhdx info` 命令: ``` $ vhdx info disk.vhdx File: disk.vhdx Format: VHDX v1 (dynamic) Virtual disk size: 16,777,216 bytes (16.00 MiB) Logical sectors: 512 bytes ``` ## 支持的格式 | 格式 | 支持情况 | |--------|:---------:| | VHDX Version 1 (Windows 8 / Server 2012+) | ✓ | | 动态磁盘 (稀疏, BAT 寻址) | ✓ | | 固定磁盘 (预分配) | ✓ | | 差分磁盘 (单级父链) | ✓ | | 日志重放 (脏日志恢复) | ✓ | 只读模式。差分磁盘需要通过 `VhdxReader::from_bytes_with_parent` 提供父镜像。当活动标头包含非零的 LogGuid 时,会在打开时自动进行日志重放。 ## 相关 crate ### 容器读取器 | Crate | 格式 | 备注 | |-------|--------|-------| | [`ewf`](https://github.com/SecurityRonin/ewf) | E01 / EWF / Ex01 | 主流的专业取证获取格式 | | [`aff4`](https://github.com/SecurityRonin/aff4) | AFF4 v1 | Evimetry / aff4-imager 带有 Map 流的取证磁盘镜像 | | [`vmdk`](https://github.com/SecurityRonin/vmdk) | VMware VMDK | 来自 VMware Workstation / ESXi 的单体稀疏磁盘镜像 | | [`vhd`](https://github.com/SecurityRonin/vhd) | Legacy VHD | Virtual PC / Hyper-V Generation-1 固定和动态磁盘镜像 | | [`qcow2`](https://github.com/SecurityRonin/qcow2) | QCOW2 v2/v3 | QEMU / KVM / libvirt 磁盘镜像 | | [`ufed`](https://github.com/SecurityRonin/ufed) | Cellebrite UFED | 带有 UFD XML 分段映射的物理移动设备转储 | | [`dd`](https://github.com/SecurityRonin/dd) | Raw / flat / gz | dd, dcfldd 以及 gzip 包装的原始镜像 | | [`iso9660-forensic`](https://github.com/SecurityRonin/iso9660-forensic) | ISO 9660 | 光盘镜像:多会话、UDF 桥接、Rock Ridge、Joliet、El Torito | | [`dmg`](https://github.com/SecurityRonin/dmg) | Apple DMG / UDIF | 带有 koly 尾部、mish 块表、zlib 解压的 macOS 磁盘镜像 | | [`dar`](https://github.com/SecurityRonin/dar) | DAR archive | 带有目录索引和 CRC32 校验的 Disk ARchiver 归档 | ### 取证分析器 | Crate | 格式 | 备注 | |-------|--------|-------| | [`vhdx-forensic`](https://github.com/SecurityRonin/vhdx-forensic) | VHDX | 基于此 crate 构建的取证完整性分析器和内存修复工具 | | [`ewf-forensic`](https://github.com/SecurityRonin/ewf-forensic) | E01 | 结构完整性审计、Adler-32 / MD5 哈希验证以及内存修复 | [隐私政策](https://securityronin.github.io/vhdx-core/privacy/) · [服务条款](https://securityronin.github.io/vhdx-core/terms/) · © 2026 Security Ronin Ltd
标签:Rust, VHDX, 可视化界面, 库, 应急响应, 文件系统, 网络流量审计, 虚拟化, 通知系统