关于 analyzing-windows-prefetch-with-python
面向安全调查的 Windows Prefetch 文件分析技能,使用 windowsprefetch Python 库重建执行时间线,并标记可疑或改名程序。
主要功能
- 01解析 Prefetch 执行记录
- 02提取运行次数与时间戳
- 03标记可疑或改名二进制文件
- 04重建执行时间线
- 05生成 JSON 报告
适用场景
- 01调查终端安全事件
- 02排查可疑程序执行
- 03构建威胁检测规则
- 04检查安全监控覆盖情况
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill analyzing-windows-prefetch-with-python安装后在 Claude Code 中输入/analyzing-windows-prefetch-with-python确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEreferences/api-reference.mdscripts/agent.py详细介绍
使用 Python 分析 Windows Prefetch
概述
Windows Prefetch 文件(.pf)记录应用程序执行数据,包括可执行文件名、运行次数、时间戳、加载的 DLL 以及访问的目录。本技能涵盖使用 windowsprefetch Python 库解析 Prefetch 文件,以重建执行时间线,通过比较可执行文件名与加载的资源来检测被重命名或伪装的二进制文件,并识别可能表明恶意软件执行或横向移动的可疑程序。
何时使用
- 当调查需要「使用 Python 分析 Windows Prefetch」的安全事件时
- 当为该领域构建检测规则或威胁狩猎查询时
- 当 SOC 分析师需要针对此类分析的标准操作流程时
- 当验证相关攻击技术的安全监控覆盖范围时
前提条件
- Python 3.9+ 及
windowsprefetch库(pip install windowsprefetch) - 来自 C:\Windows\Prefetch\ 的 Windows Prefetch 文件(支持版本 17-30)
- 了解 Windows Prefetch 文件命名规范(EXECUTABLE-HASH.pf)
步骤
步骤 1:收集 Prefetch 文件
从目标系统的 C:\Windows\Prefetch\ 目录收集 .pf 文件。
步骤 2:解析执行历史
提取可执行文件名、运行次数、最近执行时间戳和卷信息。
步骤 3:检测可疑执行
标记已知攻击工具(mimikatz、psexec 等)、被重命名的二进制文件以及异常执行模式。
步骤 4:构建执行时间线
根据所有 Prefetch 文件重建按时间顺序排列的执行时间线。
预期输出
包含执行历史、可疑可执行文件、被重命名二进制文件指示以及时间线重建的 JSON 报告。
示例输出
$ python3 prefetch_analyzer.py --dir /evidence/Windows/Prefetch --output /analysis/prefetch_report
Windows Prefetch Analyzer v2.1
================================
Source: /evidence/Windows/Prefetch/
Prefetch Format: Windows 10 (MAM compressed, version 30)
Files Found: 234
--- Execution Timeline (Incident Window: 2024-01-15 to 2024-01-18) ---
Last Executed (UTC) | Run Count | Filename | Hash | Path
------------------------|-----------|-----------------------------|----------|------------------------------------------
2024-01-15 14:33:15 | 1 | Q4_REPORT.XLSM-2A1B3C4D.pf | 2A1B3C4D | C:\Users\jsmith\Downloads\Q4_Report.xlsm
2024-01-15 14:35:44 | 1 | POWERSHELL.EXE-A2B3C4D5.pf | A2B3C4D5 | C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
2024-01-15 14:36:30 | 3 | UPDATE_CLIENT.EXE-B3C4D5E6.pf| B3C4D5E6| C:\ProgramData\Updates\update_client.exe
2024-01-15 15:10:22 | 1 | NETSCAN.EXE-C4D5E6F7.pf | C4D5E6F7 | C:\Users\jsmith\Downloads\netscan.exe
2024-01-16 02:28:00 | 1 | PROCDUMP64.EXE-D5E6F7A8.pf | D5E6F7A8 | C:\Windows\Temp\procdump64.exe
2024-01-16 02:30:15 | 2 | MIMIKATZ.EXE-E6F7A8B9.pf | E6F7A8B9 | C:\Windows\Temp\mimikatz.exe
2024-01-16 02:40:00 | 4 | PSEXEC.EXE-F7A8B9C0.pf | F7A8B9C0 | C:\Users\jsmith\AppData\Local\Temp\psexec.exe
2024-01-17 02:45:00 | 1 | SDELETE64.EXE-A8B9C0D1.pf | A8B9C0D1 | C:\Windows\Temp\sdelete64.exe
2024-01-18 03:00:45 | 1 | WEVTUTIL.EXE-B9C0D1E2.pf | B9C0D1E2 | C:\Windows\System32\wevtutil.exe
--- Renamed Binary Detection ---
ALERT: UPDATE_CLIENT.EXE loaded DLLs consistent with Cobalt Strike beacon:
Referenced DLLs: wininet.dll, ws2_32.dll, advapi32.dll, dnsapi.dll, netapi32.dll
Volume: \VOLUME{01d94f2a3b5c7d8e-A4E73F21} (C:)
Directories referenced:
C:\ProgramData\Updates\
C:\Windows\System32\
--- Execution Frequency Analysis ---
Most Executed (Top 5):
1. SVCHOST.EXE (267 runs)
2. CHROME.EXE (189 runs)
3. EXPLORER.EXE (156 runs)
4. RUNTIMEBROKER.EXE (134 runs)
5. OUTLOOK.EXE (98 runs)
First-Time Executions (Never seen before incident window):
6 executables first run between 2024-01-15 and 2024-01-18
Summary:
Total prefetch files: 234
Suspicious executables: 6
Renamed binary indicators: 1 (update_client.exe)
Anti-forensics tools: 2 (sdelete64.exe, wevtutil.exe)
JSON report: /analysis/prefetch_report/prefetch_timeline.json
评论
支持 Markdown