Skip to content

Instantly share code, notes, and snippets.

@atomicturtle
Created December 10, 2021 18:38
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 atomicturtle/130081b387562b753edd9adb0bc1d19f to your computer and use it in GitHub Desktop.
Save atomicturtle/130081b387562b753edd9adb0bc1d19f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: Skip Grube
# Contributors:
# - Scott Shinn
# - Rob Felsburg
VERSION=0.2
# Search for jar files named "log4j", and jar files that contain a file named "log4j"
# Display the results with a "@FOUND" tag for grep'ing later:
echo
echo "log4j search utility (Log4Shell: RCE 0-day) by Skip Grube"
echo "Version ${VERSION}"
echo -n "Updating mlocate database:"
updatedb
if [ $? -eq 0 ]; then
echo COMPLETE
else
echo FAILED
fi
(
echo "log4j filenames: ############################################"
jarFiles=`locate -i *.jar`
echo "${jarFiles}" | grep -i "log4j" | xargs -n 1 -I {} echo '@FOUND :: {}'
echo "###########################################################
"
echo "inspect jar files for log4j: #######################################"
IFS='
'
for i in `echo "${jarFiles}"`; do
for j in `unzip -l "${i}" | grep -i "log4j"`; do
echo "@FOUND_FILE :: ${i} :: ${j}"
done
done
) &> $HOME/`hostname`_log4j_find.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment