Virus action.sh: Difference between revisions

From Alpine Linux
m (minor)
(Cleaned up the looks of the script)
Line 1: Line 1:
#!/bin/sh
<pre>
#!/bin/sh


## Send the user usefull info in the notification email
## Send the user usefull info in the notification email
FROM="`awk '/^[Ff][Rr][Oo][Mm]:/' $EMAIL`"
FROM="`awk '/^[Ff][Rr][Oo][Mm]:/' $EMAIL`"
SUBJECT="`awk '/[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:/' $EMAIL`"
SUBJECT="`awk '/[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:/' $EMAIL`"
## Logfile to log status to
## Logfile to log status to
LOGFILE="/tmp/virus_action.log"
LOGFILE="/tmp/virus_action.log"
## From email address where the notification email comes from
## From email address where the notification email comes from
MAILFROM=""
MAILFROM=""
## Email address to send a copy of the virus/spam email to
## Email address to send a copy of the virus/spam email to
QUARANTAINE=""
QUARANTAINE=""


exec 1>>"$LOGFILE"
exec 1>>"$LOGFILE"
exec 2>>"$LOGFILE"
exec 2>>"$LOGFILE"


notify_user() {
notify_user() {
         echo "HELO `hostname -f`"
         echo "HELO `hostname -f`"
         echo "MAIL FROM:<$MAILFROM>"
         echo "MAIL FROM:<$MAILFROM>"
Line 41: Line 42:
         echo "."
         echo "."
         echo "quit"
         echo "quit"
}
}


send_virus() {
send_virus() {
         echo "HELO `hostname -f`"
         echo "HELO `hostname -f`"
         echo "MAIL FROM:<$MAILFROM>"
         echo "MAIL FROM:<$MAILFROM>"
Line 52: Line 53:
         echo "."
         echo "."
         echo "quit"
         echo "quit"
}
}


notify_user | nc localhost 10026
notify_user | nc localhost 10026
send_virus | nc localhost 10026
send_virus | nc localhost 10026
rm "$EMAIL"
rm "$EMAIL"
</pre>

Revision as of 13:28, 21 May 2009

#!/bin/sh

## Send the user usefull info in the notification email
FROM="`awk '/^[Ff][Rr][Oo][Mm]:/' $EMAIL`"
SUBJECT="`awk '/[Ss][Uu][Bb][Jj][Ee][Cc][Tt]:/' $EMAIL`"
## Logfile to log status to
LOGFILE="/tmp/virus_action.log"
## From email address where the notification email comes from
MAILFROM=""
## Email address to send a copy of the virus/spam email to
QUARANTAINE=""

exec 1>>"$LOGFILE"
exec 2>>"$LOGFILE"

notify_user() {
         echo "HELO `hostname -f`"
         echo "MAIL FROM:<$MAILFROM>"
         for RCPT in "$RECIPIENTS"; do
         echo "RCPT TO:<$RCPT>"
         done
         echo "RCPT TO:<$RECIPIENTS>"
         echo "DATA"
         sleep 1
         echo "Subject: Mail system notification"
         echo "Dear user,"
         echo ""
         echo "A virus or spam email has been found by the mail system."
         echo "We have gathered the following information for you:"
         echo ""
         echo "Date: `date`"
         echo "$FROM"
         echo "$SUBJECT"
         echo "Virus/spam name: $VIRUS"
         echo ""
         echo "If you think this is incorrect, please notify your administrator at once."
         echo ""
         echo "Best regards,"
         echo ""
         echo "Your mail administrator"
         echo "."
         echo "quit"
}

send_virus() {
         echo "HELO `hostname -f`"
         echo "MAIL FROM:<$MAILFROM>"
         echo "RCPT TO:<$QUARANTAINE>"
         echo "DATA"
         sleep 1
         cat "$EMAIL"
         echo "."
         echo "quit"
}

notify_user | nc localhost 10026
send_virus | nc localhost 10026
rm "$EMAIL"