ひよこメモ

自分が調べたこととか試したこととか書いていきます

NTFSのトンネリングとLocalFileMove(前編)

はじめに

こんにちは、iria_piyo🐣です。

削除済みのファイル名と同じファイル名でファイルを作成したら、$SIの作成時間が引き継がれたため、 LocalFileMoveで検証してみることにしました。

環境

Windows10 バージョン1803

検証内容

/test01/pomu_test01.txtを削除し、15秒以内に/test01/test02/pomu_test01.txtを/test01に移動すると削除されたpomu_test01.txtの作成時間が引き継がれるのか。

f:id:iria_piyo:20180921194852p:plain
ディレクトリ構成

/test01/pomu_test01.txtのタイムスタンプ

>istat \\.\C: 58652-128-1
MFT Entry Header Values:
Entry: 58652        Sequence: 46
$LogFile Sequence Number: 75722774793
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 3318  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16328365728
Created:        2018-09-21 18:03:06.764304200 (
File Modified:   2018-09-21 18:03:06.765301300 (
MFT Modified: 2018-09-21 18:03:15.946931800 (
Accessed:        2018-09-21 18:03:06.764304200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_T~1.TXT
Parent MFT Entry: 21923         Sequence: 245
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:06.764304200 (
File Modified:   2018-09-21 18:03:06.765301300 (
MFT Modified: 2018-09-21 18:03:06.765301300 (
Accessed:        2018-09-21 18:03:06.764304200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_test01.txt
Parent MFT Entry: 21923         Sequence: 245
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:06.764304200 (
File Modified:   2018-09-21 18:03:06.765301300 (
MFT Modified: 2018-09-21 18:03:06.765301300 (
Accessed:        2018-09-21 18:03:06.764304200 (
$OBJECT_ID Attribute Values:
Object Id: d1c03db5-bd7a-11e8-84da-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-5)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-4)   Name: N/A   Resident   size: 96
Type: $OBJECT_ID (64-6)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

/test02/pomu_test01.txtのタイムスタンプ

>istat \\.\C: 17067-128-1
MFT Entry Header Values:
Entry: 17067        Sequence: 96
$LogFile Sequence Number: 75722783398
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 3318  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16328369760
Created:        2018-09-21 18:03:24.405986700 (
File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:03:29.739141900 (
Accessed:        2018-09-21 18:03:24.405986700 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_T~1.TXT
Parent MFT Entry: 434092        Sequence: 31
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:24.405986700 (
File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:03:24.405986700 (
Accessed:        2018-09-21 18:03:24.405986700 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_test01.txt
Parent MFT Entry: 434092        Sequence: 31
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:24.405986700 (
File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:03:24.405986700 (
Accessed:        2018-09-21 18:03:24.405986700 (
$OBJECT_ID Attribute Values:
Object Id: d1c03dbe-bd7a-11e8-84da-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-5)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-4)   Name: N/A   Resident   size: 96
Type: $OBJECT_ID (64-6)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

ファイル削除後/test01/test02から/test01へ移動したpomu_test01.txtのタイムスタンプ

>istat \\.\C: 17067-128-1
MFT Entry Header Values:
Entry: 17067        Sequence: 96
$LogFile Sequence Number: 75723187786
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 3318  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16328487328
Created:        2018-09-21 18:03:06.764304200 (
File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:15:43.299740200 (
Accessed:        2018-09-21 18:03:24.405986700 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_T~1.TXT
Parent MFT Entry: 21923         Sequence: 245
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:24.405986700 
(File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:03:29.739141900 (
Accessed:        2018-09-21 18:03:24.405986700 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_test01.txt
Parent MFT Entry: 21923         Sequence: 245
Allocated Size: 0       Actual Size: 0
Created:        2018-09-21 18:03:24.405986700 (
File Modified:   2018-09-21 18:03:24.405986700 (
MFT Modified: 2018-09-21 18:03:29.739141900 (
Accessed:        2018-09-21 18:03:24.405986700 (
$OBJECT_ID Attribute Values:
Object Id: d1c03dbe-bd7a-11e8-84da-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-8)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-7)   Name: N/A   Resident   size: 96
Type: $OBJECT_ID (64-6)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

結果

ファイルの作成時間が引き継がれました。
この動きには、NTFS/FATのトンネリング*1が関係しているようです。
ファイル名で判断しているから、その前の動きは特に関係ないのかな。
ちょっと気になることができて、検証したいことが増えたから前編にしました。
すぐに後編も出します。

参考資料

A Fistful of Dongles: Microsoft Windows File System Tunneling

*1:ファイルがディレクトリから削除またはリネームされると、SFN/LFNと作成時間が短時間(デフォルトで15秒間)キャッシュに保存されます。このキャッシュは、ディレクトリごとに分けられています。 削除されたファイル名がキーとなり、新しいファイルがディレクトリに追加されると、キャッシュを検索し、復元できる情報があるか確認されます。 ディレクトリが削除されてしまうと、そのディレクトリのキャッシュも削除されてしまいます。

ファイルアクセスでタイムスタンプが更新された件

はじめに

こんにちは、iria_piyo🐣です。

コマンドによるファイル作成後のファイルアクセスとエクスプローラー上でのファイル作成後のファイルアクセスで結果が違ったため、メモをすることにしました。

使用したツールはThe Sleuth Kitです。
詳細はこちら
https://www.sleuthkit.org/sleuthkit/

環境

Windows10 バージョン1803

エクスプローラーで右クリックしてファイル作成

ファイル作成時のタイムスタンプ

> istat \\.\C: 71520-128-1
MFT Entry Header Values:
Entry: 71520        Sequence: 33
$LogFile Sequence Number: 74460574771
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 2836  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16024806192
Created:        2018-09-12 16:12:26.624456200 (  
File Modified:   2018-09-12 16:12:26.624456200 (  
MFT Modified:    2018-09-12 16:12:36.463228600 (
Accessed:     2018-09-12 16:12:26.624456200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_P~1.TXT
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:12:26.624456200 (
File Modified:   2018-09-12 16:12:26.624456200 (
MFT Modified:    2018-09-12 16:12:26.624456200 (
Accessed:     2018-09-12 16:12:26.624456200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_piyo_access.txt
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:12:26.624456200 (
File Modified:   2018-09-12 16:12:26.624456200 (
MFT Modified:    2018-09-12 16:12:26.624456200 (
Accessed:     2018-09-12 16:12:26.624456200 (
$OBJECT_ID Attribute Values:
Object Id: 4f61379b-b659-11e8-84d1-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-5)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-4)   Name: N/A   Resident   size: 106
Type: $OBJECT_ID (64-6)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

アクセス後のタイムスタンプ

> istat \\.\C: 71520-128-1
MFT Entry Header Values:
Entry: 71520        Sequence: 33
$LogFile Sequence Number: 74460574771
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 2836  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16024806192
Created:        2018-09-12 16:12:26.624456200 (
File Modified:   2018-09-12 16:12:26.624456200 (
MFT Modified:    2018-09-12 16:12:36.463228600 (
Accessed:     2018-09-12 16:12:26.624456200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_P~1.TXT
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:12:26.624456200 (
File Modified:   2018-09-12 16:12:26.624456200 (
MFT Modified:    2018-09-12 16:12:26.624456200 (
Accessed:     2018-09-12 16:12:26.624456200 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_piyo_access.txt
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:12:26.624456200 (
File Modified:   2018-09-12 16:12:26.624456200 (
MFT Modified:    2018-09-12 16:12:26.624456200 (
Accessed:     2018-09-12 16:12:26.624456200 (
$OBJECT_ID Attribute Values:
Object Id: 4f61379b-b659-11e8-84d1-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-5)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-4)   Name: N/A   Resident   size: 106
Type: $OBJECT_ID (64-6)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

fsutilコマンドでファイル作成

ファイル作成時のタイムスタンプ

> istat \\.\C: 455157-128-1
MFT Entry Header Values:
Entry: 455157        Sequence: 18
$LogFile Sequence Number: 74458591244
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 2836  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16023692008
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:02:31.240774600 (
Accessed:     2018-09-12 16:02:31.240774600 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_A~1.TXT
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:02:31.240774600 (
Accessed:     2018-09-12 16:02:31.240774600 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_access.txt
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:02:31.240774600 (
Accessed:     2018-09-12 16:02:31.240774600 (
Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-3)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-2)   Name: N/A   Resident   size: 96
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

アクセス後のタイムスタンプ

> istat \\.\C: 455157-128-1
MFT Entry Header Values:
Entry: 455157        Sequence: 18
$LogFile Sequence Number: 74460111064
Allocated File
Links: 2

$STANDARD_INFORMATION Attribute Values:
Flags: Archive
Owner ID: 0
Security ID: 2836  (S-1-5-21-3763767945-1047358448-4033639875-8282)
Last User Journal Update Sequence Number: 16024537296
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:09:54.066031100 (
Accessed:     2018-09-12 16:02:31.240774600 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: POMU_A~1.TXT
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:02:31.240774600 (
Accessed:     2018-09-12 16:02:31.240774600 (
$FILE_NAME Attribute Values:
Flags: Archive
Name: pomu_access.txt
Parent MFT Entry: 53759         Sequence: 9
Allocated Size: 0       Actual Size: 0
Created:        2018-09-12 16:02:31.240774600 (
File Modified:   2018-09-12 16:02:31.240774600 (
MFT Modified:    2018-09-12 16:02:31.240774600 (
Accessed:     2018-09-12 16:02:31.240774600 (
$OBJECT_ID Attribute Values:
Object Id: 4f613088-b659-11e8-84d1-a81374942b83

Attributes:
Type: $STANDARD_INFORMATION (16-0)   Name: N/A   Resident   size: 72
Type: $FILE_NAME (48-3)   Name: N/A   Resident   size: 90
Type: $FILE_NAME (48-2)   Name: N/A   Resident   size: 96
Type: $OBJECT_ID (64-4)   Name: N/A   Resident   size: 16
Type: $DATA (128-1)   Name: N/A   Resident   size: 0

エクスプローラー上でファイル作成をした場合、ファイルアクセスを行っても タイムスタンプは更新されません。

ですが、コマンドによるファイル作成を行った場合、ファイルアクセスを行うと 初回アクセス時のみ$SIのMFT Modifiedのタイムスタンプが更新されます。 その後、再びファイルアクセスを行っても、タイムスタンプは更新されません。

どうしてタイムスタンプが更新されたのか

理由は、コマンドによるファイル作成ではObjectIDがファイルに付与されず、 初回アクセス時にObjectID*1が付与されたことだと考えられます。

エクスプローラ上で右クリックをしてファイル作成を行うとRecentフォルダに作成したファイルのショートカットファイルが作成されます。 ファイル作成時にObjectID が付与されるため、その後ファイルアクセスを行っても、 $SIのMFT Modifiedは更新されません。

※ObjectIDはショートカットファイル作成時にファイルとショートカットファイル内に付与され、両方のファイルを紐づけする役割を果たします。 これによりファイル移動を行ってもショートカットファイルからファイルの実行が可能となっています。

さいごに

前に、コマンドによるファイル作成ではショートカットファイルが作成されないと聞いたので試してみました。これからも積極的にメモしていこうと思います。

*1:ObjectIDはショートカットファイル作成時にファイルとショートカットファイル内に付与され、両方のファイルを紐づけする役割を果たします。 これによりファイル移動を行ってもショートカットファイルからファイルの実行が可能となっています。