Skip to content

Instantly share code, notes, and snippets.

@Patrick-Kelley
Created June 30, 2023 16:31
Show Gist options
  • Save Patrick-Kelley/f583b1cc597356dcff3673881252d744 to your computer and use it in GitHub Desktop.
Save Patrick-Kelley/f583b1cc597356dcff3673881252d744 to your computer and use it in GitHub Desktop.
Potential candidate for quickly locating encrypted files using the CPS wordlist.
$drive = "C:\"
$days = 7 # Number of days to consider as "recent"
# Download the wordlist file
$wordlistUrl = "https://raw.githubusercontent.com/CriticalPathSecurity/Zeek-Intelligence-File-Names/main/Zeek-Intelligence-File-Names.txt"
$wordlistPath = "$env:TEMP\Zeek-Intelligence-File-Names.txt"
Invoke-WebRequest -Uri $wordlistUrl -OutFile $wordlistPath
# Read the wordlist file into an array
$wordlist = Get-Content -Path $wordlistPath
$recentFiles = Get-ChildItem -Path $drive -Recurse | Where-Object {
$_.LastWriteTime -gt (Get-Date).AddDays(-$days)
}
$ransomwareMatches = $recentFiles | Where-Object {
$filename = $_.Name.ToLower()
$wordlist | ForEach-Object {
if ($filename -like "*$_*") {
$true
break
}
}
}
if ($ransomwareMatches.Count -gt 0) {
Write-Host "Potentially ransomware files found:"
$ransomwareMatches | Select-Object FullName, LastWriteTime
}
else {
Write-Host "No potentially ransomware files found."
}
# Remove the downloaded wordlist file
Remove-Item -Path $wordlistPath -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment