NTFS
NTFS uses several system files to maintain the file system. NTFS reserves the first 24 records for specific use, and the first 12 are used by these system files.
1
Master file table - database that tracks every file in the volume
2
a backup copy of the first four records
3
Transaction logging file
4
NTFS attribute definitions
5
Root directory of the disk
6
tracks the allocation (in-use vs free) of each cluster in volume
7
boot record of the volume
8
tracks allocation of each cluster
9
Tracks security information for files within the volume
10
Table of Unicode upper case chars used for file sorting
11
$MFT
Master File Table: MFT
is the main element of New Technology File System (NTFS
) disk partitions.
The MFT
contains entries for all existing files written on the partition. Deleted files that were written or temporarily are stores as a file record. MFT entries are sequential so can be used to identify when a file was added to a device.
A MFT record can be broken down into the following:
Each entry has a size of 1024 bytes (can be 4096 in rare circumstances). Each valid entry will begin with a signature of "FILE
" or "0x46 0x49 0x4c 0x45
". If there's an error in the entry, the signature will be "BAAD
" or "0x42 0x41 0x044
".
Offset 0x08 - $LogFile Sequence Number (LSN) used to determine whether the filesystem is consistent or needs to have certain actions redone or undone
Offset 0x10 - Sequence Number - counter that tracks the number of times an MFT record has been reused. when allocated for the first time, the SN will be set to 1, when delete it becomes unallocated. SN is incremented again etc
Offset 0x12 - number of $FILE_NAME attributes set - multiple can track both long and short names
0ffsec 0x16 - can have the following values: 0x00 0000 Not in Use 0x01 0001 File in Use 0x02 0010 Not in Use 0x03 0011 Not in Use
Offset 0x18 & 0x1C - current size of the bytes being used by the FILE record and total number of bytes allocated to the record.
Offset 0x20 - File Reference to Base Record - only used for extended records
Offset 0x28 - Attribute ID - the number a new attribute will be assigned when added to the current FILE record.
Offset 0x30 - FixUp information - first two bytes are the fixup code, made up of Update Sequence Number (USN) and Update Sequence Array (USA).
0x10::$STANDARD_INFORMATION
0x10::$STANDARD_INFORMATION
0x30::$FILE_NAME (Long)
0x30::$FILE_NAME (Long)
0x30::$FILE_NAME (Short - sometimes)
0x30::$FILE_NAME (Short - sometimes)
0x80::$DATA
0x90::$INDEX_ROOT
0x80::$DATA (alternate data stream -sometimes)
0xA0::$INDEX_ALLOCATION (sometimes)
$MFT stores:
filename
file size
unique
Security ID
in the$STANDARD_INFORMATION
attributeFile creation, last modified, last access and last changes SI timestamps in
$STANDARD_INFORMATION
attributeIf the File Record is in use - if file is deleted the
MFT
file record is set to no longer in use, is not directly deleted during the file deletion. Metadata information and content forMFT
resident files, can be retrieved for recently deleted files (until it gets overwritten by a newMFT
entry).
$MFTMIRR
contains a backup of primary $MFT in case the primary record cannot be read due to physical damage of the disk. Information in record 0 that they system needs to find to read in the rest of the $MFT file.Default cluster size if 4k and records are 1k, this usually works out to be the first four records
$LogFile
Part of the journaling feature of NTFS
; maintains a low-level record of changes made to the NTFS
volume. Every disk operation is journalised prior to being committed. In case of a crash, the $LogFile
is used to revert the disk operations.
While typically it only contains historical data for last few hours (unless the system has been fairly idle) the $LogFile
is the file system resiliency - constantly tracking changes to the following NTFS
features:
Although fairly verbose, it's very efficient, it only logs the data that is being changed.
$LogFile
size defaults to 64Mb (can be adjusted)
NTFS
can use the $LogFile
to complete that file system transactions when power is restored
$Volume
File contains the friendly name of the volume for display in My Computer and other locations, as well as the NTFS version number and set of flags that tell the system if the volume was unmounted cleanly
$AttrDef
Defines the NTFS attributed for the version of NTFS in use on this volume.
"."
Record 5 is the root directory. No different than any other directory except that it is always record number 5 and always a single dot.
$Bitmap
the Bitmap file tracks the allocation status of the clusters of the volume. Each cluster is associated with a bit, set to 0x1 if the cluster is in use.
$Boot
Partition Boot Sector: metadata file which starts at sector 0 and can be up to 16 sectors long, describes ht basic NTFS
volume info and indicates the location of the $MFT
file.
$BadClus
provides the filesystem a way of marking, and not using, clusters where there is physical damage. it's a sparse file that has a file size equal to the volume size and is initially filled with all zeros. Clusters that are all zeros don't actually get written to the disk. If a cluster is determined to be 'bad' data will be written in this file at the offset that corresponds to the location of that bad cluster. existence in this file causes the $Bitmapfile to mark that cluster as in use. thus, no other file will try to use the cluster in the future.
$Secure
The Secure file contains security descriptors for all files and folders on the NTFS
volume. Security descriptors are stored within the $SDS
names data stream of the $secure file. the $secure file also defines two other named streams - $SDH
and $SII
Each file in the system is referenced in the $Secure
file with the Security ID
and Security Descriptor
(which is referenced in the $MFT
in the $STANDARD_INFORMATION
attribute).
While no metadata is stored, the Security ID
can be used to map the file info and data from the MFT
to its Security Descriptor
.
The Security Descriptor
references:
owner of the file (pointed to a
SID
)Access rights
Discretionary Access Control List (DACL)
how access is audited in the
System Access Control List (SACL)
$UpCase
contains a table of upper and lowercase Unicode letters for each Unicode code page in use for the filenames within the system. used in sorting the files by name, so that 'A' and 'a' are next to each other when sorting alphabetically.
$Extend
there's a total of 24 MFT records, rather than place the new system files in those records, a directory entry was placed in record 11, to hold the new system files. the files below are written by the format command before user files are written, they almost always are located in the first four records that are not reserved (number 24-28). They aren't static like the first 12:
$J
Used as an alternative data stream (ADS) for $Extend\$UsnJrnl. Individual records aren't numbered, instead tracked based on their offset into the data stream. Due to this, to analyse the $Extend\$UsnJrnl you actually need to export the $J attribute. Normally a Sparse file (filled with blank space) but when forensically extracting will take the full file size - but does compress very well (as mainly empty space)
$J often spans around +3GB in size
Common activity patterns:
File / Directory creation
AddIndexEntryAllocation AddIndexEntryRoot InitializeFileRecordSegment
FileCreate
File/ Directory deletion
DeleteIndexEntryAllocation DeleteIndexEntryRoot DeallocateFileRecordSegment
FileDelete
File / Directory Rename or Move
DeleteIndexEntryAllocation AddIndexEntryAllocation
RenameOldName RenameNewName
ADS Creation
CreateAttribute with name ending in ":ADS"
StreamChange NamedDataExtend
File Data Modification
*Op codes for $LogFile often are not efficient to determine file modification
DataOverwrite | DataExtend |DataTruncation
Extracting Data:
It's good to target directories when looking at parsing $LogFile and $Extend\$UsnJrnl. Also check for: .exe, .dll, .sys, .pyd, .ps1, .vbs, .bat, .rar, .7z, .cab
C:\Windows & C:\Windows\system32
Directories coveted by attackers
C:\Windows\Prefetch
Attackers often delete prefect files
Attackers Working Dir
Discover unknown attacker tools and exfil
Temp directories
Focus on executables
C:\Users\*\Downloads
Find recently downloaded files
C:\Users\*\Appdata\Roaming\Microsoft\Windows\Recent
Find recently downloaded files
C:\$Recycle.Bin\<SID>
Check for deleted file prior to Recycle bin empty
MFTECmd
The primary output gives an overview of the data contained in the $LogFile, (logfile.csv) but includes summary information about each event in the $LogFile but if more info is available will produce supplementary files
istat
Sleuth kits istat
- designed to parse metadata information from file systems, including NTFS, FAT, and ExFAT. Can be used against lots of image files, e.g. raw, E01, VMDK, VHD
Icat
Sleuth kits icat
- designed to go to metadata and extract out file or attribute content good for extraction of $DATA content
tsk_recover
tsk_recover
is a sleuth kit Metadata file carving tool with several options available, by default it identifies unallocated inodes ( $MFT entries) and extract them all to a specified output directory
works to extract all deleted files, instead of singular with Icat
PhotoRec
file Carving tool - runs on Unix, and Windows. Knows 480 file extensions. and support NTFS, FAT, Ext2/3/4. Once it parses files, it will search metadata to try and find original file metadata including size and original name. can run directly on E01
Indx2CSV parses both slack and active entries of $I30, $Extend\$objId, $Extend\$Reparse. Reads INDX records exported with forensics tools.
Last updated