Skip to content

Commit

Permalink
Update get-log4jrcevulnerability.ps1
Browse files Browse the repository at this point in the history
if there are some special characters in filepaths, select-string failed. With adding quotes around the pathname, this is solved.
  • Loading branch information
Robby-Swartenbroekx authored Dec 21, 2021
1 parent aedb534 commit 616834d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#
Name: get-log4jrcevulnerability.ps1
Version: 0.2.1 (21st December 2021)
Version: 0.2.2 (21st December 2021)
Author: Prejay Shah (Doherty Associates)
Thanks: Christopher Bledsoe (IPM Computers) for some bugfixes,
Robby Swartenbroekx (b-Inside) for some ideas,
Expand Down Expand Up @@ -37,9 +37,10 @@ Have excluded files within windows\system32\spool\drivers from being scanned due
0.1.9 Expanded Search Criteria to all fixed drives on a device, and added update for Log4j 2.17 Compatibility (Thx to Robby S)
0.2 Separated detection of Log4j 2.16 PAtched and 2.17 Patched States
0.2.1 Adding better output for when Everything fails to scan via RMM PS wrapping
0.2.2 Added quotes to the path of select-string. Was an issue with some characters in a path. (Robby S)
#>

$Version = "0.2.1" # 21st December 2021
$Version = "0.2.2" # 21st December 2021
Write-Host "`nget-log4jrcevulnerability $version" -foregroundcolor Green
$robocopycsv = $null
$log4jvulnerablefiles = $null
Expand Down Expand Up @@ -122,7 +123,7 @@ else {
if (($_.FilePath -ne $null) -and ($_.FilePath -ne "")) {
if (($_.FilePath -notmatch "placeholder.jar") -and ($_.FilePath -notmatch "spool\\drivers")) {
#write-host "CHECKING : " $_.FilePath -ForegroundColor Yellow
select-string "JndiLookup.class" $_.FilePath
select-string "JndiLookup.class" "$($_.FilePath)"
}
}
} | select-object -exp Path | sort-object -unique
Expand All @@ -132,7 +133,7 @@ else {
if (($_ -ne $null) -and ($_ -ne "")) {
if ($_ -notmatch "placeholder.jar") {
#write-host "CHECKING : " $_ -ForegroundColor Yellow
select-string "JndiLookup.class" $_
select-string "JndiLookup.class" "$_"
}
}
} | select-object -exp Path | sort-object -unique
Expand Down Expand Up @@ -222,4 +223,4 @@ if ($robocopycsv -eq $true) {
}
else {
$log4jfiles = $log4jfilenames -join '<br>'
}
}

0 comments on commit 616834d

Please sign in to comment.