コンテンツにスキップ

Impacket ntfs-read.py

カテゴリ目次へ戻る / コマンド全体目次へ戻る

NTFS ボリュームまたはイメージを読み取り専用で開き、ディレクトリの探索やファイルの抽出を行います。

項目内容
実装examples/ntfs-read.py
カテゴリ秘密情報 / DPAPI / レジストリ / ファイル解析
規模1455 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

オプションの最新の定義は python examples/ntfs-read.py -h で確認できます。

引数説明
volumeNTFS volume to open (e.g. \.\C: or /dev/disk1s1)
-extractextracts pathname (e.g. \windows\system32\config\sam)
-debugTurn DEBUG output ON
-tsAdds timestamp to every logging output

boot sector から cluster/MFT geometry を読み、MFT record の fixup と resident/non-resident attribute、data run、index root/allocation を解析します。-extract は指定 inode/stream を保存し、それ以外は MiniShell が ls、cd、cat、hexdump、get を dispatch します。

NTFS 解析は boot sector から始まります。sector/cluster size、MFT の開始 cluster、 MFT record size を読み、指定 volume/image の byte offset へ変換します。 NTFS.mountVolume() がこの geometry を確定し、MFT 自身の record から後続 inode を読むための data run を得ます。

各 MFT record は update sequence fixup を適用して sector 末尾の整合性を確認し、 resident/non-resident attribute を列挙します。resident data は record 内、 non-resident data は VCN→LCN の data run を辿って cluster から読みます。 directory は INDEX_ROOT と INDEX_ALLOCATION の B-tree entry を解析し、file 名と MFT reference を子 inode へ結びます。

attribute list がある file は複数 MFT record に extent が分散するため、 NonResidentDataAttribute が run を論理順に統合します。sparse、compressed、 encrypted flag は「読める data stream」と同義ではありません。MiniShell は この read-only model 上で path 解決、ls/cat/hexdump/get を行い、host filesystem への書き込みは抽出先だけに限定します。

disk image は未信頼入力です。fixup、attribute length、run length、index entry size、recursive directory reference を検証し、整数 overflow や無限 loop を 避けることが parser 変更時の最優先事項です。

シンボル位置責務を追う入口
NTFS_BPB131構造体/定数定義
NTFS_EXTENDED_BPB146構造体/定数定義
NTFS_BOOT_SECTOR160構造体/定数定義
NTFS_MFT_RECORD170構造体/定数定義
NTFS_ATTRIBUTE_RECORD188構造体/定数定義
NTFS_ATTRIBUTE_RECORD_NON_RESIDENT200構造体/定数定義
NTFS_ATTRIBUTE_RECORD_RESIDENT213構造体/定数定義
NTFS_FILE_NAME_ATTR221構造体/定数定義
NTFS_STANDARD_INFORMATION238構造体/定数定義
NTFS_INDEX_HEADER247構造体/定数定義
NTFS_INDEX_ROOT256構造体/定数定義
NTFS_INDEX_ALLOCATION267構造体/定数定義
NTFS_INDEX_ENTRY_HEADER277構造体/定数定義
NTFS_INDEX_ENTRY286構造体/定数定義
NTFS_DATA_RUN296構造体/定数定義
NTFS_ATTRIBUTE_LIST_ENTRY304構造体/定数定義
Attribute321__init__()、getFlags()、getName()、isNonResident()、dump()、getTotalSize()、getType()
AttributeResident347__init__()、dump()、getFlags()、getValue()、read()、getDataSize()
AttributeNonResident370__init__()、dump()、getDataSize()、getValue()、parseDataRuns()、readClusters()、readVCN()、read()
NonResidentDataAttribute544__init__()
AttributeStandardInfo648__init__()、getFileAttributes()、getFileTime()、dump()
AttributeFileName666__init__()、getFileNameType()、getFileAttributes()、getFileName()、getFileSize()、getFlags()、dump()
AttributeIndexAllocation690__init__()、dump()、read()
AttributeIndexRoot704__init__()、parseIndexEntries()、dump()、getType()
IndexEntry729__init__()、isSubNode()、isLastNode()、getVCN()、getSize()、getKey()、getINodeNumber()、dump()
AttributeListEntry754__init__()
AttributeList771__init__()、getEntries()
INODE804__init__()、isDirectory()、isCompressed()、isEncrypted()、isSparse()、displayName()、getPrintableAttributes()、parseAttributes()、searchAttribute()、PerformFixUp()、parseIndexBlocks()、walkSubNodes() ほか
NTFS1138__init__()、mountVolume()、readBootSector()、getINode()
MiniShell1226__init__()、emptyline()、onecmd()、do_exit()、do_shell()、do_help()、do_lcd()、do_cd()、findPathName()、do_pwd()、do_ls()、complete_cd() ほか
getUnixTime()315モジュール関数
main()1432モジュール関数
モジュール使用する主な名前
impacket.exampleslogger
impacketversion
impacket.structureStructure, hexdump
import 名配布パッケージ経路・宣言状態
sixsix直接 import、宣言済み
  • 主処理はローカルファイルの解析です。入力を信頼せず、offset、length、形式識別子を検証してからデータを参照してください。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • 入力ファイルがない場合、壊れている場合、読み取りが途中で終わる場合、未対応の形式だった場合を区別します。

impacket.structure と標準 file I/O に依存します。NTFS、INODE、各 Attribute* が parser、MiniShell が UI です。untrusted image の offset/length、sparse/compressed/encrypted 属性、attribute list extent の境界検証を保ってください。