Hey everyone,
So, like some, I was using a bit of code I actually got from this forum to peek inside zip files and reject ones containing an executable. The script worked great, but sadly, demime was part of it, and that has been depreciated.
Since then I've been searching for a solution, but my skills in that area are lacking to put it mildly.
Anyway, on a different forum I found a user asking the same question, someone recommended they use P7Zip to accomplish this.
First I created an EPEL repository, got P7zip installed and.... that's where I'm stuck. I'm not sure how to incorporate the following bit of code into Exim's configuration to get it working.
Any help would be appreciated.
Thanks,
Jay
So, like some, I was using a bit of code I actually got from this forum to peek inside zip files and reject ones containing an executable. The script worked great, but sadly, demime was part of it, and that has been depreciated.
Since then I've been searching for a solution, but my skills in that area are lacking to put it mildly.
Anyway, on a different forum I found a user asking the same question, someone recommended they use P7Zip to accomplish this.
First I created an EPEL repository, got P7zip installed and.... that's where I'm stuck. I'm not sure how to incorporate the following bit of code into Exim's configuration to get it working.
P7ZIP = /usr/local/bin/7z
BINFORBIDDEN = Windows-executable attachments forbidden
WINBIN = exe|com|js|pif|scr|bat|flv|reg|btm|chm|cmd|cpl|dat|dll|hta|jse|jsp|lnk|msi|prf|sys|vb|vbe|vbs|ace
COMPREXT = zip|rar|7z|arj|bz2|gz|uue|xz|z
check_rfc2047_length = false
acl_smtp_mime = acl_check_mime
begin acl
acl_check_mime:
deny message = BINFORBIDDEN
log_message = forbidden attachment: filename=$mime_filename, \
content-type=$mime_content_type, recipients=$recipients
condition = ${if or{\
{match{$mime_content_type}\
{(?i)executable|application/x-ace-compressed}}\
{match{$mime_filename}{\N(?i)\.(WINBIN)(\.(COMPREXT))*$\N}}\
}}
deny message = Compressed BINFORBIDDEN
condition = ${if or{\
{match{$mime_content_type}{(?i)application/\
(octet-stream|x(-zip)?-compressed|zip)}}\
{match{$mime_filename}{\N(?i)\.(COMPREXT)$\N}}\
}}
condition = ${if <{$message_size}{1500K}}
decode = default
log_message = forbidden binary in attachment: filename=$mime_filename, \
recipients=$recipients
condition = ${if match{${run{P7ZIP l -y $mime_decoded_filename}}}\
{\N(?i)\n[12].+\.(COMPREXT|WINBIN)\n\N}}
accept
I understand what the above code is doing, but I'm not sure where to add it, like I said. I thought I'd just drop it into "custom_end_exiscanall" but nope. I obviously don't understand Exim as well as I'd like to, and yet I need this functionality.BINFORBIDDEN = Windows-executable attachments forbidden
WINBIN = exe|com|js|pif|scr|bat|flv|reg|btm|chm|cmd|cpl|dat|dll|hta|jse|jsp|lnk|msi|prf|sys|vb|vbe|vbs|ace
COMPREXT = zip|rar|7z|arj|bz2|gz|uue|xz|z
check_rfc2047_length = false
acl_smtp_mime = acl_check_mime
begin acl
acl_check_mime:
deny message = BINFORBIDDEN
log_message = forbidden attachment: filename=$mime_filename, \
content-type=$mime_content_type, recipients=$recipients
condition = ${if or{\
{match{$mime_content_type}\
{(?i)executable|application/x-ace-compressed}}\
{match{$mime_filename}{\N(?i)\.(WINBIN)(\.(COMPREXT))*$\N}}\
}}
deny message = Compressed BINFORBIDDEN
condition = ${if or{\
{match{$mime_content_type}{(?i)application/\
(octet-stream|x(-zip)?-compressed|zip)}}\
{match{$mime_filename}{\N(?i)\.(COMPREXT)$\N}}\
}}
condition = ${if <{$message_size}{1500K}}
decode = default
log_message = forbidden binary in attachment: filename=$mime_filename, \
recipients=$recipients
condition = ${if match{${run{P7ZIP l -y $mime_decoded_filename}}}\
{\N(?i)\n[12].+\.(COMPREXT|WINBIN)\n\N}}
accept
Any help would be appreciated.
Thanks,
Jay