r/PowerShell • u/[deleted] • Dec 18 '21
Here is a Simple Script to detect for potential Log4J Vulnerabilities. I was scanning hashes earlier in the week but that proved unreliable so this just looks for known versions and unpacks to check for the class. Its been quick and reliable so far, just sharing as another option - good luck all!
https://github.com/shawnparslow/Log4jPowerShellScanner/blob/main/ScanLog4JFiles.ps19
u/GrowABrain3 Dec 18 '21
This doesn't work, you have no clue what the filename will look like. You need to search for all .jar and .war files and then select-string for jdnilookup.class inside all of those, and then it might still not work.
but going for log4j-core-version will not work.
2
Dec 18 '21
Thanks for the feedback, I am still looking at making some changes (I had an earlier version that just checked known sha1). What is in place should find known off-the-shelf named/versioned jar files (and has been working in my scans for specific enterprise products) but I know it does not work for repackaged or renamed distributions.
8
u/belibebond Dec 18 '21
I was doing this but found that Defender ATP already detects log4 files and tags it.
If you have defender in your organization I would go that route as it checks for hash and versions and more.
You can either quarantine it or just audit it.
5
u/belibebond Dec 18 '21
You have to go create advance threat hunting to add filter which shows affected log4 machines and it’s path.
2
0
17
u/[deleted] Dec 18 '21
I'm working on one that uses "Everything" to find all jar files and anything that has log4j in the name and searches the content for the class name. I works but I need to pretty it up.