Testare simscan

12 gennaio 2018 by Roberto Puzzanghera 3 commenti

Inviare un messaggio mailtest.txt ad un utente e controllare la risposta di simscan:

> echo "This is a test message" > mailtest.txt
> QMAILQUEUE=/var/qmail/bin/simscan SIMSCAN_DEBUG=4 /var/qmail/bin/qmail-inject user@yourdomain.tld < mailtest.txt 

simscan: cdb looking up 
simscan: cdb for found clam=yes,spam=yes,spam_hits=9.5,attach=.vbs:.lnk:.scr:.wsh:.hta:.pif
simscan: pelookup clam = yes
simscan: pelookup spam = yes
simscan: pelookup spam_hits = 9.5
simscan: Per Domain Hits set to : 9.500000
simscan: pelookup attach = .vbs:.lnk:.scr:.wsh:.hta:.pif
simscan: attachment flag attach = .vbs:.lnk:.scr:.wsh:.hta:.pif
simscan: add_attach called with .vbs:.lnk:.scr:.wsh:.hta:.pif
simscan: .vbs is attachment number 0
simscan: .lnk is attachment number 1
simscan: .scr is attachment number 2
simscan: .wsh is attachment number 3
simscan: .hta is attachment number 4
simscan: .pif is attachment number 5
simscan: starting: work dir: /var/qmail/simscan/1515774500.399139.5534
simscan: F envelope is root@mail.yourdomain.tld
simscan: T1 envelope is user@yourdomain.tld
simscan: pelookup: called with root@mail.yourdomain.tld
simscan: pelookup: domain is qmailtest.sagredo.eu
simscan: cdb looking up qmailtest.sagredo.eu
simscan: pelookup: local part is root
simscan: lpart: local part is **
simscan: cdb looking up root@mail.yourdomain.tld
simscan: pelookup: called with user@yourdomain.tld
simscan: pelookup: domain is qtest.sagredo.eu
simscan: cdb looking up qtest.sagredo.eu
simscan: pelookup: local part is test
simscan: lpart: local part is **
simscan: cdb looking up user@yourdomain.tld
simscan: checking attachment textfile0 against .vbs
simscan: checking attachment textfile0 against .lnk
simscan: checking attachment textfile0 against .scr
simscan: checking attachment textfile0 against .wsh
simscan: checking attachment textfile0 against .hta
simscan: checking attachment textfile0 against .pif
simscan: checking attachment addr.1515774500.399139.5534 against .vbs
simscan: checking attachment addr.1515774500.399139.5534 against .lnk
simscan: checking attachment addr.1515774500.399139.5534 against .scr
simscan: checking attachment addr.1515774500.399139.5534 against .wsh
simscan: checking attachment addr.1515774500.399139.5534 against .hta
simscan: checking attachment addr.1515774500.399139.5534 against .pif
simscan: checking attachment msg.1515774500.399139.5534 against .vbs
simscan: checking attachment msg.1515774500.399139.5534 against .lnk
simscan: checking attachment msg.1515774500.399139.5534 against .scr
simscan: checking attachment msg.1515774500.399139.5534 against .wsh
simscan: checking attachment msg.1515774500.399139.5534 against .hta
simscan: checking attachment msg.1515774500.399139.5534 against .pif
simscan: cdb looking up version attach
simscan: runned_scanners is attach: 1.4.0
simscan: found 1.4.0
simscan: calling clamdscan
simscan: clamdscan: /usr/local/qmail/simscan/1515774500.399139.5534: OK
simscan: clamdscan: 
simscan: clamdscan: ----------- SCAN SUMMARY -----------
simscan: clamdscan: Infected files: 0
simscan: clamdscan: Time: 0.004 sec (0 m 0 s)
simscan: cdb looking up version clamav
simscan: runned_scanners is attach: 1.4.0 clamav: 0.99.2/m:58/d:24215
simscan: found 0.99.2/m:58/d:24215
simscan: normal clamdscan return code: 0
simscan: calling spamc
simscan: calling /usr/local/bin/spamc spamc -u user@yourdomain.tld
simscan: cdb looking up version spam
simscan: runned_scanners is attach: 1.4.0 clamav: 0.99.2/m:58/d:24215 spam: 3.4.1
simscan: found 3.4.1
simscan:[5533]:CLEAN (3.80/9.50):0.3657s::(null):root@mail.yourdomain.tld:user@yourdomain.tld
simscan: done, execing qmail-queue
simscan: qmail-queue exited 0

simscan e chkuser in azione nel log smtpd

Questo è ciò che si dovrà vedere nel log smtpd cone le seguenti impostazioni nel file simcontrol:

spam=yes,spam_passthru=yes

Simscan lascierà passare lo spam a prescindere dal suo punteggio. In questo caso è consigliabile impostare una regola sieve che salvi lo spam nella cartella Spam.

@TIMESTAMP CHKUSER accepted sender: from <spammer@somewhere.net::> remote  rcpt <> : sender accepted
@TIMESTAMP CHKUSER accepted rcpt: from <spammer@somewhere.net::> remote  rcpt <user@yourdomain.net> : found existing recipient
@TIMESTAMP simscan:[26411]:PASSTHRU (16.60/5.00):4.3012s:Body text.:[remoteIP]:spammer@somewhere.net:user@yourdomain.net

spam=yes,spam_passthru=no,spam_hits=9.5

lo spam sarà rigettato nel caso in cui il punteggio sia al di sopra di 9.5, e in nessun caso passato all'utente:

@TIMESTAMP CHKUSER accepted sender: from <spammer@somewhere.net::> remote  rcpt <> : sender accepted
@TIMESTAMP CHKUSER accepted rcpt: from <spammer@somewhere.net::> remote  rcpt <user@yourdomain.net> : found existing recipient
@TIMESTAMP simscan:[26411]:SPAM REJECT (16.60/5.00):4.3012s:Body text.:[remoteIP]:spammer@somewhere.net:user@yourdomain.net

spam=yes,spam_hits=9.5

Questa è la configurazione suggerita.

In questo caso, se il punteggio dello spam è tra 5.0 e 9.5 il messaggio sarà lasciato passare da simscan anche se spamassassin l'ha etichettato come spam (spamassassin di tanto in tanto può sbagliarsi e questi messaggi con punteggio non altissimo è meglio non cancellarli, non si sa mai..):

@TIMESTAMP CHKUSER accepted sender: from <spammer@somewhere.net::> remote  rcpt <> : sender accepted
@TIMESTAMP CHKUSER accepted rcpt: from <spammer@somewhere.net::> remote  rcpt <user@yourdomain.net> : found existing recipient
@TIMESTAMP simscan:[26411]:SPAM CLEAN (6.40/9.50):4.3012s:Body text.:[remoteIP]:spammer@somewhere.net:user@yourdomain.net

E questo è ciò che si dovrebbe vedere nell'intestazione del messaggio:

X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-01-18) on mail.myserver.net
X-Spam-Flag: YES X-Spam-Level: ****** X-Spam-Status: Yes, score=6.4 required=5.0 tests=BAYES_99,HTML_MESSAGE,RAZOR2_CF_RANGE_51_100,RAZOR2_CF_RANGE_E4_51_100,RAZOR2_CHECK,RDNS_NONE autolearn=no version=3.3.1

Notare che lo status del messaggio E' spam, ma il punteggio (score) è al di sotto dfella soglia di 9.5 al di là della quale simscan l'avrebbe rigettato.

Problematiche

@400000004dd263d6378e6b74 qmail-smtpd: message delayed (mail server temporarily rejected message (#4.3.0)): xxxx@xxxxx.xx from y.y.y.y to zzzzzz@zzzz.zz helo mail.xxxxx.xx

Ho visto un errore come questo in un server dove i servizi spamd e clamd erano fermi e tutte le email non venivano recapitate. Il problema è stato risolto con un semplice avvio dei servizi collegati a simscan.

Commenti

problema invio

Salve Roberto intato grazie delle risposte precedenti.

Non invia messaggio per questo errore ma non risco a troivare dove ho sbagliato la configurazione sono su debian.

Sun Mar 21 15:00:10 2021 -> /var/qmail/simscan/1616338810.89207.825/msg.1616338810.89207.825: Can't open file or directory ERROR

Grazie, Gabriele

Rispondi |

problema invio

Ciao Gabriele,

hai seguito passo passo la guida ripmime/simscan? In particolare con quale utente stai eseguendo simscan?

Rispondi |

problema invio legato a clamdscan

Grazie dell'attenzione Roberto,

il problema non è nella tua spiegazione,  è debian, c'è un baco nel pacchetto clamav-daemon. Ho risolto disabilitando il profilo Application Armor di usr.sbin.clamd, l'ho disabilitato perché non conosco come funziona apparmor, suppongo ci sia la possibilità di aggiungere /var/qmail/simscan nelle sue politiche. Anche se dava errore sulla scansione di qualsiasi direcoty.

output di dmsg:

apparmor="DENIED" operation="open" profile="/usr/sbin/clamd" name="/var/qmail/simscan/1616345039.297759.1469/msg.1616345039.297759.1469" pid=676 comm="clamd" requested_mask="r" denied_mask="r" fsuid=108 ouid=108

Ho usato il pacchetto per semplificare l'aggiornamento delle release di clamAV come ho fatto anche sugli altri server.

ecco come ho fatto

ln -s /etc/apparmor.d/usr.sbin.clamd /etc/apparmor.d/disable/
apparmor_parser -R /etc/apparmor.d/usr.sbin.clamd
systemctl restart clamav-daemon

Grazie e ancora grazie per la tua guida

Rispondi |