dfirhub

USBDevicesLogs

Author: Eric Zimmerman, esecrpm

description

USB devices log files

paths

3 paths
USBDevicesSetupapi.log XP
C:\Windows\setupapi.log
USBDevicesSetupapi.log Win7+
C:\Windows\inf\setupapi.*.log
USBDevicesSetupapi.log Win7+
C:\Windows.old\Windows\inf\setupapi.*.log
paths use Windows environment syntax

collection commands

# PowerShell Artifact Collection Script
# Target: USBDevicesLogs
# Run as Administrator

#Requires -RunAsAdministrator

$ErrorActionPreference = "SilentlyContinue"
$DestBase = "D:\Evidence"

# Function to handle directory creation and copying
function Collect-Artifact {
    param (
        [string]$SourcePath,
        [string]$FolderName
    )
    $FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
    if (-not (Test-Path -Path $FullDest)) {
        New-Item -ItemType Directory -Path $FullDest -Force | Out-Null
    }
    Copy-Item -Path $SourcePath -Destination $FullDest -Recurse -Force
}

# 1. Setupapi.log XP
Collect-Artifact -SourcePath "C:\Windows\\setupapi.log" -FolderName "Setupapi_log_XP"

# 2. Setupapi.log Win7+
Collect-Artifact -SourcePath "C:\Windows\inf\\setupapi.*.log" -FolderName "Setupapi_log_Win7_"

# 3. Setupapi.log Win7+
Collect-Artifact -SourcePath "C:\Windows.old\Windows\inf\\setupapi.*.log" -FolderName "Setupapi_log_Win7_"

Write-Host "Collection complete!" -ForegroundColor Green

Save as .ps1 and run as Administrator. Use: powershell -ExecutionPolicy Bypass -File script.ps1

references

included in collections