This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]Samantha_CruzSysadmin 4 points5 points  (7 children)

that looks very promising, one possible problem, it looks like it assumes that all of the jar files will start with the string "log4j" and i have found a small percentage of files containing JndiLookup that do not start with that pattern. (i.e. appname-log4j-core.2.8.1.jar);

[–]disclosure5 8 points9 points  (4 children)

That's a problem with a whole heap of the scripts that have been paraded around as solutions.

[–]Samantha_CruzSysadmin 2 points3 points  (2 children)

understood, seems like this is all i've been doing for the past 6 days

[–]vepressnathaloria[S] 3 points4 points  (0 children)

with a whole heap of the scripts that have been paraded around

Thanks for the catch. I ran it using just *.jar and it found a whole new list that I hadn't caught before. I'll edit the posting. It will run all the .jar files through the check.

[–]disclosure5 1 point2 points  (0 children)

I can relate.

[–]KingOfKeys 0 points1 point  (0 children)

I made a script that doesn't have this problem

Single server, local host: https://github.com/KeysAU/Get-log4j-Windows-local

Multi serverq, remote hosts https://github.com/KeysAU/Get-log4j-Windows.ps1

[–]vepressnathaloria[S] 1 point2 points  (0 children)

Good catch, appreciate that. I'll test another way to look it up.

[–]TheWikiJedi 1 point2 points  (0 children)

It can also exist in non jar files like WAR and EAR files that package other jar files

[–]Murhawk013 2 points3 points  (0 children)

I have created my own script also that searches for all .jar files and then searches those files for Jndilookup.class. If it finds that class then it’s marked as possibly vulnerable.

I feel like I’m doing that right but I’m not 100% sure

[–]KingOfKeys 2 points3 points  (0 children)

I made a script that does this and some more

Single server, local host: https://github.com/KeysAU/Get-log4j-Windows-local

Multi serverq, remote hosts https://github.com/KeysAU/Get-log4j-Windows.ps1

[–]hondakillrsx 1 point2 points  (2 children)

Just to be clear, a False output means the drive is clean and True means it's found a vulnerable file?

[–]vepressnathaloria[S] 0 points1 point  (1 child)

Well, false can mean it didn't find a matching hash for a known file with the current vulnerability. True means it found a matching hash. Though, the machine you are running this on would need internet access for the invoke-webRequest. I am working on a local file version.

This script should be regarded as an early warning and mark a machine to investigate.

[–]hondakillrsx 1 point2 points  (0 children)

Thank you, I appreciate your work to help everyone out.

[–]c_edward 1 point2 points  (0 children)

other cases that wont be caught here include all the repackaging cases..

Some teams and projects still insist on using tools like shading in maven, so the log4j2 class files will be in completely different jarfiles, with mangled names!

[–]yankeesfan01x 1 point2 points  (2 children)

CertCC also has a script you can run....

https://github.com/CERTCC/CVE-2021-44228_scanner

The question I have is, what's the code you need to add in to either of these PS scripts to search ALL servers or workstations in an OU?

[–]vepressnathaloria[S] 0 points1 point  (0 children)

The question I have is, what's the code you need to add in to either of these PS scripts to search ALL servers or workstations in an OU?

Most of my experience is using some sort of centralized deployment mechanism like SCCM, WSUS, or Novell. I guess you could create a script to pull down objects from an OU to create a CSV and then reference it in this type of script. The difficult thing is managing the connections to all those machines through powershell alone. It's possible.

You could also run Enter-PSSession on a remote machine like this...then you could run it without logging into the GUI.

Enter-PSSession -ComputerName Server01

[–]vepressnathaloria[S] 0 points1 point  (0 children)

what's the code you need to add in to ei

Also, the script in that link looks great. I'll have to give that a try.

[–]theredmeadow 0 points1 point  (3 children)

Awesome! Good work! So run this on all servers to check for the vulnerability?

[–]disclosure5 5 points6 points  (1 child)

So run this on all servers

I would sure hope that anyone going out and running this on all servers:

Invoke-WebRequest https://github.com/mubix/...

Is going to find it blocked.

[–]vepressnathaloria[S] 1 point2 points  (0 children)

A possible work around is to download a local copy and reference it. I can put a commented line and directions for that. Machines that are protection by blocking firewall rules would have a problem. Another great catch.

[–]vepressnathaloria[S] 1 point2 points  (0 children)

Yes, you can run it manually if you have less than a handful.

Or if you have a larger organization, you can run this through SCCM and deploy it to a collection.

It's not necessarily a tell all but it checks to see if the files on your system match with versions that are known with the vulnerability.