Por que a maldet não está enviando relatório como um email?

0

O postfix está sendo executado. Eu estou tentando enviar relatório maldet como um e-mail, mas isso me dá um erro Eu não sei por quê?

[root@do ~]#  maldet --report 170321-0115.21534 [email protected]
Linux Malware Detect v1.6
            (C) 2002-2017, R-fx Networks <[email protected]>
            (C) 2017, Ryan MacDonald <[email protected]>
This program may be freely redistributed under the terms of the GNU GPL v2

/usr/local/maldetect/internals/functions: line 608: -s: command not found
maldet(18718): {report} report ID 170321-0115.21534 sent to [email protected]

E esta é a linha 608

if [ -f "$sessdir/session.$rid" ] && [ ! -z "$(echo $2 | grep '\@')" ]; th$
            cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
            eout "{report} report ID $rid sent to $2" 1
            exit
    
por kastelli 27.03.2017 / 19:33

2 respostas

1

A variável $ mail está vazia porque o comando mail não está instalado.

Execute apt-get install mailx (debian ou ubuntu) ou yum install -y mailx (centos ou redhat)

    
por 28.03.2017 / 05:01
0

Algumas configurações encontrarão o erro abaixo devido à falta do comando mail : /usr/local/maldetect/internals/functions: line 647: -s: command not found

Se você tiver sendmail instalado, poderá usar o diff abaixo para adicionar sendmail de suporte ao envio de e-mail:

diff --git a/files/internals/functions b/files/internals/functions
index f3e0a1a..acdb1b9 100644
--- a/files/internals/functions
+++ b/files/internals/functions
@@ -108,6 +108,10 @@ prerun() {
    if [ ! -f "$mail" ] || [ -z "$mail" ]; then
        email_alert=0
    fi
+
+   if [ "$email_alert" == "0" ] && [ -f "$sendmail" ]; then
+        email_alert=1
+    fi

    if [ ! -f "$sig_cust_hex_file" ]; then
        touch $sig_cust_hex_file
@@ -644,8 +648,19 @@ view_report() {
        fi
    fi
    if [ -f "$sessdir/session.$rid" ] && [ ! -z "$(echo $2 | grep '\@')" ]; then
-       cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
-       eout "{report} report ID $rid sent to $2" 1
+       if [ -f "$mail" ]; then
+           cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
+       elif [ -f "$sendmail" ]; then
+           if ! grep -q "SUBJECT: " "$sessdir/session.$rid"; then
+               echo -e "SUBJECT: $email_subj\n$(cat $sessdir/session.$rid)" > $sessdir/session.$rid
+           fi
+           cat $sessdir/session.$rid | $sendmail -t "$2"
+       else
+           eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+           exit
+       fi
+
+        eout "{report} report ID $rid sent to $2" 1
        exit
    fi
    if [ "$rid" == "" ] && [ -f "$sessdir/session.last" ]; then
@@ -1073,8 +1088,8 @@ scan() {
        eout "{scan.hook} scan of $spath in progress (id: $datestamp.$$)"
    fi
    cnt=0
-   if [ -z "$mail" ]; then
-       eout "{scan} no \$mail binary found, e-mail alerts disabled."
+   if [ -z "$mail" ] && [ -z "$sendmail" ]; then
+       eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
    fi
    if [ -f "$clamscan" ] && [ "$scan_clamscan" == "1" ]; then
        if [ -z "$hscan" ]; then
@@ -1309,7 +1324,16 @@ genalert() {
    file="$2"
         if [ "$email_alert" == "1" ] || [ "$type" == "digest" ] || [ "$type" == "daily" ]; then
        if [ "$type" == "file" ] && [ -f "$file" ]; then
-           cat $file | $mail -s "$email_subj" $email_addr
+           if [ -f "$mail" ]; then
+                cat $file | $mail -s "$email_subj" $email_addr
+            elif [ -f "$sendmail" ]; then
+                if ! grep -q "SUBJECT: " "$file"; then
+                    echo -e "SUBJECT: $email_subj\n$(cat $file)" > $file
+                fi
+                cat $file | $sendmail -t $email_addr
+            else
+                eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+            fi
            if [ ! "$(whoami)" == "root" ] && [ -z "$(echo $2 | grep '\@')" ]; then
                if [ -z "$hscan" ]; then
                    eout "{alert} sent scan report to config default $email_addr" 1
@@ -1353,8 +1377,18 @@ genalert() {
                grep -E '^{.*}' $sessdir/session.$scanid > $sessdir/session.hits.$scanid
                echo "$scanid" > $sessdir/session.last
                email_subj="${email_subj}: monitor summary"
-               cat $tmpf | $mail -s "$email_subj" $email_addr
-               eout "{alert} sent $type alert to $email_addr"
+               if [ -f "$mail" ]; then
+                    cat $tmpf | $mail -s "$email_subj" $email_addr
+                    eout "{alert} sent $type alert to $email_addr"
+                elif [ -f "$sendmail" ]; then
+                    if ! grep -q "SUBJECT: " "$tmpf"; then
+                        echo -e "SUBJECT: $email_subj\n$(cat $tmpf)" > $tmpf
+                    fi
+                    cat $tmpf | $sendmail -t $email_addr
+                    eout "{alert} sent $type alert to $email_addr"
+                else
+                    eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+                fi
                rm -f $tmpf $tmpdir/.digest.alert.hits $tmpdir/.digest.clean.hits $tmpdir/.digest.monitor.alert $tmpdir/.digest.susp.hits
            fi
        else
diff --git a/files/internals/internals.conf b/files/internals/internals.conf
index c998fd3..1291960 100644
--- a/files/internals/internals.conf
+++ b/files/internals/internals.conf
@@ -44,6 +44,7 @@ cpulimit='which cpulimit 2> /dev/null'
 ionice='which ionice 2> /dev/null'
 wc='which wc 2> /dev/null'
 mail='which mail 2> /dev/null'
+sendmail='which sendmail 2> /dev/null'
 pidof='which pidof 2> /dev/null'
 sed='which sed 2> /dev/null'
 stat='which stat 2> /dev/null'
-- 
1.8.3.2

O commit atual está disponível no link abaixo:

link

O acima é baseado no Linux Malware Detect v1.6.1.

    
por 22.06.2017 / 12:26