Last active
February 17, 2025 20:14
-
-
Save Yiannis128/2ad4e9d1c78dbda97d9711941540e7e1 to your computer and use it in GitHub Desktop.
ClamAV custom notifier script that manually triggers the VirusEvent script by reading the OnAccessScan logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
# If the logs contain duplicate entries, they should be ignored to avoid spamming the user | |
# with duplicate notifications. | |
IGNORE_DUPLICATES=true | |
# Keeps track of the journal for virus found events and manually invokes the VirusEvent | |
# script because of https://github.com/Cisco-Talos/clamav/issues/1062 | |
while IFS= read LINE;do | |
if [[ $LINE == *"FOUND"* ]]; then | |
# Check that there is no duplicate reports by ClamAV OnAccessScan (I don't know why | |
# this happens) | |
if [[ !"$IGNORE_DUPLICATES" && "$PREVIOUS_LINE" == "$LINE" ]]; then | |
continue | |
fi | |
export CLAM_VIRUSEVENT_FILENAME=$(echo $LINE | cut -d : -f 1 | xargs) | |
SIG=$(echo $LINE | cut -d : -f 2 | xargs) | |
export CLAM_VIRUSEVENT_VIRUSNAME="${SIG/ FOUND/}" | |
echo "ClamAV OnAccessScan Notifier: Found Signature $CLAM_VIRUSEVENT_VIRUSNAME in $CLAM_VIRUSEVENT_FILENAME" | |
/opt/clamav/virus-event.sh | |
fi | |
PREVIOUS_LINE="$LINE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment