Skip to content

Instantly share code, notes, and snippets.

@jaypeche
Created December 1, 2014 16:01
Show Gist options
  • Select an option

  • Save jaypeche/2ec11b348d94d667c4d6 to your computer and use it in GitHub Desktop.

Select an option

Save jaypeche/2ec11b348d94d667c4d6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script "ClamAV Temps Réel", par HacKurx
# http://hackurx.wordpress.com
# Licence: GPL v3
# Dépendance: clamav-daemon inotify-tools
# Recommandé pour PC de bureau: libnotify-bin
DOSSIER=$HOME/Téléchargements
QUARANTAINE=/tmp
LOG=$HOME/.clamav-rt.log
[ $EUID = 0 ] && echo -e "For security, this script must be run as simple user, exiting !" && exit 1
inotifywait -q -m -r -e create,modify,access,close_write,moved_to "$DOSSIER" --format '%w%f|%e' | sed --unbuffered 's/|.*//g' |
while read FICHIER; do
clamdscan --quiet --no-summary -i -m "$FICHIER" --move=$QUARANTAINE
if [ "$?" == "1" ]; then
beep // Beep Event sound
echo "`date` - Threat found into $FICHIER. File was moved to $QUARANTAINE." >> $LOG
echo -e "\033[31mThreat found : \033[00m" "'$FICHIER' was moved to quarantine."
if [ -f /usr/bin/notify-send ]; then
notify-send -u critical -t 20000 --icon=/home/jay/clamav/clamav-icone-4692-96.png \
"ClamAV Realtime" "1 Threat found : \n $FICHIER was moved to quarantine."
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment