Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:NTFS

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

The Windows NT filesystem: a boot sector with OEM id "NTFS ", a Master File Table of 'FILE' records (usually 1024 bytes) protected by an update sequence array, attributes with type codes 0x10 to 0x100 that are resident or non-resident, and data runs describing where non-resident content lives.

Overview

Everything on NTFS is a file described by an MFT record; the MFT itself is record 0 ($MFT), followed by $MFTMirr (1), $LogFile (2), $Volume (3), $AttrDef (4), the root directory (5) and $Bitmap (6). The boot sector (first sector, copy in the last sector) says where the MFT starts. A BitLocker volume replaces the OEM id with "-FVE-FS-" (Format:BitLocker volume header); compressed files use Format:LZNT1. exFAT and FAT share the 0x55AA tail but not the layout (Format:ExFAT, Format:FAT (FAT12, FAT16, FAT32, VFAT)).

Boot sector (struct NTFS_BOOT, 512 bytes)

Jump 0x00, OEM id "NTFS " 0x03, bytes per sector 0x0B (16-bit, unaligned), sectors per cluster 0x0D, media 0x15, sectors per track 0x18, heads 0x1A, hidden sectors 0x1C, BIOS drive 0x24, extended signature 0x26, sectors in volume 0x28 (u64), first cluster of $MFT 0x30, of $MFTMirr 0x38, MFT record size 0x40 (signed), index block size 0x44 (signed), serial number 0x48, additive checksum 0x50, signature 0x55 0xAA at 0x1FE. Record size rule used by ntfs3: a value >= 0 is a count of clusters; a negative value n means 2^(-n) bytes (so 0xF6 = -10 = 1024 bytes).

MFT record ('FILE')

Header: signature "FILE" 0x00, update sequence array offset 0x04, its entry count 0x06 (count of 16-bit words including the check value), log sequence number 0x08, sequence number 0x10, hard link count 0x12, first attribute offset 0x14, flags 0x16 (0x01 in use, 0x02 directory, 0x04 system, 0x08 index), used size 0x18, allocated size 0x1C, base record reference 0x20, next attribute id 0x28, record number 0x2C (NTFS 3.1 headers; older records stop at 0x2A and place the array at 0x2A or 0x30). Other multi-sector signatures: "INDX" (index blocks), "RSTR" and "RCRD" ($LogFile), "CHKD" (chkdsk), "BAAD" (record chkdsk found damaged), "HOLE". Update sequence array: the last two bytes of every 512-byte sector of a record are replaced on disk by a check value; the originals sit in the array. A parser must put the originals back before reading attributes that cross a sector end. Unverified: the exact swap procedure is stated here from general knowledge; the libfsntfs documentation says the array must end before the last 16-bit value of the first sector.

Attributes

Attribute type codes: 0x10 $STANDARD_INFORMATION, 0x20 $ATTRIBUTE_LIST, 0x30 $FILE_NAME, 0x40 $OBJECT_ID, 0x50 $SECURITY_DESCRIPTOR, 0x60 $VOLUME_NAME, 0x70 $VOLUME_INFORMATION, 0x80 $DATA, 0x90 $INDEX_ROOT, 0xA0 $INDEX_ALLOCATION, 0xB0 $BITMAP, 0xC0 $REPARSE_POINT, 0xD0 $EA_INFORMATION, 0xE0 $EA, 0xF0 property set, 0x100 $LOGGED_UTILITY_STREAM; 0xFFFFFFFF ends the list in a record. Unverified: attributes appear sorted by type code within a record. Common header: type 0x00, length 0x04, non-resident flag 0x08, name length (UTF-16 characters) 0x09, name offset 0x0A, flags 0x0C (0x0001 compressed, 0x4000 encrypted, 0x8000 sparse), attribute id 0x0E. Resident: content size 0x10, content offset 0x14, indexed flag 0x16 (header 0x18 bytes). Non-resident: starting VCN 0x10, ending VCN 0x18, offset of the data runs 0x20, compression unit (log2 clusters, 4 = 16 clusters) 0x22, allocated size 0x28, data size 0x30, valid (initialized) size 0x38, total allocated for compressed/sparse 0x40; header 0x40 bytes (0x48 with the compressed/sparse field). A named $DATA attribute is an alternate data stream.

Data runs

A run list is a sequence of elements ended by a 0x00 byte. Each element starts with a header byte: the low nibble is the number of bytes of the run length, the high nibble the number of bytes of the signed cluster offset; then the length (clusters), then the offset. The first offset is absolute (LCN) and every following offset is relative to the previous run's start; an offset size of 0 means a sparse run (zeros). Example: 21 18 34 56 00 is 0x18 clusters at LCN 0x5634. The example is computed from the rule, not taken from a sample.

Analyst notes

  • Unverified: deleted files keep their MFT record with flag 0x01 cleared, so names and runs can often be recovered until reuse (the flag is declared in ntfs.h; the recovery behaviour is general knowledge).
  • File attributes in $STANDARD_INFORMATION and $FILE_NAME use the Windows flags (0x1 read-only, 0x2 hidden, 0x4 system, 0x20 archive, 0x800 compressed, 0x4000 encrypted, 0x10000000 directory flag in directory entries).
  • Windows 10 WOF compression stores LZX/XPRESS data in the WofCompressedData stream plus a reparse point (libfsntfs).

Sources

Linux fs/ntfs3/ntfs.h and super.c at c03c1a14 (GPL-2.0); libfsntfs documentation (GFDL-1.3) at faaa031d.

Code & repositories

  • https://github.com/libyal/libfsntfs @ faaa031d0f779578559d5c025c9583d103702bcc · license: LGPL-3.0-or-later (declared by the contributor for the files used; GitHub reports LGPL-3.0 for the repository)
    libfsntfs by Joachim Metz; documentation/ holds the NTFS format specification (GFDL-1.3) with data runs, MFT entry flags and compression.
    Tested on: source read, not run: documentation read only · checked 2026-10-19; last activity 2026-10-11
  • https://github.com/torvalds/linux @ c03c1a14507dfaf8b856c2608f9ac216021fc222 · license: GPL-2.0-only WITH Linux-syscall-note (declared by the contributor for the files used; GitHub reports GPL-2.0 WITH Linux-syscall-note (read from COPYING; GitHub's detector did not classify it) for the repository)
    Linux kernel; fs/ntfs3/ntfs.h declares the NTFS on-disk structures.
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-18