PowerShellConsole
Logsv1.2
Author: Mike Cary, 2thewes, Vikas Singh
description
PowerShell Console Log File
paths
5 paths
› paths use Windows environment syntax
collection commands
# PowerShell Artifact Collection Script
# Target: PowerShellConsole
# Run as Administrator
#Requires -RunAsAdministrator
$ErrorActionPreference = "SilentlyContinue"
$DestBase = "D:\Evidence"
# Function to handle artifact collection with robocopy
function Collect-Artifact {
param (
[string]$SourceDir,
[string]$FolderName,
[string]$FileMask = "*"
)
$FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
robocopy "$SourceDir" "$FullDest" "$FileMask" /E /COPY:DAT /R:0 /W:0 /NP /NFL /NDL /NJH /NJS | Out-Null
}
# 1. PowerShell Console Log
$UserPath = Join-Path $env:USERPROFILE "AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\"
Collect-Artifact -SourceDir "$UserPath" -FileMask "*_history.txt" -FolderName "PowerShell_Console_Log"
# 2. PowerShell Console Log Systemprofile
Collect-Artifact -SourceDir "C:\Windows\System32\config\systemprofile\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\" -FileMask "*_history.txt" -FolderName "PowerShell_Console_Log_Systemprofile"
# 3. PowerShell Console Log WOW64 Systemprofile
Collect-Artifact -SourceDir "C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\" -FileMask "*_history.txt" -FolderName "PowerShell_Console_Log_WOW64_Systemprofile"
# 4. PowerShell ISE - AutoSave Files
$UserPath = Join-Path $env:USERPROFILE "AppData\Local\Microsoft_Corporation\powershell_ise.exe_StrongName*\*\AutoSaveFiles\"
Collect-Artifact -SourceDir "$UserPath" -FileMask "*.ps1" -FolderName "PowerShell_ISE___AutoSave_Files"
# 5. PowerShell ISE - User Config
$UserPath = Join-Path $env:USERPROFILE "AppData\Local\Microsoft_Corporation\powershell_ise.exe_StrongName*\*\"
Collect-Artifact -SourceDir "$UserPath" -FileMask "*.config" -FolderName "PowerShell_ISE___User_Config"
Write-Host "Collection complete!" -ForegroundColor Green› Save as .ps1 and run as Administrator. Use: powershell -ExecutionPolicy Bypass -File script.ps1
› cyberchef recipes
- open in cyberchef(opens in new tab)Base64 DecodeDecode Base64 encoded data
- open in cyberchef(opens in new tab)Unicode DecodeDecode Unicode escape sequences
Open in CyberChef to decode values extracted from this artifact.