-
-
Save mjclemente/0b6ddc20c784fbff39d55ce94d52abf0 to your computer and use it in GitHub Desktop.
Scan a folder of jars recursively for CVE-2021-44228 vulnerability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Scan all jars in folder recursivley for log4j vuln | |
*/ | |
component { | |
property name="progressableDownloader" inject="ProgressableDownloader"; | |
property name="progressBar" inject="ProgressBar"; | |
/** | |
* @scanPath absolute or relative path to folder to look for jars | |
*/ | |
function run( scanPath='' ) { | |
var scannerJarPath = resolvePath( 'Log4JDetector-0.3-jar-with-dependencies.jar' ); | |
if( !fileExists( scannerJarPath ) ) { | |
progressableDownloader.download( | |
'https://github.com/CodeShield-Security/Log4JShell-Bytecode-Detector/releases/download/v0.3/Log4JDetector-0.3-jar-with-dependencies.jar', | |
scannerJarPath, | |
function( status ) { | |
progressBar.update( argumentCollection = status ); | |
} | |
); | |
} | |
scanPath = resolvePath( scanPath ); | |
var jarList = directorylist( scanPath, true, 'array', '*.jar' ); | |
if( !jarList.len() ) { | |
print.redLine( 'No jars found in [#scanPath#]' ) | |
} | |
jarList.each( (j)=>{ | |
try { | |
var output = command( 'run' ) | |
.params( 'java -cp "#scannerJarPath#" de.codeshield.log4jshell.Log4JDetector "#j#"' ) | |
.run( returnOutput=true ); | |
} catch( any e ) { | |
output = e.message; | |
} | |
.line( output.replaceNoCase( scanPath, '' ), ( output contains 'not affected' ? 'green' : 'red' ) ) | |
.toConsole(); | |
} ); | |
print.greenLine( 'Done!' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment