doc:appunti:linux:sa:procmail_sanitizer_clamav
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:linux:sa:procmail_sanitizer_clamav [2020/06/16 13:13] – [Cosa succede se clamd è fermo] niccolo | doc:appunti:linux:sa:procmail_sanitizer_clamav [2022/04/11 18:13] (current) – [Content-Type ed estensioni per Sanitizer] niccolo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | Se si utilizza **procmail** come //local delivery agent//, è sufficiente aggiungere questa regola in **$HOME/ | + | ===== Procmail ===== |
| + | Se si utilizza **procmail** come //local delivery agent//, è sufficiente aggiungere questa regola in **$HOME/ | ||
| < | < | ||
| + | # | ||
| + | # $HOME/ | ||
| + | # | ||
| PATH=/ | PATH=/ | ||
| SHELL=/ | SHELL=/ | ||
| Line 19: | Line 23: | ||
| </ | </ | ||
| - | Il programma sanitizer | + | ===== Sanitizer ===== |
| + | |||
| + | Il programma sanitizer | ||
| < | < | ||
| + | # | ||
| + | # Active features. | ||
| + | # | ||
| + | feat_verbose | ||
| + | feat_log_inline | ||
| + | feat_log_stderr | ||
| + | feat_log_xml | ||
| + | feat_log_trace | ||
| + | feat_log_after | ||
| + | feat_files | ||
| + | feat_mime_files | ||
| + | feat_force_name | ||
| + | # have file names. | ||
| + | feat_boundaries | ||
| + | # NOTE: Always breaks PGP/MIME messages! | ||
| + | feat_lengths | ||
| + | # values. | ||
| + | feat_scripts | ||
| + | feat_html | ||
| + | feat_webbugs | ||
| + | feat_trust_pgp | ||
| + | feat_uuencoded | ||
| + | feat_forwards | ||
| + | feat_testing | ||
| + | feat_fixmime | ||
| + | feat_paranoid | ||
| + | |||
| # | # | ||
| # Create saved files using this template. The directory must exist and | # Create saved files using this template. The directory must exist and | ||
| # be writable by the user running the sanitizer. | # be writable by the user running the sanitizer. | ||
| + | # $d - Day of month (01-31) | ||
| + | # $m - Month number (01-12) | ||
| + | # $y - Two digit year (00-99) | ||
| + | # $Y - Four digit year | ||
| + | # $H - Hour (00-23) | ||
| + | # $M - Minute (00-59) | ||
| + | # $S - Second (00-59) | ||
| + | # | ||
| + | # $P - This process' | ||
| + | # $T - The current Unix time, in hex. | ||
| + | # $F - A safe version of the original file name. | ||
| + | # $ - A random character, from [A-Z0-9]. | ||
| # | # | ||
| file_name_tpl = / | file_name_tpl = / | ||
| Line 38: | Line 83: | ||
| msg_file_save += %SAVEDNAME\n | msg_file_save += %SAVEDNAME\n | ||
| msg_file_save += *******************\n | msg_file_save += *******************\n | ||
| + | |||
| + | # | ||
| + | # We have 2 policies, in addition to the file_default_policy. | ||
| + | # | ||
| + | file_list_rules = 2 | ||
| + | |||
| + | # | ||
| + | # 1) Scan some attachments for virus with Clam AntiVirus. | ||
| + | # | ||
| + | # This policy apply to attachments whose file name did not match any | ||
| + | # previous policy and matches this regular expression. | ||
| + | # The policy action can be: | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # text message and save the attachment into a local file. | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # Archives, executables, | ||
| + | # expression, see "man perlre" | ||
| + | # the regexp case insensitive. | ||
| + | file_list_1 | ||
| + | file_list_1 += 7z|bat|com|chm|cmd|cpl|exe|pif|scr|sys | ||
| + | file_list_1 += |dat|doc|m? | ||
| + | file_list_1 += |class|pl|vb[es]|[sp]? | ||
| + | file_list_1 += |z(ip|oo)|ar[cj]|lha|[tr]ar|rpm|deb|slp|tgz|g? | ||
| + | file_list_1 += )$ | ||
| # Virus scanner command line. The three exit codes represent the | # Virus scanner command line. The three exit codes represent the | ||
| # following scan conditions: clean, disinfected, | # following scan conditions: clean, disinfected, | ||
| - | file_list_1_scanner = 0:1: | + | # NOTICE: clamdscan does not have the " |
| + | file_list_1_scanner = 0:99: | ||
| # What policy to apply for each exit code, plus a catch-all default. | # What policy to apply for each exit code, plus a catch-all default. | ||
| - | # | + | file_list_1_policy |
| - | # save | + | |
| - | # text message and save the attachment into a local file. | + | |
| - | file_list_1_policy | + | # |
| + | # 2) White list, this extensions (or Content-Type) will be accepted. | ||
| + | #------------------------------------------------------------------------- | ||
| + | file_list_2 | ||
| + | file_list_2 += 7z|ai|ang|an6|asc|bmp|bz2|cl|csv|dat|doc|docx|dwg|dxf|fh|gif|gz|html? | ||
| + | file_list_2 += |jc3|jc4|jc5|jpe? | ||
| + | file_list_2 += |psd|pub|rtf|snp|sxc|tiff? | ||
| + | file_list_2 += )$ | ||
| + | file_list_2_scanner = 0; | ||
| + | file_list_2_policy = accept; | ||
| + | |||
| + | |||
| + | #------------------------------------------------------------------------- | ||
| + | # Default policy: accept, but mangle | ||
| + | # | ||
| + | file_default_policy | ||
| # | # | ||
| Line 55: | Line 147: | ||
| </ | </ | ||
| + | Con la direttiva **file_list_1_scanner** si indica il programma filtro da chiamare - nel notro caso **clamdscan** con l' | ||
| + | |||
| + | La politica da applicare a seguito della scansione è determinata da **file_list_1_policy**. Si devono indicare **quattro possibili azioni** di cui le prime tre corrispondo ai tre esiti della scansione (//clean//, // | ||
| + | |||
| + | Ricapitolando questa è la politica applicata ai file compresi nella **file_list_1**: | ||
| + | |||
| + | ^ Esito scansione | ||
| + | | Clean | 0 | **unknown** (check the next policy). | ||
| + | | Disinfected | ||
| + | | Infected | ||
| + | | Generic error | 2 | **unknown** (check the next policy). | ||
| + | |||
| + | ==== Content-Type ed estensioni per Sanitizer ==== | ||
| + | |||
| + | Nella **file_list_2** vengono indicate delle estensioni per cui l' | ||
| + | |||
| + | Non è del tutto chiaro come avere la corrispondenza tra i due, ad esempio (empiricamente) si è determinato che il Content-Type **application/ | ||
| + | |||
| + | Il riconoscimento del tipo di file viene fatto dalla funzione **check_file_type** del modulo **Anomy:: | ||
| + | |||
| + | Un problema comune con Sanitizer sono le parti del messaggio con MIME type **text/ | ||
| + | |||
| + | Nel sorgente Perl del modulo **FileTypes** si vede che la classificazione di una parte come oggetto di tipo HTML richiede la presenza di una espressione regolare nella parte stessa (la verifica riguarda solo i primi 512 bytes): | ||
| + | |||
| + | <code perl> | ||
| + | my $HTML = { | ||
| + | id => " | ||
| + | risk => $low, | ||
| + | name => "HTML text file", | ||
| + | extensions => [ " | ||
| + | mime_types => [ ' | ||
| + | magic => [ ], | ||
| + | regexp | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | È possibile personalizzare il modulo **FileTypes** definito in **/ | ||
| ===== Cosa succede se clamd è fermo ===== | ===== Cosa succede se clamd è fermo ===== | ||
| Line 64: | Line 193: | ||
| ^ 2 | Could not connect to clamd on LocalSocket. | ^ 2 | Could not connect to clamd on LocalSocket. | ||
| - | Quindi se il demone non risponde | + | Se il demone |
| + | |||
| + | Nella configurazione mostrata sopra la regola successiva prevede di accettare tali e quali gli allegati che corrispondono a **file_list_2** (in pratica documenti allegati non pericolosi), | ||
| + | |||
| + | Una configurazione più stringente potrebbe essere quella di applicare la policy **save** (rimozione dell' | ||
doc/appunti/linux/sa/procmail_sanitizer_clamav.1592306031.txt.gz · Last modified: by niccolo
