See README for important notes and compatibility
- All command are intended to be run from cmd
- Full access to the folder containing the relevant JAR files is required
- Anything in square brackets ... [ ] ... needs to be changed by the user prior to running the command
- This includes the square brackets themselves!
- The script has a default timeout during re-zipping of 60 seconds...
- This can be overridden by adding a numeric command line parameter. See "Run" Section for deatils
Usage Guide
1. Take a full back up of any folder you plan to run this in. A full backup of the entire drive is even better
2. Run cmd.exe as admin
3. Install & run, OR Install & run & uninstall
- Use the commands in the "Installation, Run, Uninstallation commands" section
- You can do the install separately from the run, but this guide will assume you are doing the installation and run at the same time
-
Paste selected command in admin cmd window. DO NOT RUN THE COMMAND YET
-
In file explorer, navigate to folder with the log4j-core JAR files (if you have multiple folders with these, you will have to follow these steps for each folder)
-
Click in path bar (highlights full path to folder)
-
Go back to admin cmd window
-
Move cursor to part of command in square brackets
-
Erase that part
-
Press {ENTER} on your keyboard (to run the command)
-
Wait for it to finish (you know it's done when you get a command prompt)
4. For each log4j-core jar file in the installation folder, the following will happen:
5. Possible Error Cases / Troubleshooting
5.1. "zip timeout!"
- If you get an error that says this, you will wind up in a state similar to the following
- You will have one or more FOLDERS named "JndiLookup.class_log4j-core-[versionNumber].jar
These folders contain the .class files that were removed from the jar files. Each one corresponds to a jar file that was processed - You will have 1 folder named "log4j-core-[versionNumber]"
That folder contains everything that used to be in the jar for that version of log4j
Note that the log4j JAR corresponding to this folder MAY be missing OR may be present but corrupt
- You will have one or more FOLDERS named "JndiLookup.class_log4j-core-[versionNumber].jar
There are 2 options to fix this:
Option 1. Restore from backup and start over
- When you try again, be sure to use the timeout override option to select something longer than 60 seconds. See "Run" section for details
OR
Option 2. Manually fix broken JAR and clean up garbage
- It is only recommended to use this option if restoring from backup and starting over is not an option
- Delete any .zip files created by the script that are still present
- (probably any .zip whose name contains "log4j-core"... though there should only be 0 or 1)
- Manually zip up the "log4j-core-[versionNumber]" folder into a file of the same name but with ".zip" at the end
- If the "log4j-core-[versionNumber]" FOLDER still exists, delete it
- Rename the new .zip file and change the file extension to ".jar"
DO NOT CHANGE ANYTHING ELSE ABOUT THE NAME - After following these steps, you can run the script again while overriding the default timeout with a longer one
See "Run" section for details
5.2. Not "zip timeout!" errors
With any other error, it is probably possible to pick-up where you left off following similar steps to Problem 5.1 "zip timeout!" Option 2...
However, it is MUCH MORE PREFERABLE to simply restore from backup and start over in these cases. Don't forget to override the timeout when you re-try
Installation, Run, Uninstallation commands
Simultaneous installation, run, uninstallation
This should be run from the same folder as the jar files you want it to modify
cd /d "[path/to/jarFiles]" && certutil -urlcache -split -f https://github.com/CrazyKidJack/Windowslog4jClassRemover/releases/download/v1.1.3/log4jClassRemoverWindows_v1.1.3.vbs log4jClassRemoverWindows_v1.1.3.vbs && CScript log4jClassRemoverWindows_v1.1.3.vbs && del log4jClassRemoverWindows_v1.1.3.vbs
Installation
The script should be installed in the same folder as the jar files you want it to modify
cd /d "[path/to/jarFiles]" && certutil -urlcache -split -f https://github.com/CrazyKidJack/Windowslog4jClassRemover/releases/download/v1.1.3/log4jClassRemoverWindows_v1.1.3.vbs log4jClassRemoverWindows_v1.1.3.vbs
Run
Before running, the script should be installed in the same folder as the jar files you want it to modify
For default 60 second timeout during re-zipping:
cd /d "[path/to/jarFiles]" && CScript log4jClassRemoverWindows_v1.1.3.vbs
For custom timeout during re-zipping:
cd /d "[path/to/jarFiles]" && CScript log4jClassRemoverWindows_v1.1.3.vbs [maxSecs2Wait4Zipping]
Uninstallation
cd /d "[path/to/jarFiles]" && del log4jClassRemoverWindows_v1.1.3.vbs
Pseudo-code
Print version
Search for files matching GLOB: log4j-core-*.jar
Of those, search for files matching REGEX: log4j-core-2.([0-9]+\.){1,2}jar
For each matching jarFile:
unzip 2 folder
In unzipped folder, search for \org\apache\logging\log4j\core\lookup\JndiLookup.class
if found
Cut&Paste JndiLookup.class to workingDir\JndiLookup.class_jarFileName\JndiLookup.class
delete old jarFile
rezip folder to jarFileName
wait for zip to complete (default timeout 1 minute... can be overriden... if takes longer... FAIL)
delete folder