#!/bin/bash

function output () {
    echo -e "\e[31m[WARNING]  Suspected to be vulnerable, files with name\e[0m"
    echo -e "\e[31m:- $RESULT\e[0m"
}

echo -e "\e[32m\n Scanning for log4j vulnerability.............\e[0m \n"

RESULT="$(locate log4j|grep -v log4js)"
if [ "$RESULT" ]; then
  output
fi;
RESULT="$(dpkg -l|grep log4j|grep -v log4js)"
if [ "$RESULT" ]; then
  output
fi;
if [ "$(command -v java)" ]; then
  echo -e "\e[31m[WARNING]  It seems java is installed, libraries are inside jar/war/ear files, suspected to have log4j in such applications.\e[0m";
fi;

echo -e "\e[33m\n Congratulations It Seems you are safe, if you see any results above Please check the listed files and packages\e[0m\n ";