1. 1. 一、USB 外设取证
    1. 1.1. 1.1 为什么 USB 取证重要
    2. 1.2. 1.2 USB 接入留下的痕迹全景
    3. 1.3. 1.3 注册表 USBSTOR(核心证据)
      1. 1.3.1. 位置
      2. 1.3.2. 包含的信息
      3. 1.3.3. 排查命令
      4. 1.3.4. 时间戳提取(关键!)
    4. 1.4. 1.4 注册表 USB(VID/PID 信息)
      1. 1.4.1. 位置
      2. 1.4.2. VID/PID 的含义
      3. 1.4.3. 排查命令
    5. 1.5. 1.5 MountedDevices(盘符映射)
      1. 1.5.1. 位置
      2. 1.5.2. 作用
      3. 1.5.3. 排查命令
    6. 1.6. 1.6 MountPoints2(用户级证据)
      1. 1.6.1. 位置
      2. 1.6.2. 关键价值
      3. 1.6.3. 排查命令
    7. 1.7. 1.7 SetupAPI 日志(首次接入精确时间)
      1. 1.7.1. 位置
      2. 1.7.2. 关键价值
      3. 1.7.3. 分析方法
      4. 1.7.4. 日志格式示例
    8. 1.8. 1.8 事件日志中的 USB 事件
      1. 1.8.1. 关键事件
      2. 1.8.2. 排查命令
    9. 1.9. 1.9 USBDeview 工具(一键查看所有 USB 历史)
      1. 1.9.1. 工具简介
      2. 1.9.2. 显示的信息
      3. 1.9.3. 使用方法
      4. 1.9.4. IR 中的典型用法
      5. 1.9.5. 命令行用法
    10. 1.10. 1.10 USB 取证综合排查脚本
  2. 2. 二、文件访问与操作历史追踪
    1. 2.1. 2.1 文件访问追踪的证据源全景
    2. 2.2. 2.2 Recent 文件夹(LNK 快捷方式)
      1. 2.2.1. 位置
      2. 2.2.2. 包含的信息
      3. 2.2.3. 排查命令
    3. 2.3. 2.3 OpenSaveMRU(打开/另存为对话框历史)
      1. 2.3.1. 位置
      2. 2.3.2. 关键价值
      3. 2.3.3. 排查命令
    4. 2.4. 2.4 RecentDocs(最近文档注册表)
      1. 2.4.1. 位置
      2. 2.4.2. 排查命令
    5. 2.5. 2.5 TypedPaths(资源管理器地址栏输入历史)
      1. 2.5.1. 位置
      2. 2.5.2. 关键价值
      3. 2.5.3. 排查命令
    6. 2.6. 2.6 LastVisitedMRU(应用程序最近文件关联)
      1. 2.6.1. 位置
      2. 2.6.2. 关键价值
      3. 2.6.3. 分析
    7. 2.7. 2.7 Office MRU(Office 最近文档)
      1. 2.7.1. 位置
      2. 2.7.2. 排查命令
    8. 2.8. 2.8 LastActivityView 工具(一键查看所有活动)
      1. 2.8.1. 工具简介
      2. 2.8.2. 数据源
      3. 2.8.3. 显示的活动类型
      4. 2.8.4. 使用方法
      5. 2.8.5. 命令行
    9. 2.9. 2.9 文件访问追踪综合排查脚本
  3. 3. 三、驱动级恶意软件排查(银狐/BYOVD)
    1. 3.1. 3.1 驱动级威胁概述
      1. 3.1.1. 什么是驱动级恶意软件
      2. 3.1.2. 为什么越来越多恶意软件使用驱动
    2. 3.2. 3.2 BYOVD 攻击原理(Bring Your Own Vulnerable Driver)
      1. 3.2.1. 原理
      2. 3.2.2. 常被滥用的合法驱动
      3. 3.2.3. 关键理解
    3. 3.3. 3.3 银狐木马(Silver Fox)详解
      1. 3.3.1. 概述
      2. 3.3.2. 银狐的驱动利用链
      3. 3.3.3. 银狐常用的驱动
      4. 3.3.4. 银狐特征
    4. 3.4. 3.4 驱动级恶意软件排查要点(重点)
      1. 3.4.1. 排查思路
      2. 3.4.2. 排查点 1:检查已加载的驱动列表
      3. 3.4.3. 排查点 2:检查驱动签名
      4. 3.4.4. 排查点 3:对比已知漏洞驱动列表(LOLDRIVERS)
      5. 3.4.5. 排查点 4:检查驱动加载事件日志
      6. 3.4.6. 排查点 5:检查安全软件是否被异常终止
      7. 3.4.7. 排查点 6:检查 ETW (Event Tracing for Windows) 篡改
    5. 3.5. 3.5 白加黑(DLL 侧加载)排查
      1. 3.5.1. 原理
      2. 3.5.2. 银狐等常用的”白”程序
      3. 3.5.3. 排查方法
    6. 3.6. 3.6 驱动级恶意软件清除
      1. 3.6.1. 清除步骤
      2. 3.6.2. 预防措施
    7. 3.7. 3.7 驱动级威胁排查综合脚本
  4. 4. 四、实战练习
    1. 4.1. 练习 1:USB 取证
    2. 4.2. 练习 2:文件访问追踪
    3. 4.3. 练习 3:驱动排查

Windows应急响应 - 37 USB外设取证与文件访问追踪

USB 外设取证与文件访问追踪

在数据泄露调查和入侵溯源中,”谁插过什么 USB 设备”和”谁打开/写入过什么文件”是两个核心问题。本页深入讲解 Windows 下 USB 设备取证和文件访问历史追踪的原理与实操

关联:04-取证制品分析 | 07-文件系统取证 | 06-文件系统取证

一、USB 外设取证

1.1 为什么 USB 取证重要

数据泄露调查:员工是否用 U 盘拷走了敏感数据

恶意软件入口:BadUSB、Rubber Ducky 等 HID 攻击设备

攻击者痕迹:入侵者是否使用了 USB 设备(如离线密码破解工具)

合规审计:某些行业要求记录所有外设接入

1.2 USB 接入留下的痕迹全景

Windows 在多个位置记录 USB 设备信息,形成完整的证据链

1
2
3
4
5
6
7
8
9
10
11
USB 设备接入

├──▶ 注册表 USBSTOR (设备标识、序列号、首次/末次接入时间)
├──▶ 注册表 USB (VID/PID)
├──▶ 注册表 MountedDevices (盘符分配)
├──▶ 注册表 MountPoints2 (用户级,哪个用户使用了该设备)
├──▶ SetupAPI 日志 (驱动安装时间 = 首次接入时间)
├──▶ 事件日志 (接入/断开事件)
├──▶ Shellbags (用户浏览了设备中的哪些文件夹)
├──▶ LNK 文件 (用户打开了设备中的哪些文件)
└──▶ Jump Lists (通过哪个程序打开了设备上的文件)

1.3 注册表 USBSTOR(核心证据)

位置

HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR

每个子键代表一种 USB 存储设备型号

格式:Disk&Ven_厂商&Prod_产品&Rev_版本\序列号

包含的信息

字段 含义 IR 价值
子键名 厂商、产品名、版本 识别设备型号
序列号 设备唯一标识 关联其他证据源
FriendlyName 设备友好名称 如 “Kingston DataTraveler 3.0”
ContainerID 设备容器 ID 关联同一物理设备的多个接口

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 列出所有曾连接的 USB 存储设备
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*" |
Select-Object PSChildName, FriendlyName, ContainerID |
Format-Table -AutoSize

# 更详细的输出
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR" -Recurse |
ForEach-Object {
$props = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue
if ($props.FriendlyName) {
[PSCustomObject]@{
DeviceID = $_.PSChildName
FriendlyName = $props.FriendlyName
Driver = $props.Driver
ContainerID = $props.ContainerID
}
}
} | Format-Table -AutoSize

时间戳提取(关键!)

USBSTOR 注册表键的 最后写入时间 = 设备最后接入时间

需要用专门工具提取(PowerShell 无法直接获取注册表键的 LastWriteTime)

1
2
3
4
# 使用 RECmd (Eric Zimmerman) 提取 USBSTOR 时间戳
# RECmd.exe --hive C:\Windows\System32\config\SYSTEM --kn "ControlSet001\Enum\USBSTOR" --csv C:\output

# 或使用 Registry Explorer GUI 查看 Last Write Time

1.4 注册表 USB(VID/PID 信息)

位置

HKLM\SYSTEM\CurrentControlSet\Enum\USB

格式:VID_xxxx&PID_xxxx\序列号

VID/PID 的含义

VID (Vendor ID) — 厂商 ID,如 0951 = Kingston

PID (Product ID) — 产品 ID

可在 devicehunt.comthe-sz.com/products/usbid 查询对应设备

排查命令

1
2
3
4
5
6
7
8
9
10
# 列出所有 USB 设备(含 HID 键盘鼠标等)
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Enum\USB" |
Select-Object PSChildName | Sort-Object PSChildName

# 查找可疑 HID 设备(BadUSB / Rubber Ducky 检测)
# BadUSB 通常伪装为 HID 键盘,VID/PID 可能不在已知数据库中
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Enum\USB\VID_*\*" |
Where-Object { $_.Service -eq "HidUsb" -or $_.Service -eq "kbdhid" } |
Select-Object PSChildName, DeviceDesc, Mfg |
Format-Table -AutoSize

1.5 MountedDevices(盘符映射)

位置

HKLM\SYSTEM\MountedDevices

作用

记录设备被分配的盘符(如 \DosDevices\E:

值数据包含设备标识,可与 USBSTOR 序列号关联

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
# 查看所有挂载过的设备和盘符
Get-ItemProperty "HKLM:\SYSTEM\MountedDevices" |
Select-Object -Property * -ExcludeProperty PS* |
ForEach-Object {
$_.PSObject.Properties | Where-Object { $_.Name -like "\DosDevices\*" } |
ForEach-Object {
[PSCustomObject]@{
DriveLetter = $_.Name
DeviceData = [System.Text.Encoding]::Unicode.GetString($_.Value) -replace '\x00',''
}
}
}

1.6 MountPoints2(用户级证据)

位置

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2

或离线分析:NTUSER.DAT 中对应路径

关键价值

这是用户级记录,说明哪个用户使用了该设备

USBSTOR 只能证明设备接入了系统,MountPoints2 能证明特定用户访问了该设备

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
# 当前用户的挂载点历史
Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2" |
Select-Object PSChildName

# 遍历所有用户(需要加载每个用户的 NTUSER.DAT)
foreach ($userDir in Get-ChildItem C:\Users -Directory) {
$ntuser = "$($userDir.FullName)\NTUSER.DAT"
if (Test-Path $ntuser) {
Write-Host "=== $($userDir.Name) ===" -ForegroundColor Cyan
# 需要离线挂载或使用 RECmd 分析
}
}

1.7 SetupAPI 日志(首次接入精确时间)

位置

C:\Windows\INF\setupapi.dev.log(Windows 7+)

旧版:C:\Windows\setupapi.log

关键价值

记录设备驱动安装的精确时间 = 设备首次接入系统的时间

这是唯一能确定”首次接入时间”的可靠来源

分析方法

1
2
3
4
5
6
7
8
9
# 搜索 USB 存储设备的安装记录
Select-String -Path "C:\Windows\INF\setupapi.dev.log" -Pattern "USBSTOR" -Context 5

# 提取设备安装时间
Select-String -Path "C:\Windows\INF\setupapi.dev.log" -Pattern "Device Install.*USBSTOR" |
ForEach-Object {
$_.Line
# 上下文中的 "Section start" 行包含精确时间戳
}

日志格式示例

1
2
3
4
5
>>>  [Device Install (Hardware initiated) - USBSTOR\Disk&Ven_Kingston&Prod_DataTraveler_3.0&Rev_\60A44C4139C5B0A0E96E0DA6-0:0]
>>> Section start 2024/03/15 14:32:05.123
dvi: {Build Driver List} 14:32:05.234
dvi: {DIF_SELECTBESTCOMPATDRV} 14:32:05.456
>>> Section end 2024/03/15 14:32:06.789

1.8 事件日志中的 USB 事件

关键事件

日志 Event ID 含义
System 20001 即插即用驱动安装
System 20003 驱动服务添加
Microsoft-Windows-DriverFrameworks-UserMode/Operational 2003 USB 设备加载驱动
Microsoft-Windows-DriverFrameworks-UserMode/Operational 2100 USB 设备连接
Microsoft-Windows-DriverFrameworks-UserMode/Operational 2102 USB 设备断开
Microsoft-Windows-Storage-Storport/Operational 507 磁盘连接
Security 4663 对象访问(如果审计策略启用)
Security 6416 新外部设备被系统识别(Win10+)

排查命令

1
2
3
4
5
6
7
8
9
10
# 查看 USB 存储设备连接事件
Get-WinEvent -LogName "Microsoft-Windows-DriverFrameworks-UserMode/Operational" -MaxEvents 100 |
Where-Object { $_.Id -in @(2003, 2100, 2102) } |
Select-Object TimeCreated, Id, Message |
Format-Table -AutoSize -Wrap

# 新设备识别事件 (Windows 10+, 需审计策略)
Get-WinEvent -FilterHashtable @{LogName='Security';ID=6416} -MaxEvents 50 -ErrorAction SilentlyContinue |
Select-Object TimeCreated, @{N='Device';E={$_.Properties[1].Value}} |
Format-Table -AutoSize

1.9 USBDeview 工具(一键查看所有 USB 历史)

工具简介

NirSoft 出品的免费工具

一个界面展示所有曾连接的 USB 设备

无需安装,绿色便携

显示的信息

设备名称、描述、序列号

VID/PID

首次接入时间、最后接入时间、最后断开时间

盘符

设备类型(存储/HID/打印机等)

驱动程序

使用方法

1
2
3
4
5
1. 下载 USBDeview(nirsoft.net/utils/usb_devices_view.html)
2. 以管理员权限运行 USBDeview.exe
3. 默认显示当前系统的所有 USB 历史
4. 支持分析离线系统:Options → Advanced Options → Load from remote/external
5. 导出:View → HTML Report 或 Ctrl+S 保存为 CSV

IR 中的典型用法

1
2
3
4
- 排序按 "Last Plug/Unplug Date" → 找最近接入的设备
- 过滤 "Device Type = Mass Storage" → 只看存储设备
- 检查 "Created Date" → 首次接入时间
- 右键 → Open Device Info in DevManView → 查看详细驱动信息

命令行用法

1
2
3
4
5
6
7
8
:: 导出所有 USB 设备为 CSV
USBDeview.exe /scomma "C:\IR\usb_history.csv"

:: 只导出 Mass Storage 设备
USBDeview.exe /DisplayMassStorage 1 /scomma "C:\IR\usb_storage.csv"

:: 分析远程计算机
USBDeview.exe /remote \\RemotePC /scomma "C:\IR\remote_usb.csv"

1.10 USB 取证综合排查脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# USB 外设取证综合脚本
Write-Host "=== USB 外设取证 ===" -ForegroundColor Cyan

Write-Host "`n[1] USBSTOR 注册表记录:" -ForegroundColor Yellow
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR" -ErrorAction SilentlyContinue |
ForEach-Object {
$device = $_.PSChildName
Get-ChildItem $_.PSPath | ForEach-Object {
$props = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue
Write-Host " 设备: $device" -ForegroundColor White
Write-Host " 序列号: $($_.PSChildName)" -ForegroundColor White
Write-Host " 友好名称: $($props.FriendlyName)" -ForegroundColor White
Write-Host ""
}
}

Write-Host "[2] MountPoints2 (用户级):" -ForegroundColor Yellow
Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2" -ErrorAction SilentlyContinue |
ForEach-Object { Write-Host " $($_.PSChildName)" }

Write-Host "`n[3] SetupAPI 首次接入时间:" -ForegroundColor Yellow
if (Test-Path "C:\Windows\INF\setupapi.dev.log") {
Select-String "USBSTOR" "C:\Windows\INF\setupapi.dev.log" -Context 1 |
Select-Object -First 10 | ForEach-Object {
Write-Host " $($_.Line.Trim())" -ForegroundColor Gray
}
}

Write-Host "`n[4] 最近 USB 事件日志:" -ForegroundColor Yellow
Get-WinEvent -FilterHashtable @{LogName='Security';ID=6416} -MaxEvents 5 -ErrorAction SilentlyContinue |
ForEach-Object { Write-Host " $($_.TimeCreated): $($_.Message.Substring(0,80))..." }

二、文件访问与操作历史追踪

2.1 文件访问追踪的证据源全景

1
2
3
4
5
6
7
8
9
10
11
12
13
14
用户操作文件

├──▶ Recent 文件夹 (LNK) — 最近打开的文件快捷方式
├──▶ Jump Lists — 各应用最近打开的文件列表
├──▶ Shellbags — 浏览过的文件夹记录
├──▶ OpenSaveMRU (注册表) — 打开/另存为对话框历史
├──▶ RecentDocs (注册表) — 按文件类型分类的最近文档
├──▶ TypedPaths (注册表) — 资源管理器地址栏输入历史
├──▶ LastVisitedMRU (注册表) — 最后使用某程序打开文件的记录
├──▶ UserAssist (注册表) — GUI 执行的程序记录
├──▶ Prefetch — 程序执行证据(含加载的文件)
├──▶ USN Journal — NTFS 文件变更日志
├──▶ $MFT — 文件创建/修改/访问时间
└──▶ Office MRU (注册表) — Office 最近打开的文档

2.2 Recent 文件夹(LNK 快捷方式)

位置

C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Recent\

每个 .lnk 文件指向一个最近打开过的文件

包含的信息

目标文件完整路径(即使文件已删除,LNK 仍保留路径)

目标文件大小、创建/修改/访问时间

卷序列号和卷标(识别来源磁盘,包括 USB)

MAC 地址(如果是网络路径,可能包含 NIC MAC)

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 列出 Recent 中的所有快捷方式,按修改时间排序
Get-ChildItem "$env:APPDATA\Microsoft\Windows\Recent\*.lnk" |
Sort-Object LastWriteTime -Descending |
Select-Object Name, LastWriteTime |
Format-Table -AutoSize

# 解析 LNK 目标路径(使用 COM 对象)
$shell = New-Object -ComObject WScript.Shell
Get-ChildItem "$env:APPDATA\Microsoft\Windows\Recent\*.lnk" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 20 |
ForEach-Object {
$lnk = $shell.CreateShortcut($_.FullName)
[PSCustomObject]@{
Name = $_.Name
Target = $lnk.TargetPath
Arguments = $lnk.Arguments
AccessTime = $_.LastWriteTime
}
} | Format-Table -AutoSize -Wrap

# 使用 LECmd (Eric Zimmerman) 做深度解析
# LECmd.exe -d "C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Recent" --csv C:\output

2.3 OpenSaveMRU(打开/另存为对话框历史)

位置

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU

按文件扩展名分子键:*(所有文件)、docxlsxpdfexe

关键价值

记录用户通过 打开/另存为 对话框访问的文件

包含完整文件路径

按文件类型分类,方便筛查特定类型

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 查看所有 OpenSave 记录
Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU" |
ForEach-Object {
$ext = $_.PSChildName
$items = Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue
Write-Host "=== 扩展名: $ext ===" -ForegroundColor Cyan
$items.PSObject.Properties | Where-Object { $_.Name -match "^\d+$" } |
ForEach-Object {
# 值是二进制 PIDL 格式,需要工具解析
Write-Host " 条目 $($_.Name): [PIDL binary data]" -ForegroundColor Gray
}
}

# 推荐使用 Registry Explorer 或 RECmd 解析 PIDL 为可读路径
# RECmd.exe --hive NTUSER.DAT --kn "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU" --csv C:\output

2.4 RecentDocs(最近文档注册表)

位置

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs

子键按扩展名分类:.docx.pdf.xlsx.txt

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 列出所有有记录的文件类型
Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" |
Select-Object PSChildName

# 查看特定类型的最近文档(值需要解码)
$regPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.docx"
$props = Get-ItemProperty $regPath -ErrorAction SilentlyContinue
if ($props) {
$props.PSObject.Properties | Where-Object { $_.Name -match "^\d+$" } |
ForEach-Object {
# 值包含文件名的 Unicode 编码
$bytes = $_.Value
$name = [System.Text.Encoding]::Unicode.GetString($bytes) -split '\x00' | Select-Object -First 1
Write-Host " $name"
}
}

2.5 TypedPaths(资源管理器地址栏输入历史)

位置

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths

关键价值

记录用户在 Windows 资源管理器地址栏手动输入的路径

包括 UNC 网络路径(\\server\share)和本地路径

非常有价值:用户主动输入的路径通常有明确意图

排查命令

1
2
3
4
# 查看所有输入的路径
Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths" -ErrorAction SilentlyContinue |
Select-Object -Property url* |
Format-List

2.6 LastVisitedMRU(应用程序最近文件关联)

位置

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRU

关键价值

记录哪个程序最后打开了哪个目录的文件

例如:notepad.exe 最后打开 C:\secret\passwords.txt 所在的目录

分析

值为 PIDL 格式,需要 RECmd 或 Registry Explorer 解析

2.7 Office MRU(Office 最近文档)

位置

HKCU\SOFTWARE\Microsoft\Office\<版本>\<应用>\File MRU

例如:HKCU\SOFTWARE\Microsoft\Office\16.0\Word\File MRU

排查命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 查看 Word 最近文件
Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Office\16.0\Word\File MRU" -ErrorAction SilentlyContinue |
Select-Object -Property Item* | Format-List

# 查看 Excel 最近文件
Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Office\16.0\Excel\File MRU" -ErrorAction SilentlyContinue |
Select-Object -Property Item* | Format-List

# 遍历所有 Office 应用
foreach ($app in @("Word","Excel","PowerPoint","Access")) {
$mru = Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Office\16.0\$app\File MRU" -ErrorAction SilentlyContinue
if ($mru) {
Write-Host "=== $app ===" -ForegroundColor Cyan
$mru.PSObject.Properties | Where-Object { $_.Name -like "Item*" } |
ForEach-Object { Write-Host " $($_.Value)" }
}
}

2.8 LastActivityView 工具(一键查看所有活动)

工具简介

NirSoft 出品的免费工具(nirsoft.net/utils/last_activity_view.html)

聚合多个数据源,展示系统上的所有活动时间线

无需安装,绿色便携

数据源

注册表(USBSTOR、MRU、UserAssist、BAM 等)

Prefetch 文件

Event Log(安装/卸载/登录/关机等)

Minidump 崩溃记录

Setup API 日志

显示的活动类型

类型 说明
Run .EXE 程序执行(来自 Prefetch)
Installed Application 软件安装
System Started / Shutdown 系统启动/关机
User Logon / Logoff 用户登录/注销
Software Installation (MsiInstaller) MSI 安装
Software Uninstall 软件卸载
Network Connected / Disconnected 网络连接
Restore Point Created 还原点
Windows Update 系统更新

使用方法

1
2
3
4
5
1. 下载 LastActivityView
2. 直接运行 LastActivityView.exe
3. 默认显示本机所有活动,按时间排序
4. Options → Advanced Options → 可分析远程/离线系统
5. View → HTML Report 导出完整报告

命令行

1
2
3
4
5
:: 导出所有活动到 CSV
LastActivityView.exe /scomma "C:\IR\activity.csv"

:: 分析远程计算机
LastActivityView.exe /remote \\RemotePC /scomma "C:\IR\remote_activity.csv"

2.9 文件访问追踪综合排查脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 文件访问历史综合排查
Write-Host "=== 文件访问历史追踪 ===" -ForegroundColor Cyan

# 1. Recent LNK
Write-Host "`n[1] 最近打开的文件 (Recent LNK):" -ForegroundColor Yellow
$shell = New-Object -ComObject WScript.Shell
Get-ChildItem "$env:APPDATA\Microsoft\Windows\Recent\*.lnk" -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime -Descending | Select-Object -First 15 |
ForEach-Object {
$lnk = $shell.CreateShortcut($_.FullName)
Write-Host " $($_.LastWriteTime.ToString('yyyy-MM-dd HH:mm')) | $($lnk.TargetPath)" -ForegroundColor Gray
}

# 2. TypedPaths
Write-Host "`n[2] 资源管理器输入的路径:" -ForegroundColor Yellow
$tp = Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths" -ErrorAction SilentlyContinue
if ($tp) {
$tp.PSObject.Properties | Where-Object { $_.Name -like "url*" } |
ForEach-Object { Write-Host " $($_.Value)" -ForegroundColor Gray }
}

# 3. Office MRU
Write-Host "`n[3] Office 最近文件:" -ForegroundColor Yellow
foreach ($app in @("Word","Excel","PowerPoint")) {
$mru = Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Office\16.0\$app\File MRU" -ErrorAction SilentlyContinue
if ($mru) {
$mru.PSObject.Properties | Where-Object { $_.Name -like "Item 1" } |
ForEach-Object { Write-Host " [$app] $($_.Value)" -ForegroundColor Gray }
}
}

# 4. RecentDocs 按类型
Write-Host "`n[4] RecentDocs 文件类型:" -ForegroundColor Yellow
Get-ChildItem "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs" -ErrorAction SilentlyContinue |
ForEach-Object {
$count = ($_ | Get-ItemProperty).PSObject.Properties | Where-Object { $_.Name -match "^\d+$" } | Measure-Object
Write-Host " $($_.PSChildName): $($count.Count) 条记录" -ForegroundColor Gray
}

三、驱动级恶意软件排查(银狐/BYOVD)

3.1 驱动级威胁概述

什么是驱动级恶意软件

恶意软件加载内核驱动(.sys 文件)运行在 Ring 0(最高权限)

一旦进入内核态,可以:

绕过所有安全软件(杀毒软件运行在 Ring 3,无法检测 Ring 0)

隐藏进程、文件、注册表、网络连接(内核级 Rootkit)

拦截/修改系统调用(SSDT Hook、Filter Driver)

窃取凭据(直接读取 LSASS 内存)

禁用安全机制(关闭 Windows Defender、ETW 日志)

为什么越来越多恶意软件使用驱动

Windows 的 Kernel-Mode Code Signing (KMCS) 策略要求驱动必须有数字签名

但攻击者找到了多种绕过方式:

  1. BYOVD — 利用已签名的合法但有漏洞的驱动
  2. 盗取/购买代码签名证书 — 银狐等团伙实际购买 EV 证书签名
  3. 利用泄露的签名驱动 — 使用泄露的测试签名
  4. DSE (Driver Signature Enforcement) 绕过 — 利用漏洞禁用签名检查

3.2 BYOVD 攻击原理(Bring Your Own Vulnerable Driver)

原理

1
2
3
4
5
6
攻击流程:
1. 攻击者携带一个【已签名、合法、但有漏洞】的驱动 (.sys)
2. 安装该驱动到系统(因为有合法签名,Windows 允许加载)
3. 利用驱动中的漏洞获取内核态任意读写能力
4. 通过内核态能力杀掉安全软件进程
5. 执行后续恶意操作(部署勒索、窃取数据等)

常被滥用的合法驱动

驱动 厂商 漏洞 CVE 被哪些恶意软件使用
RTCore64.sys MSI Afterburner 任意内存读写 CVE-2019-16098 BlackByte, AvosLocker
dbutil_2_3.sys Dell 任意内存读写 CVE-2021-21551 银狐变体, Cuba
gdrv.sys GIGABYTE 任意内存读写 CVE-2018-19320 RobbinHood
aswArPot.sys Avast Kill 进程 CVE-2022-26522 AvosLocker, Cuba
viragt64.sys Trend Micro Kill 进程 银狐
Rentdrv2.sys Kill 进程 银狐
KProcessHacker.sys Process Hacker 任意内核操作 多种勒索
procexp152.sys Sysinternals Kill 进程 AuKill
zamguard64.sys Zemana Kill 进程/修改 Terminator

关键理解

这些驱动本身是合法签名的(微软/厂商签名)

它们有合法的功能(硬件管理、安全防护等)

但其中的漏洞被恶意软件利用来获取内核权限

即使你信任签名,也必须检查驱动是否在已知漏洞列表中

3.3 银狐木马(Silver Fox)详解

概述

银狐(Silver Fox / 银狐远控)是国内非常活跃的商业化远控木马

主要通过钓鱼邮件、即时通讯(微信/QQ 群)传播

伪装为常见软件安装包(报税软件、发票工具、办公软件等)

具备驱动级对抗能力,是国内最常见的驱动级威胁之一

银狐的驱动利用链

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
银狐感染流程:
1. 用户下载伪装的安装包 (.exe)
2. 安装包释放多个文件:
├── 合法签名程序 (白加黑的"白")
├── 恶意 DLL (白加黑的"黑",被白程序加载)
├── 漏洞驱动 .sys (BYOVD)
└── 加密的 Shellcode/Payload
3. 白程序启动 → 加载恶意 DLL (DLL 侧加载)
4. 恶意 DLL 安装漏洞驱动 (利用合法签名绕过 KMCS)
5. 通过驱动漏洞获取内核权限
6. 利用内核权限:
├── 终止杀毒软件进程
├── 禁用 Windows Defender
├── 阻止 ETW 日志记录
└── 注入 Shellcode 到合法进程
7. 建立远控连接 (C2 通信)

银狐常用的驱动

Rentdrv2.sys — 杀进程驱动

viragt64.sys — 趋势科技的合法驱动被滥用

dbutil_2_3.sys — Dell 驱动被滥用

各种国内厂商的已签名驱动

银狐特征

进程名伪装:svchost.exeRuntimeBroker.exe 等系统进程名

文件位置:C:\Users\Public\C:\ProgramData\%AppData%

持久化:注册表 Run 键 + 计划任务 + 服务

C2 通信:使用国内云服务器、CDN、或合法网站做跳板

DLL 侧加载:利用合法签名程序加载恶意 DLL

3.4 驱动级恶意软件排查要点(重点)

排查思路

1
2
3
4
5
6
7
排查流程:
1. 检查已加载的驱动 → 是否有已知漏洞驱动
2. 检查驱动签名 → 是否有异常/过期/测试签名
3. 检查驱动加载事件 → 什么时候加载的、从哪里加载的
4. 检查安全软件状态 → 是否被异常终止
5. 检查 ETW/日志 → 是否有日志被篡改的迹象
6. 内存分析 → 检测内核级 Hook

排查点 1:检查已加载的驱动列表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 方法1:PowerShell 列出所有驱动
Get-WmiObject Win32_SystemDriver |
Select-Object Name, DisplayName, PathName, State, StartMode |
Sort-Object State |
Format-Table -AutoSize

# 方法2:driverquery 命令
driverquery /v /fo csv | ConvertFrom-Csv |
Select-Object "Module Name", "Display Name", "Driver Type", "Start Mode", "State", "Path" |
Format-Table -AutoSize

# 方法3:sc query 列出内核驱动
sc query type= driver state= all

# 方法4:使用 Autoruns 的 Drivers 标签页(推荐)
# autorunsc.exe -a d -c -h -s -v | ConvertFrom-Csv

排查点 2:检查驱动签名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 验证所有已加载驱动的签名
Get-WmiObject Win32_SystemDriver | Where-Object { $_.State -eq "Running" } |
ForEach-Object {
$path = $_.PathName -replace '\\SystemRoot\\','C:\Windows\'
$path = $path -replace '\\??\\',''
if (Test-Path $path) {
$sig = Get-AuthenticodeSignature $path -ErrorAction SilentlyContinue
if ($sig.Status -ne "Valid") {
[PSCustomObject]@{
Driver = $_.Name
Path = $path
SigStatus = $sig.Status
Signer = $sig.SignerCertificate.Subject
}
}
}
} | Format-Table -AutoSize

# 使用 sigcheck (Sysinternals) 扫描所有驱动
# sigcheck64.exe -e -u -vt C:\Windows\System32\drivers\
# -e: 扫描可执行文件(含 .sys)
# -u: 只显示未签名或 VirusTotal 检测到的
# -vt: 提交到 VirusTotal 检查

排查点 3:对比已知漏洞驱动列表(LOLDRIVERS)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# loldrivers.io 维护了已知被恶意软件滥用的驱动列表
# 包含驱动的 SHA256 哈希

# 步骤:
# 1. 计算所有 .sys 文件的哈希
Get-ChildItem C:\Windows\System32\drivers\*.sys |
ForEach-Object {
[PSCustomObject]@{
File = $_.Name
SHA256 = (Get-FileHash $_.FullName -Algorithm SHA256).Hash
Size = $_.Length
LastWrite = $_.LastWriteTime
}
} | Export-Csv "C:\IR\driver_hashes.csv" -NoTypeInformation

# 2. 与 loldrivers.io 的哈希列表对比
# 下载: https://www.loldrivers.io/api/drivers.csv

# 3. 或使用微软的 Vulnerable Driver Blocklist
# 查看当前系统的驱动阻止列表状态
Get-CimInstance -Namespace root\Microsoft\Windows\CI -ClassName MSFT_DriverBlockList -ErrorAction SilentlyContinue

排查点 4:检查驱动加载事件日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Sysmon Event ID 6 = 驱动加载(如果 Sysmon 已部署)
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Sysmon/Operational';ID=6} -MaxEvents 50 -ErrorAction SilentlyContinue |
ForEach-Object {
[PSCustomObject]@{
Time = $_.TimeCreated
ImagePath = $_.Properties[1].Value
Hashes = $_.Properties[2].Value
Signed = $_.Properties[3].Value
Signature = $_.Properties[4].Value
}
} | Format-Table -AutoSize -Wrap

# System 事件日志中的驱动加载
Get-WinEvent -FilterHashtable @{LogName='System';ID=7045} -MaxEvents 50 -ErrorAction SilentlyContinue |
Where-Object { $_.Properties[4].Value -eq "kernel mode" } |
Select-Object TimeCreated, @{N='ServiceName';E={$_.Properties[0].Value}}, @{N='ImagePath';E={$_.Properties[1].Value}} |
Format-Table -AutoSize

排查点 5:检查安全软件是否被异常终止

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 检查 Windows Defender 状态
Get-MpComputerStatus | Select-Object AMRunningMode, AntispywareEnabled, AntivirusEnabled, RealTimeProtectionEnabled, IoavProtectionEnabled

# 检查 Defender 是否有排除项被添加(攻击者常添加排除来绕过)
Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
Get-MpPreference | Select-Object -ExpandProperty ExclusionProcess
Get-MpPreference | Select-Object -ExpandProperty ExclusionExtension

# 检查安全相关服务状态
$securityServices = @("WinDefend","SecurityHealthService","wscsvc","WdNisSvc","mpssvc","Sense")
foreach ($svc in $securityServices) {
$s = Get-Service -Name $svc -ErrorAction SilentlyContinue
$color = if ($s.Status -eq "Running") { "Green" } else { "Red" }
Write-Host " $svc : $($s.Status)" -ForegroundColor $color
}

# 检查 Tamper Protection 状态
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows Defender\Features" -Name TamperProtection -ErrorAction SilentlyContinue

排查点 6:检查 ETW (Event Tracing for Windows) 篡改

1
2
3
4
5
6
# 高级攻击会 patch ETW 来阻止日志记录
# 检查 ETW 提供者状态
logman query providers | Select-String "Microsoft-Windows-Threat"

# 检查 NtTraceEvent 是否被 Hook(需要内存分析工具)
# 这是高级排查,通常需要 Volatility 内存分析

3.5 白加黑(DLL 侧加载)排查

原理

“白加黑”是国内安全圈的术语(国际上叫 DLL Side-Loading)

“白” = 有合法数字签名的正常程序

“黑” = 恶意 DLL,被白程序加载

因为主程序签名合法,杀毒软件可能放过

银狐等常用的”白”程序

国产软件安装程序、更新程序

合法的运维工具、远程桌面软件

签名的编辑器、阅读器组件

排查方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 1. 检查进程加载的 DLL 中是否有未签名的
Get-Process | ForEach-Object {
$proc = $_
try {
$modules = $proc.Modules
foreach ($mod in $modules) {
$sig = Get-AuthenticodeSignature $mod.FileName -ErrorAction SilentlyContinue
if ($sig.Status -ne "Valid" -and $mod.FileName -notmatch "\\Windows\\") {
[PSCustomObject]@{
PID = $proc.Id
Process = $proc.ProcessName
DLL = $mod.FileName
SigStatus = $sig.Status
}
}
}
} catch {}
} | Format-Table -AutoSize

# 2. 使用 Process Explorer
# View → Show Lower Pane → DLLs
# Options → Verify Image Signatures
# 紫色高亮 = packed/encrypted image
# 标记 "Not Verified" 的 DLL 重点关注

# 3. 使用 listdlls (Sysinternals)
# listdlls.exe -u # 只显示未签名的 DLL

3.6 驱动级恶意软件清除

清除步骤

1
2
3
4
5
6
7
8
9
1. 隔离(断网)
2. 进入安全模式(驱动可能阻止在正常模式下清除)
3. 删除恶意驱动文件 (.sys)
4. 清除驱动对应的服务注册表
HKLM\SYSTEM\CurrentControlSet\Services\<driver_name>
5. 清除其他持久化(Run 键、计划任务、服务等)
6. 恢复被篡改的安全软件配置
7. 清除 Defender 排除项
8. 重启验证

预防措施

启用 Windows Defender Credential Guard — 保护 LSASS

启用 Microsoft Vulnerable Driver Blocklist — 阻止已知漏洞驱动

1
2
3
# 检查是否启用
Get-CimInstance -Namespace root\Microsoft\Windows\CI -ClassName MSFT_DriverBlockList -ErrorAction SilentlyContinue
# Windows 11 22H2+ 默认启用

启用 HVCI (Hypervisor-Protected Code Integrity) — 阻止未签名内核代码

使用 ASR 规则 — 阻止可疑的驱动安装

监控 Sysmon Event ID 6 — 驱动加载告警

3.7 驱动级威胁排查综合脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 驱动级威胁综合排查
Write-Host "=== 驱动级威胁排查 ===" -ForegroundColor Cyan

# 1. 最近安装的驱动
Write-Host "`n[1] 最近 7 天加载的驱动:" -ForegroundColor Yellow
Get-ChildItem C:\Windows\System32\drivers\*.sys |
Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) } |
ForEach-Object {
$sig = Get-AuthenticodeSignature $_.FullName -ErrorAction SilentlyContinue
[PSCustomObject]@{
Name = $_.Name
Size = "{0:N0} KB" -f ($_.Length/1KB)
Date = $_.LastWriteTime.ToString("yyyy-MM-dd HH:mm")
Signed = $sig.Status
Signer = if($sig.SignerCertificate){$sig.SignerCertificate.Subject.Split(',')[0]}else{"N/A"}
}
} | Format-Table -AutoSize

# 2. 未签名/签名异常的驱动
Write-Host "[2] 签名异常的运行中驱动:" -ForegroundColor Yellow
Get-WmiObject Win32_SystemDriver | Where-Object { $_.State -eq "Running" } |
ForEach-Object {
$path = ($_.PathName -replace '\\SystemRoot\\','C:\Windows\' -replace '\\??\\','')
if (Test-Path $path) {
$sig = Get-AuthenticodeSignature $path -ErrorAction SilentlyContinue
if ($sig.Status -ne "Valid") {
Write-Host " [!] $($_.Name) : $path (Sig: $($sig.Status))" -ForegroundColor Red
}
}
}

# 3. 安全软件状态
Write-Host "`n[3] 安全软件状态:" -ForegroundColor Yellow
try {
$mp = Get-MpComputerStatus -ErrorAction SilentlyContinue
Write-Host " Defender RealTime: $($mp.RealTimeProtectionEnabled)" -ForegroundColor $(if($mp.RealTimeProtectionEnabled){"Green"}else{"Red"})
Write-Host " Defender Antivirus: $($mp.AntivirusEnabled)" -ForegroundColor $(if($mp.AntivirusEnabled){"Green"}else{"Red"})
} catch { Write-Host " 无法获取 Defender 状态" -ForegroundColor Red }

# 4. Defender 排除项(被攻击者添加?)
Write-Host "`n[4] Defender 排除项:" -ForegroundColor Yellow
$excl = Get-MpPreference -ErrorAction SilentlyContinue
if ($excl.ExclusionPath) { $excl.ExclusionPath | ForEach-Object { Write-Host " 路径排除: $_" -ForegroundColor Red } }
if ($excl.ExclusionProcess) { $excl.ExclusionProcess | ForEach-Object { Write-Host " 进程排除: $_" -ForegroundColor Red } }
if ($excl.ExclusionExtension) { $excl.ExclusionExtension | ForEach-Object { Write-Host " 扩展名排除: $_" -ForegroundColor Red } }
if (-not $excl.ExclusionPath -and -not $excl.ExclusionProcess) { Write-Host " 无排除项" -ForegroundColor Green }

# 5. Sysmon 驱动加载事件
Write-Host "`n[5] Sysmon 驱动加载事件 (最近 20 条):" -ForegroundColor Yellow
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Sysmon/Operational';ID=6} -MaxEvents 20 -ErrorAction SilentlyContinue |
ForEach-Object {
$signed = $_.Properties[3].Value
$color = if ($signed -eq "true") { "Gray" } else { "Red" }
Write-Host " $($_.TimeCreated.ToString('yyyy-MM-dd HH:mm')) | Signed=$signed | $($_.Properties[1].Value)" -ForegroundColor $color
}

Write-Host "`n=== 排查完成 ===" -ForegroundColor Cyan
Write-Host "建议: 将 driver_hashes.csv 与 loldrivers.io 数据库对比" -ForegroundColor Yellow

四、实战练习

练习 1:USB 取证

在实验 VM 中插入 U 盘,然后拔掉

使用本页方法找出:设备型号、序列号、首次接入时间、使用者

练习 2:文件访问追踪

用 Word 打开一个文档,用 Excel 打开一个表格

使用 LastActivityView 和注册表分析找出这些操作

练习 3:驱动排查

在 VM 中运行 persistence-checker.ps1 + 本页的驱动排查脚本

了解你的系统中有哪些第三方驱动

对比 loldrivers.io 看是否有已知漏洞驱动


上一章 目录 下一章
36-自动化IR工具-KAPE与Velociraptor Windows应急响应 38-冷门持久化与内核级威胁补充