Search Log4j files / applications on your endpoints

Hello folks,

Below script will help you locate log4j jar files and their versions on your Windows endpoints. It simply searches for file names containing log4j and generates a list of files and their file paths. You can than refer to Apache website to decide if they need your attention. Hope it helps your remediation efforts.

Moderators, please upload this to scripts.itarian.com so our community can find it easily.

Happy holidays!

#This script will help you locate log4j jar files and their versions on your Windows endpoints.
#It simply searches for file names containing log4j and generates a list of files and their file paths.
#You can than refer to Apache website to decide if they need your attention. Hope it helps your remediation efforts.
#Make sure to check “configure parameters” button before running the procedure and use default value “log4j”
#Searching files in drive names from B to E, change this for your endpoints if needed. see below

param = itsm.getParameter(‘Keyword’)

import ctypes
import sys
import os
import re
search_name="."+param+"."

class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
def enter(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def exit(self, type, value, traceback):
if self.success:
self._revert(self.old_value)

with disable_file_system_redirection():
disk=os.popen( r’wmic logicaldisk get name’).read()
#Searching drive names from B to E, change this for your endpoints if needed.
drive_list = re.findall(r’.*[B-E]:’,disk)
#print drive_list
#print type (drive_list)
drive = “”
for drive in drive_list:
drive_path = drive+""
for dirpath,dirs,files in os.walk(drive_path):
try:
for k in files:
result = re.search(search_name,k,re.IGNORECASE)
if result != None:
fpath=os.path.join(dirpath,k)
print fpath
except:
pass

Hi @GISTeam,

Thanks for sharing the script for Log4j which can be helpful. We have published the script using this as reference
https://scripts.itarian.com/frontend…s-on-endpoints

Kind Regards,
PremJK

Hi,

Thanks for making this script available.
It’s definitely a handy script nowadays.

But, If I run this script over all my endpoints (100+), how do I check the results?
It’s not doable to open all the script logs manually to check the results…

@Itarian: is it possible to adapt the script so that it will send the results to email?
Or that they appear in the ‘Notification list’.
Or anywhere…
How can I see the results of such a procedure like an overview?

Regards

Hey @ailan,

Itarian might come up with a solution for your request. But in the meantime you way want to use our workaround for this. You can see list of all endpoints and file name/paths in a single table.

Here is how:

  • go to the Execution Log of the procedure
  • Export > Export to CSV
  • Go to Dashboard > Reports
  • Download and review CSV table in Excel showing endpoint names and file paths.

Thanks

Hi @GISTeam ,

That’s a very nice workaround and works well to see a list of all the devices… :wink:

Thanks for your tip!

Regards