@@ -396,6 +396,7 @@ if($EverythingSearch) {
396
396
Write-Log - Text " Robocopy search failed. Falling back to Get-ChildItem." - Type WARN
397
397
$filesDetected = Get-ChildItem - path " $drive \" - Recurse - Force - ErrorAction 0 | Where-Object {$_.Extension -in " .jar" , " .log" , " .txt" } | Select-Object - ExpandProperty FullName
398
398
Write-Log - Text " Get-ChildItem found $ ( $filesDetected.Count ) files to scan on '$drive \'"
399
+ $arrFiles += $filesDetected
399
400
}
400
401
}
401
402
}
@@ -415,7 +416,6 @@ $MD5_BAD = @{
415
416
" f1d630c48928096a484e4b95ccb162a0" = " log4j 2.14.0 - 2.14.1"
416
417
" 5d253e53fa993e122ff012221aa49ec3" = " log4j 2.15.0"
417
418
" ba1cf8f81e7b31c709768561ba8ab558" = " log4j 2.16.0"
418
- ' 1B6E6DD47D8084ABDE61CAA28C96B7A3' = " log4j test-reallynotbad"
419
419
}
420
420
421
421
# Known GOOD
@@ -424,6 +424,7 @@ $MD5_GOOD = @{
424
424
" 3c3a43af0930a658716b870e66db1569" = " log4j 2.17.1"
425
425
}
426
426
427
+ [System.Reflection.Assembly ]::LoadWithPartialName(' System.IO.Compression.FileSystem' ) | Out-Null
427
428
Write-Log - Text " Scanning for JAR files containing potentially insecure Log4j code."
428
429
$arrFiles | Where-Object {$_ -match ' \.jar$' } | ForEach-Object {
429
430
Write-Verbose - Message " Running insecure code scan on file '$_ '"
@@ -434,8 +435,8 @@ $arrFiles | Where-Object {$_ -match '\.jar$'} | ForEach-Object {
434
435
remove-item - Path $env: TEMP \extract - Recurse - Force - ErrorAction SilentlyContinue
435
436
New-Item - ItemType Directory - Path $env: TEMP \extract | Out-Null
436
437
}
437
- [ System.Reflection.Assembly ]::LoadWithPartialName( ' System.IO.Compression.FileSystem ' ) | Out-Null
438
- [System.IO.Compression.ZipFile ]::ExtractToDirectory($_ , " $env: TEMP \extract" ) | Out-Null
438
+ Remove-Item $ env: TEMP \extract - Recurse - Force
439
+ [System.IO.Compression.ZipFile ]::ExtractToDirectory($_ , " $env: TEMP \extract" ) 2> $null | Out-Null
439
440
$Files = Get-ChildItem $env: TEMP \extract - Recurse | Where-Object - Property Name -match ' JNDIManager.class'
440
441
If ($Files ) {
441
442
foreach ($file in $files ) {
@@ -444,24 +445,20 @@ $arrFiles | Where-Object {$_ -match '\.jar$'} | ForEach-Object {
444
445
if ($checksum -in $MD5_BAD.keys ) {
445
446
Write-Log - Text " MD5 found in bad list referencing $ ( $MD5_BAD .$checksum ) " - Type WARN
446
447
# if it's bad, check for jndilookup.class, it will be two directories up under the lookup directory.
447
- $path = Get-Childitem ($File.PSParentPath ).replace(" \$ ( $file.directory.name ) " , ' ' )
448
+ $ItemPath = Get-item ($File.PSParentPath ).replace(" \$ ( $file.directory.name ) " , ' ' )
449
+ if (Test-Path " $ ( $ItemPath.PSParentPath ) \lookup\JndiLookup.class" ){Write-Host " lookupclass file found on $_ " ; $script :varDetection = 1 } else {if ($script :varDetection = 1 ){$script :Vardetection = 1 } else {$script :varDetection = 0 }}
448
450
449
- $script :varDetection = 1
450
451
} elseif ($checksum -in $MD5_GOOD.keys ) {
451
452
Write-Log - Text " MD5 found in good list referencing $ ( $MD5_BAD .$checksum ) " - Type Log
452
- $script :varDetection = 0
453
+ if ( $script :varDetection = 1 ){ $ script :Vardetection = 1 } else { $ script :varDetection = 0 }
453
454
} else {
454
455
Write-Log - Text ' MD5 was not found in any list' - Type Log
455
- $script :varDetection = 0
456
+ if ( $script :varDetection = 1 ){ $ script :Vardetection = 1 } else { $ script :varDetection = 0 }
456
457
}
457
458
}
458
459
}
459
460
}
460
461
461
-
462
- if (Select-String - Quiet - Path $_ " JndiLookup.class" ) {
463
- Write-Log - Text " ! ALERT: Potentially vulnerable file at $ ( $_ ) !" - Type WARN
464
- }
465
462
# endregion
466
463
if (-not $skipYARA ) {
467
464
# scan ii: YARA for logfiles & JARs
0 commit comments