Skip to content

Instantly share code, notes, and snippets.

@mjclemente
Forked from bdw429s/task.cfc
Created December 13, 2021 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjclemente/0b6ddc20c784fbff39d55ce94d52abf0 to your computer and use it in GitHub Desktop.
Save mjclemente/0b6ddc20c784fbff39d55ce94d52abf0 to your computer and use it in GitHub Desktop.
Scan a folder of jars recursively for CVE-2021-44228 vulnerability
/**
* 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;
}
print
.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