ntfs-logfile

Queries transaction log records from the $LogFile of an NTFS file system. Enables analysis of file system change history including file creation, deletion, and renaming.

Command properties

PropertyDescription
Command typeDriver
Required permissionNone
License usageCounted
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

ntfs-logfile [zipcharset=STR] [zippath=STR] FILE_PATH

Options

zipcharset=STR
Character encoding of ZIP file entries. (Default: utf-8)
zippath=STR
Path to the ZIP file. When this option is specified, queries the $LogFile inside the ZIP file.

Target

FILE_PATH
File path of the $LogFile. You can use wildcards (*) to query multiple matching files at once.

Output fields

FieldTypeDescription
_filestringSource file name
pageintegerPage number
lsnlongLog sequence number (LSN)
prev_lsnlongPrevious log sequence number
redo_opstringRedo operation code. See the operation code table below.
undo_opstringUndo operation code. See the operation code table below.
record_typeintegerRecord type. 1: Normal record, 2: Checkpoint record
redo_offsetintegerRedo data offset
redo_lenintegerRedo data length
undo_offsetintegerUndo data offset
undo_lenintegerUndo data length
client_data_lengthintegerClient data length
flagsintegerRecord flags
mft_headstring16-byte hex dump of the MFT record header. Output when redo_op is initialize_file_record_segment, delete_index_entry_root, or delete_index_entry_allocation.
mft_lsnlongLog sequence number of the MFT record. Output when redo_op is one of the above codes.
mft_link_countintegerHard link count of the MFT record. Output when redo_op is one of the above codes.
file_namestringFile name. Output when redo_op is one of the above codes and the $FILE_NAME attribute exists.
created_attimestampFile creation time. Output when redo_op is one of the above codes and the $FILE_NAME attribute exists.
modified_attimestampFile modification time. Output when redo_op is one of the above codes and the $FILE_NAME attribute exists.
access_attimestampFile access time. Output when redo_op is one of the above codes and the $FILE_NAME attribute exists.
Operation codes

The operation codes output in the redo_op and undo_op fields are as follows.

Operation codeHex valueDescription
noop0x00No operation
compensation_log_record0x01Compensation log record
initialize_file_record_segment0x02Initialize file record segment
deallocate_file_record_segment0x03Deallocate file record segment
write_end_of_file_record_segment0x04Write end of file record segment
create_attribute0x05Create attribute
delete_attribute0x06Delete attribute
update_resident_value0x07Update resident value
update_non_resident_value0x08Update non-resident value
update_mapping_pairs0x09Update mapping pairs
delete_dirty_clusters0x0aDelete dirty clusters
set_new_attribute_size0x0bSet new attribute size
add_index_entry_root0x0cAdd root index entry
delete_index_entry_root0x0dDelete root index entry
add_index_entry_allocation0x0eAdd allocation index entry
delete_index_entry_allocation0x0fDelete allocation index entry
set_index_entry_ven_allocation0x12Set VCN of allocation index entry
update_file_name_root0x13Update root file name
update_file_name_allocation0x14Update allocation file name
set_bits_in_non_resident_bitmap0x15Set bits in non-resident bitmap
clear_bits_in_non_resident_bitmap0x16Clear bits in non-resident bitmap
prepare_transaction0x19Prepare transaction
commit_transaction0x1aCommit transaction
forget_transaction0x1bForget transaction
open_non_resident_attribute0x1cOpen non-resident attribute
open_attribute_table_dump0x1dOpen attribute table dump
dirty_page_table_dump0x1fDirty page table dump
transaction_table_dump0x20Transaction table dump
update_record_data_root0x21Update root record data

Error codes

Parse errors

None

Runtime errors

None

Description

The ntfs-logfile command parses the $LogFile, which is the transaction log file of the NTFS file system, and outputs each transaction log record. The $LogFile records changes to file system metadata as Redo/Undo operation pairs.

For records where redo_op is initialize_file_record_segment, MFT record information is also extracted, outputting the file name and creation/modification/access times. For records where redo_op is delete_index_entry_root or delete_index_entry_allocation, information about the deleted file is extracted from the Undo data.

Using wildcards (*) in the file path allows querying all matching files at once. Specifying the zippath option allows directly querying a $LogFile inside a ZIP file.

Examples

  1. Query $LogFile transaction logs

    ntfs-logfile /data/ntfs/LogFile
    

    Queries transaction log records from the $LogFile at the specified path.

  2. Query $LogFile inside a ZIP file

    ntfs-logfile zippath=/data/evidence.zip ntfs/LogFile
    

    Queries the $LogFile inside a ZIP file.

  3. Query file creation and deletion history

    ntfs-logfile /data/ntfs/LogFile
    | sort lsn
    | search redo_op == "initialize_file_record_segment" or redo_op == "*delete*"
    

    Queries records where redo_op is initialize_file_record_segment or contains delete, in LSN order.