NTFSのトンネリングとHardlink
🐣🎄IPFactory Advent Calendar 2019 - Qiita 18日目の記事です🎄🐣
はじめに
こんにちは、iria_piyo🐣です。
今回は、ハードリンク同士でファイルシステムのトンネリング*1の検証を2つ行いました。
使用したツールはThe Sleuth Kitです。
環境
Windows10 1903
検証内容1
ファイルtest01.txt
のハードリンクhardlink01
を削除し、15秒以内にファイルtest02.txt
のハードリンクhardlink01
を作成します。
手順は以下の通り。
- ファイル
test01.txt
とtest02.txt
を作成 - ファイル
test01.txt
のハードリンクhardlink01
を作成 - ファイル
test01.txt
のハードリンクhardlink01
を削除 - 手順3で消したハードリンクと同じディレクトリに、ファイル
test02.txt
のハードリンクをhardlink01
という名前で作成
この結果、test01.txt
の作成時間がtest02.txt
に引き継がれるかを検証していきます。
ファイルtest01.txt
作成時のタイムスタンプ
# istat \\.\C: 146771 MFT Entry Header Values: Entry: 146771 Sequence: 86 $LogFile Sequence Number: 153267805192 Allocated File Links: 1 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5650018112 Created: 2019-12-16 23:30:04.578859200 ( File Modified: 2019-12-16 23:30:04.578859200 ( MFT Modified: 2019-12-16 23:30:04.578859200 ( Accessed: 2019-12-16 23:30:04.578859200 ( $FILE_NAME Attribute Values: Flags: Archive Name: test01.txt Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:04.578859200 ( File Modified: 2019-12-16 23:30:04.578859200 ( MFT Modified: 2019-12-16 23:30:04.578859200 ( Accessed: 2019-12-16 23:30:04.578859200 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest02.txt
作成時のタイムスタンプ
# istat \\.\C: 1040145 MFT Entry Header Values: Entry: 1040145 Sequence: 387 $LogFile Sequence Number: 153267817132 Allocated File Links: 1 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5650021360 Created: 2019-12-16 23:30:12.724593400 ( File Modified: 2019-12-16 23:30:12.725590900 ( MFT Modified: 2019-12-16 23:30:12.725590900 ( Accessed: 2019-12-16 23:30:12.725590900 ( $FILE_NAME Attribute Values: Flags: Archive Name: test02.txt Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:12.724593400 ( File Modified: 2019-12-16 23:30:12.724593400 ( MFT Modified: 2019-12-16 23:30:12.724593400 ( Accessed: 2019-12-16 23:30:12.724593400 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest01.txt
のハードリンクhardlink01
を作成
# fsutil hardlink create hardlink01 test01.txt C:\hardlink_create\hardlink01 <<===>> C:\hardlink_create\test01.txt のハードリンクが作成されました
ハードリンクhardlink01
作成後のファイルtest01.txt
のタイムスタンプ
# istat \\.\C: 146771 MFT Entry Header Values: Entry: 146771 Sequence: 86 $LogFile Sequence Number: 153276670676 Allocated File Links: 2 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5650175544 Created: 2019-12-16 23:30:04.578859200 ( File Modified: 2019-12-16 23:30:04.578859200 ( MFT Modified: 2019-12-16 23:33:48.819870600 ( Accessed: 2019-12-16 23:30:04.578859200 ( $FILE_NAME Attribute Values: Flags: Archive Name: hardlink01 Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:04.578859200 ( File Modified: 2019-12-16 23:30:04.578859200 ( MFT Modified: 2019-12-16 23:33:48.819870600 ( Accessed: 2019-12-16 23:30:04.578859200 ( $FILE_NAME Attribute Values: Flags: Archive Name: test01.txt Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:04.578859200 ( File Modified: 2019-12-16 23:30:04.578859200 ( MFT Modified: 2019-12-16 23:30:04.578859200 ( Accessed: 2019-12-16 23:30:04.578859200 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-3) Name: N/A Resident size: 86 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest01.txt
のハードリンクhardlink01
を削除
# del hardlink01
ここで、15秒以内に削除したハードリンクと同名のハードリンクを作成します。
ファイルtest02.txt
のハードリンクをhardlink01
という名前で作成
C:\hardlink_create\hardlink01 <<===>> C:\hardlink_create\test02.txt のハードリ ンクが作成されました
ここで、test01.txt
の作成時間がtest02.txt
の作成時間に引き継がれているかを確認します。
ハードリンクhardlink01
作成後のファイルtest02.txt
のタイムスタンプ
# istat \\.\C: 1040145 MFT Entry Header Values: Entry: 1040145 Sequence: 387 $LogFile Sequence Number: 153276931204 Allocated File Links: 2 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5650276352 Created: 2019-12-16 23:30:12.724593400 ( File Modified: 2019-12-16 23:30:12.725590900 ( MFT Modified: 2019-12-16 23:35:57.706606600 ( Accessed: 2019-12-16 23:30:12.725590900 ( $FILE_NAME Attribute Values: Flags: Archive Name: hardlink01 Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:12.724593400 ( File Modified: 2019-12-16 23:30:12.725590900 ( MFT Modified: 2019-12-16 23:35:57.706606600 ( Accessed: 2019-12-16 23:30:12.725590900 ( $FILE_NAME Attribute Values: Flags: Archive Name: test02.txt Parent MFT Entry: 2818 Sequence: 50 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 23:30:12.724593400 ( File Modified: 2019-12-16 23:30:12.724593400 ( MFT Modified: 2019-12-16 23:30:12.724593400 ( Accessed: 2019-12-16 23:30:12.724593400 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-3) Name: N/A Resident size: 86 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
検証内容1の結果
作成時間が$SI、$FNのどちらにも引き継がれなかった。
検証内容2
次は、リネームでトンネリングが起こるか検証しました。
ファイルtest01.txt
のハードリンクhardlink01
を削除し、15秒以内にファイルtest02.txt
のハードリンクをhardlink02
からhardlink01
にリネームします。
手順は以下の通り。
- ファイル
test01.txt
とファイルtest02.txt
を作成 - ファイル
test01.txt
のハードリンクhardlink01
、ファイルtest02.txt
のハードリンクhardlink02
を作成 - ファイル
test01.txt
のハードリンクhardlink01
を削除 - ファイル
test02.txt
のハードリンクhardlink02
をhardlink01
にリネーム
この結果、test01.txt
の作成時間がtest02.txt
に引き継がれるかを検証していきます。
ファイルtest01.txt
作成時のタイムスタンプ
# istat \\.\C: 2774 MFT Entry Header Values: Entry: 2774 Sequence: 19 $LogFile Sequence Number: 153197282607 Allocated File Links: 1 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5633252760 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:34.889876600 ( MFT Modified: 2019-12-16 20:34:34.889876600 ( Accessed: 2019-12-16 20:34:34.889876600 ( $FILE_NAME Attribute Values: Flags: Archive Name: test01.txt Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:34.889876600 ( MFT Modified: 2019-12-16 20:34:34.889876600 ( Accessed: 2019-12-16 20:34:34.889876600 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest02.txt
作成時のタイムスタンプ
# istat \\.\C: 83955 MFT Entry Header Values: Entry: 83955 Sequence: 25 $LogFile Sequence Number: 153197294820 Allocated File Links: 1 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5633259728 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:34:37.682492800 ( Accessed: 2019-12-16 20:34:37.682492800 ( $FILE_NAME Attribute Values: Flags: Archive Name: test02.txt Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:34:37.682492800 ( Accessed: 2019-12-16 20:34:37.682492800 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest01.txt
のハードリンクhardlink01
を作成
# fsutil hardlink create hardlink01 test01.txt C:\hardlink\hardlink01 <<===>> C:\hardlink\test01.txt のハードリンクが作成されました
ファイルtest02.txt
のハードリンクhardlink02
を作成
# fsutil hardlink create hardlink02 test02.txt C:\hardlink\hardlink02 <<===>> C:\hardlink\test02.txt のハードリンクが作成されました
ハードリンクhardlink01
作成後のファイルtest01.txt
のタイムスタンプ
# istat \\.\C: 2774 MFT Entry Header Values: Entry: 2774 Sequence: 19 $LogFile Sequence Number: 153198686978 Allocated File Links: 2 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5634040352 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:34.889876600 ( MFT Modified: 2019-12-16 20:37:52.573895500 ( Accessed: 2019-12-16 20:34:34.889876600 ( $FILE_NAME Attribute Values: Flags: Archive Name: hardlink01 Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:34.889876600 ( MFT Modified: 2019-12-16 20:37:52.573895500 ( Accessed: 2019-12-16 20:34:34.889876600 ( $FILE_NAME Attribute Values: Flags: Archive Name: test01.txt Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:34.889876600 ( MFT Modified: 2019-12-16 20:34:34.889876600 ( Accessed: 2019-12-16 20:34:34.889876600 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-3) Name: N/A Resident size: 86 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ハードリンクhardlink02
作成後のファイルtest02.txt
のタイムスタンプ
# istat \\.\C: 83955 MFT Entry Header Values: Entry: 83955 Sequence: 25 $LogFile Sequence Number: 153198732704 Allocated File Links: 2 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5634067536 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:38:00.744881700 ( Accessed: 2019-12-16 20:34:37.682492800 ( $FILE_NAME Attribute Values: Flags: Archive Name: test02.txt Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:34:37.682492800 ( Accessed: 2019-12-16 20:34:37.682492800 ( $FILE_NAME Attribute Values: Flags: Archive Name: hardlink02 Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:38:00.744881700 ( Accessed: 2019-12-16 20:34:37.682492800 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $FILE_NAME (48-3) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
ファイルtest01.txt
のハードリンクhardlink01
を削除
# del hardlink01
ここで、15秒以内にハードリンクをリネームします。
ファイルtest02.txt
のハードリンクhardlink02
をhardlink01
にリネーム
# ren hardlink02 hardlink01
ここで、test01.txtの作成時間がtest02.txtの作成時間に引き継がれているかを確認します。
ファイルtest02.txt
のタイムスタンプ
# istat \\.\C: 83955 MFT Entry Header Values: Entry: 83955 Sequence: 25 $LogFile Sequence Number: 153215457570 Allocated File Links: 2 $STANDARD_INFORMATION Attribute Values: Flags: Archive Owner ID: 0 Security ID: 6172 (S-1-5-32-544) Last User Journal Update Sequence Number: 5638721056 Created: 2019-12-16 20:34:34.889876600 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 21:03:48.231215600 ( Accessed: 2019-12-16 20:34:37.682492800 ( $FILE_NAME Attribute Values: Flags: Archive Name: test02.txt Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:34:37.682492800 ( Accessed: 2019-12-16 20:34:37.682492800 ( $FILE_NAME Attribute Values: Flags: Archive Name: hardlink01 Parent MFT Entry: 4504 Sequence: 54 Allocated Size: 0 Actual Size: 0 Created: 2019-12-16 20:34:37.682492800 ( File Modified: 2019-12-16 20:34:37.682492800 ( MFT Modified: 2019-12-16 20:38:00.744881700 ( Accessed: 2019-12-16 20:34:37.682492800 ( Attributes: Type: $STANDARD_INFORMATION (16-0) Name: N/A Resident size: 72 Type: $FILE_NAME (48-2) Name: N/A Resident size: 86 Type: $FILE_NAME (48-4) Name: N/A Resident size: 86 Type: $DATA (128-1) Name: N/A Resident size: 0
検証内容2の結果
$SIのみ作成時間が引き継がれた。
最後に
ファイルシステムのトンネリングの検証をしていて、作成時間が引き継がれないケースは初めてでした。
$LogFile
や$J
を見ても、作成時間が引き継がれた痕跡は確認できませんでした。
1つ目の検証のように作成時間が引き継がれない理由を確認出来る方がいたら、ぜひ共有していただきたいです。
注意
環境によって、結果が異なる可能性があります。