Chapter 03

File System and Storage

NTFS is the security layer underneath everything on Windows. Its metadata structures are where malware hides, where forensics recovers deleted evidence, and where ransomware attacks are most precisely timed.

Scenario

A threat hunter is investigating a suspected compromise. The suspected malware file was deleted three days ago. The attacker was careful — they cleared event logs, removed the file, and overwrote it. But the forensic analyst pulls a forensic image of the disk and runs Autopsy. The MFT still has an entry for the deleted file — with the original creation timestamp, last access time, and the file's size. The USN Change Journal has an entry showing the file was created, then executed, then deleted, with timestamps for each event. A Volume Shadow Copy from two days ago still has the file. The attacker deleted the visible file. They forgot about the journal, the shadow copy, and the MFT.

NTFS keeps more records than most people realize. This chapter explains what those records are and why they matter for both attackers and defenders.

NTFS Architecture and the MFT

NTFS (New Technology File System) is not just a way to organize files on disk. It is a transactional, journaled, access-controlled database that happens to store files. Every file and directory on an NTFS volume has a corresponding record in the Master File Table (MFT).

  NTFS On-Disk Structure
  ══════════════════════════════════════════════════════════════════════

  NTFS Volume
  ┌────────────────────────────────────────────────────────────────┐
  │  Volume Boot Record (VBR)                                      │
  │  Contains: NTFS signature, cluster size, MFT location          │
  ├────────────────────────────────────────────────────────────────┤
  │  Master File Table ($MFT)                                      │
  │  ─────────────────────────────────────────────────────────     │
  │  Record 0:  $MFT (the MFT file itself)                         │
  │  Record 1:  $MFTMirr (partial backup of first 4 MFT records)  │
  │  Record 2:  $LogFile (NTFS transaction log)                    │
  │  Record 3:  $Volume (volume info, version, flags)              │
  │  Record 4:  $AttrDef (attribute type definitions)              │
  │  Record 5:  . (root directory, ".")                            │
  │  Record 6:  $Bitmap (cluster allocation bitmap)                │
  │  Record 7:  $Boot (volume boot record copy)                    │
  │  Record 8:  $BadClus (bad cluster file)                        │
  │  Record 9:  $Secure (security descriptor database)             │
  │  Record 10: $UpCase (Unicode uppercase table)                  │
  │  Record 11: $Extend (extension metadata directory)             │
  │  Record 12–23: Reserved                                        │
  │  Record 24+: User files and directories                        │
  ├────────────────────────────────────────────────────────────────┤
  │  $UsnJrnl (USN Change Journal)                                 │
  │  Stored in $Extend\$UsnJrnl                                    │
  │  Append-only log of all file system changes                    │
  ├────────────────────────────────────────────────────────────────┤
  │  File Data Clusters                                            │
  │  Actual file content (or within MFT record if small enough)   │
  └────────────────────────────────────────────────────────────────┘
    

Each MFT record is 1024 bytes. It contains attributes describing the file: its name, timestamps, security descriptor, and the locations of its data on disk. For small files (under ~700 bytes), the actual file content is stored directly in the MFT record as a resident attribute — the file data is in the metadata, not in a separate cluster.

Why deleted files are recoverable from the MFT

When a file is deleted, Windows marks the file's MFT record as "free" and updates the cluster allocation bitmap to mark those clusters as available. But it doesn't zero out the MFT record or overwrite the data clusters immediately. The MFT record still contains the file's name, timestamps, and cluster locations. The data clusters still contain the file's content until they're reused for a new file. A forensic tool can read the MFT, find records marked as deallocated, and recover both the metadata and (if the clusters haven't been overused) the file content. This is why file deletion is not evidence destruction — it's only evidence de-indexing. Secure deletion requires overwriting the data clusters, which most file deletion tools don't do.

NTFS Timestamps and Timestomping

Every file in NTFS has four timestamps, stored in two locations: the $STANDARD_INFORMATION attribute (visible to users and tools like Explorer) and the $FILE_NAME attribute (maintained by the kernel, harder to manipulate).

Timestamp When Updated Attacker Manipulation
Created ($SI) File creation. Note: copying a file sets this to the copy time, not the original. Easily changed via SetFileTime() Win32 API. Tools like timestomp.exe do this in seconds.
Modified ($SI) Last time file content changed. Easily changed via SetFileTime().
Accessed ($SI) Last time file was opened. Often disabled/delayed in modern Windows for performance. Easily changed via SetFileTime().
MFT Entry Modified ($SI) Last time the MFT record itself was modified (any attribute change). Cannot be changed via normal APIs. Requires raw disk write. Often overlooked by attackers.
$FILE_NAME timestamps Set by the kernel on file creation and rename. Updated on rename and hard link creation. Cannot be changed via normal Win32 APIs. Require kernel-mode access or raw disk write. If $FN timestamps differ significantly from $SI timestamps, timestomping is likely.
Mental model: timestamp forensics as a consistency check

Legitimate files have consistent timestamps across $STANDARD_INFORMATION and $FILE_NAME attributes — they were both set by the same OS operations. When an attacker timestomps a file to make it look old, they change the $SI timestamps via the Win32 API. But they typically can't change the $FN timestamps without kernel access. A forensic analyst who finds a file where $SI says "created 2019-01-01" but $FN says "created 2024-03-15" has strong evidence of timestomping. The MFT Entry Modified timestamp is also a give-away: if a file's "creation" timestamp is 2019 but the MFT record was last modified in 2024, something changed the file's metadata in 2024.

NTFS Permissions vs Share Permissions

Windows has two overlapping permission systems for shared files: NTFS permissions (controlled by the DACL on the file object) and share permissions (controlled when creating a network share). When a user accesses a file over the network, both sets of permissions apply, and the most restrictive set wins.

  Network File Access Permission Logic
  ══════════════════════════════════════════════════════════════════════

  User connects to \\Server\Share\Finance\report.xlsx

  Check 1: Share Permissions
  ─────────────────────────────────────────────────────────────────
  Share ACL: Finance Users = Change
             Everyone = Read
             Administrators = Full Control

  Check 2: NTFS Permissions on report.xlsx
  ─────────────────────────────────────────────────────────────────
  NTFS ACL: Finance Users = Read
            Administrators = Full Control

  Result: Most restrictive wins
  ─────────────────────────────────────────────────────────────────
  Finance Users: Share=Change, NTFS=Read → Effective = READ
  Administrators: Share=Full, NTFS=Full  → Effective = FULL

  Common Mistake:
  Share permissions set to "Everyone = Full Control"
  relying entirely on NTFS permissions to control access.
  This works for network access but means share permissions
  add no protection. If NTFS permissions are misconfigured,
  there's no second layer.

  Note: NTFS permissions apply for LOCAL access too.
  Share permissions only apply over the network.
  Local access (RDP console, local logon) bypasses share
  permissions entirely and uses only NTFS ACLs.
    

Alternate Data Streams: NTFS's Hidden Layer

Every NTFS file can have multiple data streams. The default data stream — the one you normally see and interact with — is called $DATA and has no name. But any file can have additional named streams: filename.txt:streamname. These alternate data streams (ADS) are not visible in Explorer, not shown in dir output, and not included in file size calculations. They are, however, fully functional storage that can hold arbitrary data.

  Alternate Data Stream Structure
  ══════════════════════════════════════════════════════════════════════

  File: legitimate.txt
  ─────────────────────────────────────────────────────────────────
  Visible in Explorer:    legitimate.txt  (2 KB)
  Actual contents:
    legitimate.txt         ← default stream ($DATA, unnamed)
                              Content: "This is a normal document."
    legitimate.txt:hidden  ← named ADS
                              Content: [malware payload, 500 KB]
    legitimate.txt:Zone.Identifier  ← Zone.Identifier ADS
                              Content: [ZoneId=3] (from internet)

  The 2 KB size shown in Explorer = size of default stream only.
  The hidden stream's 500 KB is invisible to normal directory listing.

  Zone.Identifier is a real ADS Windows uses for Mark of the Web:
  ─────────────────────────────────────────────────────────────────
  When you download a file from the internet, Windows writes:
  filename.exe:Zone.Identifier containing [ZoneTransfer]\nZoneId=3
  This triggers "Open File - Security Warning" dialogs.
  Attackers remove this ADS to suppress the warning.
    
Wild: ADS used by real malware to hide payloads on legitimate files

The Poweliks malware family (2014) stored its payload entirely within an ADS attached to a registry key — not even a file. Several APT groups have used ADS to hide additional payloads within system files. The tactic: copy a legitimate Windows binary to a user-writable location, attach a malicious payload as an ADS to it, then execute the payload directly from the stream using wscript.exe legitimate.js:payload or by loading the stream into a reflective DLL loader. Detection: Sysmon Event ID 15 (FileCreateStreamHash) fires when a named ADS is created on a file — this is a low-volume event in normal environments and almost always worth investigating when it fires for executable-type streams on non-system files.

The USN Change Journal: An Attacker Activity Log

The USN (Update Sequence Number) Change Journal is an append-only log that records every file system change: file creation, modification, deletion, rename, attribute change, and security change. Every file system operation generates at least one USN record. The journal is stored in $Extend\$UsnJrnl:$J on the NTFS volume.

USN Record Field Contents Forensic Value
TimeStamp UTC timestamp of the change Independent timestamp source — attackers cannot manipulate this via timestomping
Reason What changed: FILE_CREATE, FILE_DELETE, DATA_CHANGE, RENAME_OLD_NAME, RENAME_NEW_NAME, etc. Reveals the operation sequence — create → modify → delete shows a file that existed briefly
FileName The file's name at the time of the change Even for deleted files — the name is preserved in the journal
FileReferenceNumber MFT record number — links the USN record to the MFT entry Correlates USN activity with MFT metadata for the same file
ParentFileReferenceNumber MFT record number of parent directory Reveals full path even if directory was renamed or deleted

The USN journal has a maximum size (typically 32 MB by default). When it fills, the oldest entries are overwritten. In active environments, this means the journal may only cover the last few hours to days of activity. Attackers who know about the journal may attempt to fill it quickly to overwrite evidence, or may use fsutil usn deletejournal to delete the journal entirely — which itself generates a detectable event.

Volume Shadow Copy Service: Forensic Goldmine and Ransomware Target

Volume Shadow Copy Service (VSS) creates point-in-time snapshots of NTFS volumes. These snapshots are used for Windows Backup, Previous Versions (the ability to restore prior versions of a file via right-click), and System Restore. From a security perspective, they are simultaneously one of the most valuable forensic resources on a Windows machine and the first thing ransomware deletes.

  VSS Architecture
  ══════════════════════════════════════════════════════════════════════

  How VSS Creates a Shadow Copy:
  ─────────────────────────────────────────────────────────────────
  Normal write: App writes to C:\file.txt
              → New data goes directly to the disk cluster

  With VSS snapshot active:
  1. App signals intent to write C:\file.txt
  2. VSS "copy-on-write": Before allowing the write, VSS copies
     the current content of the cluster to the Shadow Copy Store
  3. New data writes to the live volume
  4. Shadow Copy Store now has the "before" version of the cluster

  Result: Shadow copy = point-in-time view of the volume
  Live volume = current state

  Where shadow copies are stored:
  C:\System Volume Information\{GUID}...
  (Hidden system directory, requires SYSTEM or TrustedInstaller to access)

  VSS shadow copy contains:
  ✓ All files as they existed at snapshot time (including deleted files)
  ✓ Registry hives at snapshot time
  ✓ NTDS.dit (if on a DC) at snapshot time
  ✓ SAM database at snapshot time
    
Why ransomware always deletes shadow copies first

A shadow copy is a free backup. If ransomware encrypts all your files but shadow copies remain intact, the victim can simply restore to the previous version and avoid paying the ransom. Every ransomware family since 2013 includes shadow copy deletion as one of its first actions, typically using vssadmin delete shadows /all /quiet, wmic shadowcopy delete, or PowerShell Get-WMIObject Win32_ShadowCopy | Remove-WMIObject. The detection implication: these commands are highly reliable ransomware pre-indicators. An alert on vssadmin or wmic being used to delete shadow copies should be treated as a tier-1 incident, not a false positive investigation. Defenders who enable VSS deletion detection often catch ransomware before the encryption phase starts.

BitLocker and NTFS: The Encryption Layer

BitLocker operates at the volume level, below NTFS. It encrypts the entire volume — including the MFT, the USN journal, the $LogFile, all cluster data. From the perspective of anyone who accesses the disk without the BitLocker key (physically, via forensic boot, via offline attack), the disk is opaque. NTFS structures are encrypted along with file data.

The forensic implication: BitLocker-encrypted volumes require the recovery key before any NTFS forensics is possible. Incident responders who encounter a BitLocker-encrypted system must ensure they can obtain the recovery key (from AD, AAD, or MBAM) before imaging. Powering off a BitLocker machine with TPM-only protection means the next boot will auto-unlock if the TPM measurements match — but a forensic boot from external media will not match, and will require the recovery key.

EFS: File-Level Encryption with a Credential Dependency

EFS (Encrypting File System) provides per-file encryption at the NTFS level, distinct from BitLocker's volume-level encryption. EFS encrypts individual files using the user's certificate and stores the encrypted file encryption key (FEK) in the file's $EFS attribute. The crucial security property: EFS is tied to the user's credentials. A user who is locked out of their account, whose certificate is lost, or whose profile is deleted loses access to their EFS-encrypted files permanently.

Common mistake: EFS as a defense against LSASS attacks

EFS does not protect files from an attacker who is running as that user or as SYSTEM. When a logged-on user accesses an EFS file, Windows automatically decrypts it using the cached credentials — the user doesn't see encryption happening at all. An attacker running code as that user has the same transparent access. EFS protects against: offline disk access (physical theft, forensic imaging without credentials), access by a different user account on the same machine. EFS does not protect against: an attacker who has compromised the user's running session, an attacker running as SYSTEM (who can impersonate any user's context), or an attacker who has stolen the user's DPAPI master key.

Q & A

1. Can an attacker use Alternate Data Streams to completely hide a malware executable from most security tools?

ADS can hide content from directory listings and Explorer, but modern security tools are generally aware of them. Windows Defender scans ADS along with main file data. EDR products using Sysmon Event ID 15 (FileCreateStreamHash) detect ADS creation. However, some legacy or signature-only scanning tools may only scan the default stream. The practical attacker use of ADS today is less about hiding from AV (since most AV handles it) and more about: (1) avoiding detection by human analysts doing manual directory inspection — dir and Explorer won't show streams; (2) hiding configuration or staging data for a multi-stage payload; (3) using the stream execution technique (wscript.exe file.js:stream) to avoid creating a separate suspicious file. The Zone.Identifier ADS removal is more operationally significant — removing it prevents the SmartScreen "this file came from the internet" warning, which can prevent a user from alerting security about a suspicious download.

2. How can a forensic analyst determine a file's true creation time when an attacker has timestomped it?

The primary technique is comparing $STANDARD_INFORMATION timestamps (visible, manipulable) against $FILE_NAME timestamps (maintained by kernel, not changeable via Win32 API). If $SI timestamps show 2019 but $FN timestamps show 2024, the $SI was manipulated. Tools like Autopsy, FTK, and Eric Zimmermann's MFT Explorer display both sets. Additionally: the $LOGFILE (NTFS transaction log) contains records of recent file system transactions — these timestamps can't be manipulated without raw disk access. The USN Change Journal preserves a FILE_CREATE record with its own timestamp that is independent of the file's stored timestamps. Registry hive timestamps (if the file was associated with registry writes) and Windows Event Log entries for process creation can also provide corroborating timestamps. Finally, if a VSS shadow copy predates the alleged creation timestamp, but the file doesn't appear in that shadow copy, the file didn't exist then regardless of what its $SI says.

3. Why is NTDS.dit the ultimate prize for domain credential theft, and what protects it?

NTDS.dit is the Active Directory database stored on domain controllers at C:\Windows\NTDS\ntds.dit. It contains the NT hashes (and Kerberos keys) for every domain account — every user, every computer account, every service account. Extracting NTDS.dit and the SYSTEM registry hive together yields the domain-wide encryption key needed to decrypt the hashes, providing offline crackable hashes for every account in the domain. This is a complete domain credential compromise. Protections: The file is locked by the AD database service while the DC is running — it cannot be simply copied via normal file operations. Common extraction techniques bypass this: (1) ntdsutil creates a backup copy (legitimate admin tool); (2) VSS shadow copy contains an unlocked copy of NTDS.dit from the snapshot time; (3) DCSync attack uses the Domain Replication Service protocol to request password data directly from a DC without touching the file at all — requires only an account with replication rights. Detection: Event ID 4662 with object type "domainDNS" and right "Replicating Directory Changes All" is the DCSync detection signal. VSS access to NTDS.dit generates Event ID 4656 (handle request to object) which EDR can detect.

4. What is the Mark of the Web (MotW) and how is it enforced?

Mark of the Web is a security mechanism that tracks the origin of files downloaded from the internet. When Windows downloads a file (via Edge, Internet Explorer, or most download managers), it writes a Zone.Identifier ADS to the downloaded file containing [ZoneTransfer]\nZoneId=3 (ZoneId 3 = Internet zone). When the user tries to execute that file, Windows checks for this ADS and presents a security warning if present. More importantly, SmartScreen Application Reputation uses MotW to decide whether to scan a file against its reputation database. Applications that respect MotW (Office, script hosts) may apply additional restrictions to files with ZoneId=3 — Protected View in Office documents, for example, is triggered by MotW. Attackers remove MotW by deleting the Zone.Identifier stream before the victim can interact with the file, or by delivering files through channels that don't preserve ADS (email attachments sometimes strip ADS, network shares may not preserve them). Files delivered via USB (FAT32, no ADS support), compressed inside .iso or .img files (which bypass MotW propagation in older Windows versions), or extracted with certain unzip tools that don't propagate MotW, all arrive without the security warning. The .iso delivery method was heavily exploited before Microsoft patched the MotW bypass for ISO files in 2022.