sumeshi/ntfsfind

GitHub: sumeshi/ntfsfind

直接从NTFS磁盘镜像中搜索文件和目录的高效取证工具,无需挂载镜像即可进行正则表达式匹配和备用数据流查找。

Stars: 28 | Forks: 2

# ntfsfind [![LGPLv3+ License](http://img.shields.io/badge/license-LGPLv3+-blue.svg?style=flat)](LICENSE) [![PyPI version](https://badge.fury.io/py/ntfsfind.svg)](https://badge.fury.io/py/ntfsfind) [![Python Versions](https://img.shields.io/pypi/pyversions/ntfsfind.svg)](https://pypi.org/project/ntfsfind/) ![ntfsfind logo](https://gist.githubusercontent.com/sumeshi/c2f430d352ae763273faadf9616a29e5/raw/baa85b045e0043914218cf9c0e1d1722e1e7524b/ntfsfind.svg) 一个直接从 NTFS 镜像文件中搜索文件、目录和备用数据流的高效工具。 ## 🚀 概述 `ntfsfind` 使数字取证调查人员和事件响应人员能够使用正则表达式无缝地从磁盘镜像中搜索记录,而无需挂载它们。通过利用强大的后端库,它支持读取标准磁盘镜像格式(RAW、E01、VHD(x)、VMDK)并可靠地解析 NTFS 结构。 ## 📦 功能 - **直接搜索**: 通过直接从 NTFS 分区搜索文件来避免挂载开销。 - **支持多种格式**: 支持读取 `.raw`、`.e01`、`.vhd`、`.vhdx` 和 `.vmdk` 文件。 - **正则表达式查询**: 使用正则表达式精确查找文件和目录(默认使用部分匹配,类似于 `grep`)。 - **备用数据流 (ADS)**: 支持查找隐藏的备用数据流。 - **可作为 CLI 或 Python 模块使用**: 高度灵活,可集成到其他自动化工具中。 ## ⚙️ 运行环境 - **Python**: 兼容 Python 3.13+。 - **预编译二进制文件**: 在 [GitHub releases](https://github.com/sumeshi/ntfsfind/releases) 部分提供 Windows 和 Linux 版本。 ## 📂 安装 ``` # 来自 PyPI pip install ntfsfind # 来自 GitHub Releases(预编译二进制文件) chmod +x ./ntfsfind ./ntfsfind --help # 在 Windows 上通过 bat 执行 > ntfsfind.exe --help ``` ## 🛠️ 需求和文件前置条件 镜像文件必须满足以下条件: - **格式**: `raw`、`e01`、`vhd`、`vhdx`、`vmdk`。 - **文件系统**: `NTFS`。 - **分区表**: `GPT`(MBR 通常会自动检测,但官方支持 GPT)。 ## 💻 使用方法 ### 命令行界面 您可以直接向 CLI 传递参数。路径使用正斜杠(`/`,Unix/Linux 风格)分隔,而不是反斜杠(`\`,Windows 风格)。 ``` ntfsfind [OPTIONS] [SEARCH_QUERY] ``` **选项**: - `--help`, `-h`: 显示帮助信息。 - `--version`, `-V`: 显示程序版本。 - `--volume`, `-n`: 指定目标 NTFS 卷号(默认:自动检测主操作系统卷)。 - `--format`, `-f`: 镜像文件格式(默认:`raw`)。选项:`raw`、`e01`、`vhd`、`vhdx`、`vmdk`。 - `--ignore-case`, `-i`: 启用不区分大小写的搜索。 - `--fixed-strings`, `-F`: 将搜索查询解释为字面固定字符串,而不是正则表达式。 - `--multiprocess`, `-m`: 启用多进程处理。 - `--out-mft`: 将解析的 `$MFT` 原始字节导出到指定文件路径。 #### 示例 查找 Eventlogs: ``` $ ntfsfind ./path/to/your/image.raw '.*\.evtx' /Windows/System32/winevt/Logs/Setup.evtx /Windows/System32/winevt/Logs/Microsoft-Windows-All-User-Install-Agent%4Admin.evtx /Logs/Windows PowerShell.evtx /Logs/Microsoft-Windows-Winlogon%4Operational.evtx /Logs/Microsoft-Windows-WinINet-Config%4ProxyConfigChanged.evtx ... ``` 查找原始 $MFT 文件及其路径中的文件: ``` $ ntfsfind ./path/to/your/image.raw '\$MFT' /$MFT /$MFTMirr ``` 查找备用数据流: ``` $ ntfsfind ./path/to/your/image.raw '.*:.*' ``` 导出 MFT 并直接从其中搜索(更快缓存): ``` # 1. 从镜像中导出 MFT(搜索查询可省略) $ ntfsfind --out-mft /tmp/my_mft.bin ./path/to/your/image.raw # 2. 之后您可以查询转储的 MFT 文件,而不是沉重的镜像! $ ntfsfind -F /tmp/my_mft.bin '.evtx' ``` #### 与 ntfsdump 配合使用 当与 [ntfsdump](https://github.com/sumeshi/ntfsdump) 结合使用时,可以直接从镜像文件通过标准输入(管道)转储检索到的文件。 `ntfsfind` 和 `ntfsdump` 如果具有相同的主版本和次版本则兼容(例如,如果两者都是 `3.0.x` 版本,则可以一起使用)。 ``` $ ntfsfind ./path/to/imagefile.raw '.*\.evtx' | ntfsdump ./path/to/your/imagefile.raw ``` ### Python 模块 您可以将 `ntfsfind` 逻辑集成到您自己的脚本中。 ``` from ntfsfind import ntfsfind # image: str # search_query: str # volume: Optional[int] = None # format: Literal['raw', 'e01', 'vhd', 'vhdx', 'vmdk'] = 'raw' # multiprocess: bool = False # ignore_case: bool = False # fixed_strings: bool = False # out_mft: Optional[str] = None # # -> List[str] records = ntfsfind( image='./path/to/your/imagefile.raw', search_query='.*\.evtx', volume=2, format='raw', multiprocess=False, ignore_case=True, fixed_strings=False, out_mft='/tmp/dumped_mft.bin' ) for record in records: print(record) ``` ## 📜 许可证 根据 [LGPLv3+](LICENSE) 许可证发布。 技术支持: - [pymft-rs](https://github.com/omerbenamram/pymft-rs) - [pytsk](https://github.com/py4n6/pytsk) - [libewf](https://github.com/libyal/libewf) - [libvhdi](https://github.com/libyal/libvhdi) - [libvmdk](https://github.com/libyal/libvmdk) - [Nuitka](https://github.com/Nuitka/Nuitka)
标签:ADS, DAST, E01, forensics, NTFS, Python, VHD, VHDX, VMDK, 取证工具, 可视化界面, 备用数据流, 开源取证, 恶意软件分析, 数字取证, 数据恢复, 文件搜索, 无后门, 无挂载搜索, 磁盘镜像, 网络安全审计, 自动化脚本, 逆向工具