BrowserCache

Author: Bjorn Vanhaeren, Reece394

description

Browser Caches

paths

15 paths
paths use Windows environment syntax

collection commands

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

#Requires -RunAsAdministrator

$ErrorActionPreference = "Continue"
$SourceRoot = "C:"
$DestBase   = "D:\Evidence"
$Summary = @{ Copied = 0; Missed = 0; Errors = 0 }

function Collect-Artifact {
    param(
        [Parameter(Mandatory)][string]$SourceDir,
        [Parameter(Mandatory)][string]$FolderName,
        [string]$FileMask = "*"
    )
    # Expand wildcards in any path segment (e.g. 'Program Files*',
    # 'ScreenConnect Client*'). robocopy itself does not glob the source.
    $sources = @(Get-Item -Path $SourceDir -ErrorAction SilentlyContinue |
        Where-Object { $_.PSIsContainer })
    if ($sources.Count -eq 0) {
        $Summary.Missed++
        return
    }
    $FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
    $null = New-Item -ItemType Directory -Force -Path $FullDest -ErrorAction SilentlyContinue
    foreach ($src in $sources) {
        robocopy $src.FullName "$FullDest" "$FileMask" /E /COPY:DAT /R:0 /W:0 /NP /NFL /NDL /NJH /NJS 2>$null | Out-Null
        if ($LASTEXITCODE -le 7) { $Summary.Copied++ } else { $Summary.Errors++ }
    }
}

# 1. Brave Cache Folder
Collect-Artifact -SourceDir "C:\Users\%users%\AppData\Local\BraveSoftware\Brave-Browser\User Data\Default\Cache\Cache_Data" -FolderName "Brave_Cache_Folder"

# Iterate every user profile under the source drive
Get-ChildItem "$SourceRoot\Users" -Directory -ErrorAction SilentlyContinue |
    Where-Object { $_.Name -notin @('All Users', 'Default', 'Default User', 'Public') } |
    ForEach-Object {
        $UserName = $_.Name
        # Chrome Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_Cache_Folder_$UserName"
        # Chrome Beta Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome Beta\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_Beta_Cache_Folder_$UserName"
        # Chrome Dev Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome Dev\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_Dev_Cache_Folder_$UserName"
        # Chrome SxS - Canary Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Google\Chrome SxS\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chrome_SxS_Canary_Cache_Folder_$UserName"
        # Chromium Edge Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Edge\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chromium_Edge_Cache_Folder_$UserName"
        # Chromium Edge Beta Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Edge Beta\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chromium_Edge_Beta_Cache_Folder_$UserName"
        # Chromium Edge Dev Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Edge Dev\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chromium_Edge_Dev_Cache_Folder_$UserName"
        # Chromium Edge SxS - Canary Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Edge SxS\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chromium_Edge_SxS_Canary_Cache_Folder_$UserName"
        # Chromium Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Chromium\User Data\*\Cache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Chromium_Cache_Folder_$UserName"
        # Firefox Cache Folder
        $UserPath = "$($_.FullName)\AppData\Local\Mozilla\Firefox\Profiles\*"
        Collect-Artifact -SourceDir $UserPath -FolderName "Firefox_Cache_Folder_$UserName"
        # IE 9/10 Cache
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Windows\Temporary Internet Files"
        Collect-Artifact -SourceDir $UserPath -FolderName "IE_9_10_Cache_$UserName"
        # IE Index.dat temp internet files
        $UserPath = "$($_.FullName)\Local Settings\Temporary Internet Files\Content.IE5"
        Collect-Artifact -SourceDir $UserPath -FileMask "index.dat" -FolderName "IE_Index_dat_temp_internet_files_$UserName"
        # IE 11 Cache
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Windows\INetCache"
        Collect-Artifact -SourceDir $UserPath -FolderName "IE_11_Cache_$UserName"
        # Edge WebcacheV01.dat
        $UserPath = "$($_.FullName)\AppData\Local\Microsoft\Windows\WebCache"
        Collect-Artifact -SourceDir $UserPath -FolderName "Edge_WebcacheV01_dat_$UserName"
    }

Write-Host ("Collection complete. Copied: {0}  Missed: {1}  Errors: {2}" -f $Summary.Copied, $Summary.Missed, $Summary.Errors) -ForegroundColor Green

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