[Mimedefang] Blocking .exe file

An.H.Nguyen annguyen251 at hotmail.com
Sat Feb 3 11:44:06 EST 2007


I am unable to block exe attachment file.
Here's the code I started in mimedefang-filter. What else do I need to do?

md_graphdefang_log_enable('mail', 1);

# This procedure returns true for entities with bad filenames.
sub filter_bad_filename ($) {
    my($entity) = @_;
    my($bad_exts, $re);
    # Bad extensions
    $bad_exts =   '(exe|\{[^\}]+\})';
    # Do not allow:
    # - CLSIDs  {foobarbaz}
    # - bad extensions (possibly with trailing dots) at end
    $re = '\.' . $bad_exts . '\.*$';
    return 1 if (re_match($entity, $re));
    return 0;
}

sub filter ($$$$) {
    my($entity, $fname, $ext, $type) = @_;
    return if message_rejected(); # Avoid unnecessary work
    if (filter_bad_filename($entity)) {
        md_graphdefang_log('bad_filename', $fname, $type);
        return action_drop_with_warning("An attachment named $fname was 
removed from this document as it\nconstituted a  security hazard.  If you 
require this document, please contact\nthe sender and arrange an alternate 
means of receiving it.\n");
    }
    return action_accept();
}


Thanks,
An Nguyen 




More information about the MIMEDefang mailing list