orpsec/Win-Harvester
GitHub: orpsec/Win-Harvester
模块化的 Windows 取证痕迹只读收集器,面向事件响应和数字取证场景,支持 VSS 读取锁定文件并自动生成哈希、时间线和多格式报告。
Stars: 0 | Forks: 0
# WinHarvest
全面、模块化的 **Windows 取证痕迹收集器** (Go)。专为在 Windows 10 和 Windows 11 上进行事件响应 (IR)、数字取证 (DFIR)、恶意软件分析和威胁狩猎而设计的**只读**证据收集工具。
## 核心原则
- **只读:** 不修改任何源文件;副本保留 timestamp。
- **锁定文件:** 通过 Volume Shadow Copy (VSS) 读取 (SAM, SYSTEM, `$MFT`, EVTX...)。
- **完整性:** 为收集的每个文件生成 **SHA256 + SHA1 + MD5** 以及完整的 metadata。
- **可审计性:** 记录每一个操作(包括失败的收集)并将其写入 manifest。
- **可扩展:** 模块通过 goroutine 并行运行。
## 架构
```
cmd/winharvest → CLI giriş noktası, orkestrasyon
internal/core → tipler, Collector interface, plugin registry, config,
OutputWriter (kopya+hash+metadata), timeline sink
internal/platform → OS tespiti, ACL/timestamp, komut çalıştırma, VSS
(//go:build windows + cross-platform stub)
internal/rawio → ham NTFS okuyucu ($MFT, $LogFile çıkarımı)
internal/collect → modüller için ortak yardımcılar (kopyalama, glob, exec)
internal/modules → her artefact kategorisi bir collector modülü
internal/report → JSON/CSV/HTML/Markdown + ZIP
internal/timeline → birleşik süper zaman çizelgesi
internal/hashing → tek geçişte üçlü hash
internal/logging → seviyeli, dosya+konsol logger
```
### 添加新模块(插件模式)
只需在 `internal/modules/` 目录下添加一个实现了 `core.Collector` 接口的文件,
并在 `init()` 中调用 `core.Register(...)` 即可。无需修改 `main.go`。
```
type myModule struct{}
func (myModule) Name() string { return "mymodule" }
func (myModule) Category() string { return "System" }
func (myModule) Description() string { return "..." }
func (m myModule) Collect(ctx context.Context, cc *core.Context) (*core.ModuleResult, error) {
h := collect.New(cc, m.Name(), m.Category())
h.CopyFile(`C:\path\to\artifact`)
return h.Result(), nil
}
func init() { core.Register(myModule{}) }
```
## 收集的痕迹类别
| 模块 | 类别 | 内容 |
|---|---|---|
| `system` | System | 主机身份、硬件、OS、BitLocker、TPM、VM 检测、SID |
| `eventlogs` | EventLogs | 原始 EVTX(包括 Operational/Analytic/Debug) |
| `registry` | Registry | SYSTEM/SOFTWARE/SAM/SECURITY/DEFAULT + NTUSER/UsrClass + RegBack + 事务日志 + 键 export |
| `filesystem` | FileSystem | `$MFT`, `$LogFile` (原始 NTFS), `$UsnJrnl`, Recycle Bin, ADS, reparse, VSS metadata |
| `execution` | FileSystem | Prefetch, Amcache, SRUM, JumpList, LNK, Recent, WER |
| `tasks` | Tasks | 计划任务 XML, TaskCache, 列表 |
| `services` | Services | 服务、驱动程序、ImagePath, ServiceDLL, FailureActions |
| `wmi` | WMI | Repository + 持久化 event subscription (filter/consumer/binding) |
| `powershell` | System | PSReadLine history, transcript |
| `browser` | Browser | Chrome/Edge/Brave/Opera/Vivaldi/Firefox:history, cookies, logins, extensions, storage |
| `network` | Network | 连接、ARP/DNS cache, route, firewall, Wi-Fi (clear key), VPN, hosts, proxy |
| `usb` | USB | USBSTOR, MountedDevices, SetupAPI 日志, portable devices |
| `users` | Users | Recent, clipboard, Sticky Notes, OneDrive/GDrive/Dropbox metadata |
| `memory` | Memory | 进程/线程/DLL/handle/驱动程序/登录会话/连接 metadata(无需 RAM dump) |
| `persistence` | System | Run keys, IFEO, AppInit, COM hijack, Winlogon, BITS, startup, Office add-in |
| `logs` | System | CBS/DISM/Panther/Defender/WindowsUpdate 日志, crash dump metadata |
## 可读 / 已解析的输出(供分析使用)
除了原始(二进制)痕迹外,还会生成可直接分析的**已解析**输出(在每个模块下的 `parsed/` 文件夹中)。这样您无需任何额外工具即可查看输出(例如,直接交给分析师/AI 分析)。
| 来源 | 解析输出 | 方法 |
|---|---|---|
| EVTX(重要通道) | `EventLogs/eventlogs/parsed/.json` | `Get-WinEvent` → JSON (TimeCreated, Id, Provider, Message) |
| Prefetch (`.pf`) | `FileSystem/execution/parsed/prefetch.json` | **Native Go** SCCA v30/v31 + MAM (Xpress Huffman) 解压 |
| LNK (`.lnk`) | `FileSystem/execution/parsed/lnk.json` | **Native Go** Shell Link parser(目标路径、参数、volume) |
| Amcache.hve | `FileSystem/execution/parsed/amcache.json` | **Native Go** regf + InventoryApplicationFile |
| ShimCache (AppCompatCache) | `Registry/registry/parsed/shimcache.json` | **Native Go** regf + Win10/11 `10ts` parser |
| UserAssist | `Registry/registry/parsed/userassist_.json` | **Native Go** regf + ROT13 + run count/last run |
| USBSTOR | `Registry/registry/parsed/usbstor.json` | **Native Go** regf |
| `$MFT` | `FileSystem/filesystem/parsed/mft.csv` | **Native Go** NTFS MFT parser ($SI/$FN MAC times) |
| Registry 键 | `Registry/registry/exported/*.txt` | `reg query /s` |
| 浏览器(history 等) | 原始 SQLite 文件 | 可直接作为 SQLite 进行查询 |
所有这些解析输出中的事件(Prefetch/LNK/UserAssist/ShimCache/USB)
另外会被添加到合并的 **`Reports/timeline.csv`** 超级时间线中。
## 编译
```
# Windows 目标(开发机器可以是 macOS/Linux — cross-compile)
GOOS=windows GOARCH=amd64 go build -o winharvest.exe ./cmd/winharvest
GOOS=windows GOARCH=arm64 go build -o winharvest-arm64.exe ./cmd/winharvest
# 在本地 Windows 上
go build -o winharvest.exe ./cmd/winharvest
go test ./...
```
## 使用
```
# 所有模块,默认设置
.\winharvest.exe -output D:\Evidence -case IR-2026-0001 -examiner analyst
# 仅特定模块
.\winharvest.exe -modules registry,eventlogs,execution
# 排除某些模块,无 ZIP,更多并行
.\winharvest.exe -exclude browser,memory -no-zip -concurrency 8
# 使用 Config 文件
.\winharvest.exe -config config.yaml
# 列出可用模块
.\winharvest.exe -list
```
### 重要标志
| 标志 | 描述 | 默认值 |
|---|---|---|
| `-output` | 输出目录 | `.` |
| `-config` | YAML config 路径 | — |
| `-modules` | 要运行的模块(CSV) | 全部 |
| `-exclude` | 要排除的模块(CSV) | — |
| `-concurrency` | 并行模块数 | 4 |
| `-vss` | 使用 VSS | true |
| `-no-hash` | 禁用 hash | false |
| `-no-acl` | 禁用 ACL 收集 | false |
| `-no-zip` | 禁用 ZIP 压缩 | false |
| `-max-file-size` | 大小上限(字节) | 0(无限制) |
| `-volume` | 目标 volume | `C:\` |
| `-verbose` | Debug log | false |
## 输出结构
```
Collection__/
├── System/ EventLogs/ Registry/ FileSystem/
├── Users/ Browser/ Network/ Memory/
├── USB/ Services/ WMI/ Tasks/
├── Reports/
│ ├── manifest.json # tam, kendini tanımlayan kayıt
│ ├── artifacts.csv # her dosya: yol, boyut, MAC, owner, 3 hash, durum
│ ├── timeline.csv # birleşik süper zaman çizelgesi
│ ├── report.html # özet + zaman çizelgesi (interaktif)
│ └── report.md
└── collection.log # ayrıntılı çalışma logu
Collection__.zip
```
为每个文件保存的 metadata:原始路径、大小、创建/修改/访问时间、owner、ACL (SDDL)、SHA256/SHA1/MD5、收集时间、来源(`live`/`vss`/`rawio`)、成功状态及错误消息。
## 注意事项 / 限制
- 不会获取完整的 RAM 镜像(仅限 volatile metadata)。如有需要,请使用专门的镜像获取工具;`memory` 模块提供 process/handle/driver/会话转储。
- 当 `MEMORY.DMP` 过大时,仅记录 metadata(不进行复制)。
- EVTX/Registry hive 以**原始**格式收集;建议使用 Eric Zimmerman 工具、Velociraptor 或 Plaso 进行后期解析。
- 该工具**不会**修改证据;但在实时系统上运行的命令(`netstat`、`ipconfig` 等)属于系统正常的读取操作。
标签:Artifact收集, EVTX分析, Go, Ruby工具, 库, 应急响应, 提权工具, 数字取证, 日志审计, 自动化脚本