Skip to content

Instantly share code, notes, and snippets.

@holly
Last active June 15, 2018 08:45
Show Gist options
  • Save holly/e3ef09ae9551d425eb77 to your computer and use it in GitHub Desktop.
Save holly/e3ef09ae9551d425eb77 to your computer and use it in GitHub Desktop.
clamav-milter VirusAction script
#!/usr/bin/env bash
# setting clamav-milter config file
# VirusAction /path/to/virus-alert.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
SERVER=$HOSTNAME
VIRUS_ADMIN=${VIRUS_ADMIN:=virus-admin@$HOSTNAME}
VIRUS_ALERT=${VIRUS_ALERT:=postmaster@$HOSTNAME}
SUBJECT="[virus-alert] $SERVER: an infected e-mail has been detected."
#### Should sanitize the input strings ####
VIRUS=$1 # Name of the detected virus (Obviously)
FILE=$2 # FILE/ID of the message (on the server)
SENDER=$3 # SENDER's e-mail
RECIPIENT=$4 # RECIPIENT's e-mail (Only the first one will be passed)
SUBJECT=$5 # The subject of the message
MSGID=$6 # MESSAGE-ID Of the given message (From Message-ID Header)
DATE=$7 # MSG RECV DATE TIME
cat -v << EOF | /usr/sbin/sendmail -t -i
From: $VIRUS_ADMIN
To: $VIRUS_ALERT
Subject: $SUBJECT
Signature : $VIRUS
Date : $DATE
Subject : $SUBJECT
Sender : $SENDER
Recipient : $RECIPIENT
File : $FILE
Message is currently quarantined. Further action is required.
EOF
@CSchulz
Copy link

CSchulz commented Nov 20, 2017

SUBJECT is overwritten by parameters.

@secretofthesteel
Copy link

Thanx for script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment