Skip to content

Commit

Permalink
Update DeepBlueHash-checker.ps1
Browse files Browse the repository at this point in the history
Updated for Virustotal API key v3
  • Loading branch information
eric-conrad authored Jun 28, 2023
1 parent cd3e304 commit 3c8fa15
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions DeepBlueHash-checker.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Requires Posh-VirusTotal: https://github.com/darkoperator/Posh-VirusTotal
# Requires VirusTotalAnalyzer: https://github.com/darkoperator/Posh-VirusTotal
#
# Plus a (free) VirusTotal API Key: https://www.virustotal.com/en/documentation/public-api/
#
Import-Module VirusTotalAnalyzer -Force

# API KEY can be found once you register to Virus Total service (it's free)
$VTApi = '<Your API Key>'

$hashdirectory = ".\hashes"
$safelistfile=".\file-safelist.csv"
$safelistfile=".\safelists\win10-x64.csv"
# Load the safelist into a hash table
if (Test-Path $safelistfile){
$safelist = Get-Content $safelistfile | Select-String '^[^#]' | ConvertFrom-Csv
Expand All @@ -21,32 +26,30 @@ Get-ChildItem $hashdirectory | Foreach-Object{
}
Else{
try{
$VTreport = Get-VTFileReport $SHA256
$VTreport = Get-VirusReport -ApiKey $VTApi -Hash "$SHA256"
}
catch {
Write-Host "`r`nAttempted to run: Get-VTFileReport $SHA256`r`r"
Write-Host "`r`nAttempted to run: Get-Virusreport $SHA256`r`r"
Write-Host "Error: " $_.Exception.Message "`n"
Write-Host "Have you installed Posh-VirusTotal and set the VirusTotal API key?"
Write-Host "Have you installed VirusTotalAnalyzer and set the VirusTotal API key?"
Write-Host " - See: https://github.com/darkoperator/Posh-VirusTotal`r`n"
Write-Host "Once you have installed Posh-VirusTotal and have a VirusTotal API key, run the following command:`r`n"
Write-Host "Set-VTAPIKey -APIKey <API Key>`r`n"
Write-Host "Exiting...`n"
exit
}
if ($VTreport.positives -eq 0){
$positives=$VTreport.Data.attributes.last_analysis_stats.malicious
if ($positives -eq 0){
# File is clean
Rename-Item -Path "$hashdirectory\$SHA256" -NewName "$SHA256.clean"
}
ElseIf ($VTreport.positives -gt 0){
ElseIf ($positives -gt 0){
# File is flagged by Virustotal
$positives=$VTreport.positives
Write-Host " - Hash was detected by $positives Virustotal scanners"
if ($positives -eq 1){
Write-Host " - Don't Panic (yet)! There is only one positive, which may be a sign of a false positive."
Write-Host " - Check the VirusTotal report for more information."
}
Write-Host " - See $hashdirectory\$SHA256.Virustotal for the full report`r`n"
$VTreport | Set-Content "$hashdirectory\$SHA256.Virustotal"
$VTreport.Data.attributes | Set-Content "$hashdirectory\$SHA256.Virustotal"
# Rename original hash file, add the Virustotal positive count as a numbered extension
# $SHA256.$positives
Rename-Item -Path "$hashdirectory\$SHA256" -NewName "$SHA256.$positives"
Expand Down

0 comments on commit 3c8fa15

Please sign in to comment.