mbr-partition-core
A pure, read-only Master Boot Record parser — decode the boot sector, partition table, and EBR chain from a 512-byte buffer or any Read + Seek, with no I/O of its own and no panics on hostile input.
use parse_mbr_sector;
let sector = read?;
let mbr = parse_mbr_sector?;
println!;
for in mbr.entries.iter.enumerate
# Ok::
The crate is published as mbr-partition-core but imported as mbr ([lib] name = "mbr").
What it decodes
This is the structure-decode layer. It deliberately contains no anomaly
findings — the analyzer that grades these structures lives in the sibling
mbr-partition-forensic
crate, which re-exports every type here.
| Module | Decodes |
|---|---|
mbr |
parse_mbr_sector — the 512-byte boot sector, NT disk signature, four primary PartitionEntry records |
partition |
PartitionEntry, TypeCode → PartitionFamily, Chs geometry and chs_consistency CHS↔LBA cross-check |
ebr |
walk_ebr_chain over a Read + Seek — Extended Boot Record traversal yielding an EbrChain |
gpt |
has_gpt_header — protective-MBR / GPT presence check |
vbr |
parse_bpb — BIOS Parameter Block (hidden-sector count, geometry) from a volume boot record |
signature |
detect — filesystem fingerprint (DetectedFs) from a partition's first sector; type_conflicts |
boot_code |
identify — bootloader fingerprint (BootCodeId) from the first 446 bytes |
disk_signature |
find_signature_collisions — duplicate NT disk-signature detection across images |
carve |
carve / extract_ascii_strings — magic-byte file carving and string extraction over a byte slice |
The only error type is Error (TooShort, BadSignature, Io).
Trust but verify
Built to run on untrusted disk images:
- Panic-free — bounds-checked reads and checked/saturating arithmetic; no
unwrap/expect/panic!in production code (enforced byclippy::unwrap_used/expect_used = deny). - EBR hardening —
walk_ebr_chainuses a visited-LBA set against cycles,checked_addagainst overflow, and a depth cap against runaway chains; read errors on truncated images terminate traversal gracefully. - Fuzzed — the
fuzz_parsecargo-fuzz target drives the sector parser; the invariant is "must not panic".
Features
| Feature | Effect |
|---|---|
trace |
Forwards diagnostic events to the tracing ecosystem |
serde |
Derives Serialize/Deserialize on the public types |
For graded forensic findings, gap analysis, slack-space carving, and wipe /
bootkit detection, use
mbr-partition-forensic.
Privacy Policy · Terms of Service · © 2026 Security Ronin Ltd