How to get the 'NextUSN' journal entry for a VSS snapshot?

前端 未结 4 1127
孤街浪徒
孤街浪徒 2021-01-05 04:05

after creating a VSS snapshot I\'d like to be able to query the USN journal. Is this possible or is the USN journal not accessible from a VSS snapshot?

my goal

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 05:06

    You may want to give Ruben's answer a second thought:

    The USN Journal in a snapped volume is definitely readable by reading a special file inside the snapped VSS Volume. If the Windows API won't allow you to read the USN journal of a snapped volume then this may be a viable option although I'm sure it feels like a hack.

    The thing is although NTFS does not have an open specification its been figured out by more than one project amongst which is the Linux implementations of NTFS drivers. The document that Ruben posted for you was originally written to help development of this driver.

    Like I mentioned, the USN Journal content sits in a special file on your NTFS volume (like many things in NTFS e.g. The NTFS master file table. Actually it is said that everything in NTFS is a file). Special files in NTFS starts with a dollar sign $ and the one jou are looking for is named $UsnJrnl which in turn resides in a special directory named $Extend. So on your C: volume that file is

    C:\$Extend\$UsnJrnl 
    

    or for you snapshot it would be

    \?\GLOBALROOT\Device\HarddiskVolumeShadowCopy25\$Extend\$UsnJrnl
    

    The info you are looking for sits in an Alternate Data Stream named the $J stream and it has entries in this format (See Ruben's referred to doc):

    Offset(in hex) Size Description
    0x00 4 Size of entry
    0x04 2 Major Version
    0x06 2 Minor Version
    0x08 8 MFT Reference
    0x10 8 Parent MFT Reference
    0x18 8 Offset of this entry in $J
    0x20 8 Timestamp
    0x28 4 Reason (see table below)
    0x2B 4 SourceInfo (see table below)
    0x30 4 SecurityID
    0x34 4 FileAttributes
    0x38 2 Size of filename (in bytes)
    0x3A 2 Offset to filename
    0x3C V Filename
    V+0x3C P Padding (align to 8 bytes)
    

    So you could be reading the $J stream of this special file to get the USN entry that you want. I'm wanting to tell you how to derive the USN number that you will need but I'm a bit rusty. If I figure it out again I will update this answer. But have a look at reading special files this way, its quite fun ;-). I've used this method to read the master file table (Special file $MFT) inside an unmounted VHD file in order to enumerate all the files on the volume inside the VHD.

提交回复
热议问题