ntfstool

repository·master·Indexed 20 days ago

https://github.com/thewhiteninja/ntfstool

A command-line utility for forensic analysis and manipulation of NTFS-related artifacts. It provides capabilities for BitLocker volume decryption, FVE metadata extraction, and recovery key validation. Additionally, it supports Encrypting File System (EFS) operations, including backing up certificates and keys to .pfx archives, analyzing EFS certificates, and decrypting EFS-protected files.

Tokens
14.4K
Snippets
44
Records
71
Agent score
70%

What's inside ntfstool

  1. Extracting NTFS streams

    master
    When extracting a file, you can target a specific NTFS stream. If the --stream option is provided, the tool will attempt to extract that specific stream name instead of the default unnamed data stream. If the source path in --from contains a stream identifier (e.g., file:stream), the tool will split the path to identify the stream name.
  2. Undelete deleted files from NTFS/Bitlocker volumes

    master

    The undelete command scans an NTFS or Bitlocker volume to identify deleted files and directories. It calculates a recovery percentage for each file based on whether its data clusters have been reused (checked against the $BITMAP file).

    Results can be displayed in a formatted table in the terminal or exported to a file in csv or json format.

    Output Columns:

    • Id: Sequential ID
    • MFT Index: The hex MFT record index
    • Type: File or Dir
    • Filename: The full path of the deleted item
    • Size: The size of the file (empty for directories)
    • Deletion Date: The timestamp from $STANDARD_INFORMATION
    • % Recoverable: The estimated percentage of data still intact
    # Note: This is a conceptual usage based on the command logic.
    # To list deleted files:
    ntfstool undelete --disk <disk_name> --volume <volume_index>
    
    # To export deleted files to JSON:
    ntfstool undelete --disk <disk_name> --volume <volume_index> --format json --output results.json
  3. Analyze USN Journal (Offline and Live)

    master

    The analyze command for the USN journal allows you to parse and analyze NTFS Update Sequence Number (USN) records. It supports two primary modes of operation:

    1. Offline Analysis: Analyzing a USN journal dump from a file. This is used when you have a pre-captured dump of the $UsnJrnl:$J stream.
    2. Live Analysis: Analyzing the USN journal directly from a live volume on a disk.

    The tool matches records against user-defined rules and outputs the results to a CSV file. It provides a summary of record statistics and rule match percentages in the console upon completion.

  4. Requirements for running ntfstool

    master
    To perform low-level operations such as reading physical drives, ntfstool must be executed with Administrator privileges. If the application is not elevated, it will exit with the error: Administrator rights are required to read physical drives.
  5. Decrypt EFS files using the CLI

    master

    The efs decrypt command allows you to decrypt files protected by Windows Encrypting File System (EFS) by providing a PKCS#12 (.pfx) archive containing the necessary certificate and private key. The tool identifies the correct decryption field within the NTFS $EFS stream by matching the certificate thumbprint from the PFX file with the entries in the file's metadata.

    To successfully decrypt a file, you must provide:

    1. A target disk or volume.
    2. A pfx file path containing the certificate.
    3. The password for the PFX file.
    4. The path to the target file (via the standard file selection options used by the tool).

    If no output path is specified, the tool will default to saving the decrypted content as <original_filename>.decrypted.

    # Note: The exact CLI syntax depends on the global parser, but based on the dispatch logic, the required options are:
    # ntfstool efs decrypt --disk <disk> --volume <volume> --pfx <path_to_pfx> --password <pfx_password> [file_options]
  6. Extract files from an NTFS volume

    master

    The extract command allows you to recover files from an NTFS disk or volume. It can extract standard files or specific NTFS streams. The tool attempts to preserve file metadata, including creation/read/alter times and file attributes, by reading the $STANDARD_INFORMATION attribute from the MFT record.

    Key Features:

    • Stream Support: You can specify a specific NTFS stream to extract using the --stream option.
    • Metadata Preservation: Automatically attempts to set file timestamps and attributes on the output file.
    • System File Shortcuts: If no source path is provided, using --sam or --system will automatically target c:\windows\system32\config\sam or c:\windows\system32\config\system respectively.
    • Encryption Warning: If the file is encrypted (detected via the $STANDARD_INFORMATION attribute), the tool will notify you that the extracted data is not readable.
    # Note: This is a CLI command. Usage depends on the specific CLI wrapper, but the logic follows:
    # ntfstool extract --disk <disk> --volume <vol> --from <path> --output <path> [--stream <stream_name>]
    # Or for system files:
    # ntfstool extract --disk <disk> --volume <vol> --sam --output <path>
  7. Analyze EFS Master Keys

    master

    The EFS masterkey command suite allows you to list, inspect, and decrypt Windows Encrypting File System (EFS) master key files located in user profiles (typically under \Users\<User>\AppData\Roaming\Microsoft\Protect\<SID>\).

    Usage Modes

    1. List all master keys: If no specific inode or file path is provided, the tool scans the C:\Users directory to find all available master key files, preferred files, and credential histories.
    2. Show master key details: If a specific file (via inode or from path) is specified, the tool parses the file and displays metadata such as Version, GUID, Policy, and details for the MasterKey, BackupKey, DomainKey, or Credential History.
    3. Decrypt master key: If a specific file is specified AND both a sid and password are provided, the tool attempts to decrypt the master key and outputs the cleartext key in hex format.
  8. Use the interactive NTFS shell

    master

    The ntfstool provides an interactive shell mode for exploring NTFS file systems. Once the shell is active, you can navigate directories, list files, view MFT record details, and perform basic file operations like copying or reading content. The shell prompt follows the format: disk<disk_index>:volume<volume_index>:<current_path>> .

    # This is a conceptual usage example of the shell interface
    # After launching the tool with specific disk/volume options:
    
    disk0:volume1:\> ls
    
    disk0:volume1:\> cd folder
    
    disk0:volume1:\folder\> pwd
    
    disk0:volume1:\folder\> cat file.txt
    
    disk0:volume1:\folder\> quit
  9. Extract a specific deleted file by MFT index

    master

    If you have identified a specific deleted file via the listing command, you can extract its contents directly to a file. This requires providing the MFT record index (inode) and a destination output path.

    Requirements:

    • The --inode option must be set to a non-negative value.
    • The --output option must be provided with a valid file path.
    • The volume must be NTFS or Bitlocker.
    # Example: Extracting MFT index 12345 to a file named recovered.dat
    ntfstool undelete --disk <disk_name> --volume <volume_index> --inode 12345 --output recovered.dat
  10. Use the help command to view usage information

    master

    The help command provides usage information for the tool itself or for specific subcommands.

    • To see the general list of all available commands, run: help
    • To see detailed usage, options, and examples for a specific command, run: help [command]
    # General help
    ntfstool help
    
    # Help for a specific command
    ntfstool help info
  11. Analyze EFS certificates via CLI

    master

    The EFS certificate command allows you to either list all certificates found in user directories or display the detailed properties of a specific certificate file using its inode. This is useful for forensic analysis of Encrypting File System (EFS) artifacts on NTFS volumes.

    Modes of Operation

    1. List Certificates: If no specific inode or file path is provided, the tool scans C:\Users\<User>\AppData\Roaming\Microsoft\SystemCertificates\My\Certificates for all user certificates. It displays a table containing the User, File Name, MFT Record Index, Size, Creation Time, and certificate metadata (Friendly Name, Container, Provider, etc.).
    2. Show Specific Certificate: If an inode or from path is provided, the tool targets that specific MFT record to extract and display its full certificate properties or export it.

    Exporting Certificates

    If you provide an --output path, instead of displaying the certificate properties in a table, the tool will attempt to export the certificate to a .pem file at the specified location.

    # Note: Exact CLI syntax depends on the main entrypoint, but the logic follows:
    # To list all certificates:
    ntfstool efs certificate [disk_options] [volume_options]
    
    # To show a specific certificate by inode:
    ntfstool efs certificate --inode <inode_number>
    
    # To export a certificate to a PEM file:
    ntfstool efs certificate --inode <inode_number> --output <output_path>
  12. Use the `info` command to view disk and volume information

    master

    The info command provides detailed metadata about physical disks, disk images, and their constituent volumes/partitions.

    Usage Patterns

    1. List all disks: Running info without specific disk or image options provides a summary table of all detected disks.
    2. View specific disk details: Provide a disk index or a path to a disk image to see hardware/file metadata, geometry, and a partition table.
    3. View specific volume details: Provide a disk index/image AND a volume index to see detailed information about a specific partition (e.g., filesystem, offset, size, Bitlocker status).

    Information Provided

    • Disks: Model, Type (SSD/HDD/Virtual), Partition Style (MBR/GPT), Size, and Geometry.
    • Volumes: Filesystem, Label, Mountpoints, Offset, Size, Free Space, and Bitlocker status (Locked/Unlocked).
    • Disk Images: For image files, it also provides file creation/modification/access timestamps and an option to calculate a SHA256 hash.
    # Example: List all disks
    ntfstool info
    
    # Example: View details for disk index 0
    ntfstool info --disk 0
    
    # Example: View details for a disk image
    ntfstool info --image /path/to/image.img
    
    # Example: View details for volume 1 on disk 0
    ntfstool info --disk 0 --volume 1
    
    # Example: View details for volume 1 on a disk image
    ntfstool info --image /path/to/image.img --volume 1