Exim İçin Gelişmiş Attachment (Ek) Filtresi: Zararlı Dosya Uzantılarını Daha Güvenli Şekilde Engelleyin
Kurumsal ya da bireysel olarak kendi whm e-posta sunucunuzda Exim kullanıyor ve zararlı ekleri (ör: .exe, .iso, .vbs, .js, .bat) engellemek istiyorsanız, aşağıda paylaştığım gelişmiş Exim attachment filtresi ile güvenliğinizi ciddi oranda artırabilirsiniz.
Neden Böyle Bir Filtre Kullanmalısınız?
- Son yıllarda, zararlı yazılımlar genellikle e-posta ekleri ile yayılıyor.
- Sadece .exe değil, birçok farklı tehlikeli dosya uzantısı spam ve zararlı yazılım yaymak için kullanılıyor.
- Klasik Exim filtreleri yetersiz kalıyor; bu gelişmiş filtre ile çok daha geniş bir uzantı listesi engellenir.
- Çalışanlarınız ve şirket verileriniz için ekstra bir güvenlik katmanı sağlar.
Exim Zararlı Ekleri Engelleme Filtresi (Güncel Kod)
/usr/local/cpanel/etc/exim/sysfilter/options dizinine “ek_filtresi” adinda bir dosya açın notepad ile kodları buraya kopyalayın.
## -----------------------------------------------------------------------
# Potansiyel olarak zararlı dosya uzantılarını kontrol et
# Icerik tipi basligini kontrol et ve belirli dosya uzantilarini engelle
# Alinan dosya uzantilari: .001, .002, .003, ..., .iso
if $header_content-type: matches "(?:file)?name=(\"[^\"]+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|r00|bz2|z|arj|eml|bz|uu|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]|001|002|003|004|005|006|007|008|009|r01|r02|r03|r04|r05|r06|r07|r08|r09|r10|7z|html|tar|gz|bz2|xz|z|ace|arc|cab|lz|lzma|tgz|tbz|tz|tar.gz|tar.bz2|.z|tar.xz|dmg|iso)\")"
then
# Mesaji reddet ve bilgilendirici mesaj gonder
fail text "Bu mesaj, icinde potansiyel olarak calistirilebilir icerik bulunan\n\
$1 dosyasina sahip oldugu icin reddedildi.\n\
Bu tur ekler, son zamanlarda virüsler veya diger zararlilara\n\
sebep olan dosya turleridir.\n\
Eger bu dosyayi gondermeyi amacliyorsaniz, lutfen\n\
dosyayi bir zip dosyasi olarak paketleyip yeniden gonderin."
seen finish
endif
# Ayni kontrolu, alintilanmamis dosya adlari icin yap
if $header_content-type: matches "(?:file)?name=(\\\\S+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|r00|bz2|z|arj|eml|bz|uu|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]|001|002|003|004|005|006|007|008|009|r01|r02|r03|r04|r05|r06|r07|r08|r09|r10|7z|html|tar|gz|bz2|xz|z|ace|arc|cab|lz|lzma|tgz|tbz|tz|tar.gz|.z|tar.bz2|tar.xz|dmg|iso))([\\\\s;]|\\$)"
then
fail text "Bu mesaj, icinde potansiyel olarak calistirilebilir icerik bulunan\n\
$1 dosyasina sahip oldugu icin reddedildi.\n\
Bu tur ekler, son zamanlarda virüsler veya diger zararlilara\n\
sebep olan dosya türleridir.\n\
Eger bu dosyayi gondermeyi amacliyorsaniz, lutfen\n\
dosyayi bir zip dosyasi olarak paketleyip yeniden gonderin."
seen finish
endif
## -----------------------------------------------------------------------
# VBS eklentilerini yakalamaya calis
# ILOVEYOU virüsleri ve benzeri zararlilar icin kullanilan bir yontemdir
# Alintilanmis dosya adi icin kontrol
if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w-]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[0-7]{3,4}(?>\\\\s+))(\"[^\"]+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|r00|bz2|z|arj|eml|bz|uu|z|7z|html|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]|.z|001|002|003|004|005|006|007|008|009|r01|r02|r03|r04|r05|r06|r07|r08|r09|r10|7z|tar|gz|bz2|xz|z|ace|arc|cab|lz|lzma|tgz|tbz|tz|tar.gz|tar.bz2|tar.xz|dmg|iso)\")[\\\\s;]"
then
fail text "Bu mesaj, icinde potansiyel olarak calistirilebilir icerik bulunan\n\
$1 dosyasina sahip oldugu icin reddedildi.\n\
Bu tur ekler, son zamanlarda virüsler veya diger zararlilara\n\
sebep olan dosya turleridir.\n\
Eger bu dosyayi gondermeyi amacliyorsaniz, lutfen\n\
dosyayi bir zip dosyasi olarak paketleyip yeniden gonderin."
seen finish
endif
# Alintilanmamis dosya adi icin ayni kontrolu yap
if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w-]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[0-7]{3,4}(?>\\\\s+))(\\\\S+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|r00|bz2|z|arj|eml|bz|uu|z|7z|exe|hlp|html|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]|.z|001|002|003|004|005|006|007|008|009|r01|r02|r03|r04|r05|r06|r07|r08|r09|r10|7z|tar|gz|bz2|xz|z|ace|arc|cab|lz|lzma|tgz|tbz|tz|tar.gz|tar.bz2|tar.xz|dmg|iso))[\\\\s;]"
then
fail text "Bu mesaj, icinde potansiyel olarak calistirilebilir icerik bulunan\n\
$1 dosyasina sahip oldugu icin reddedildi.\n\
Bu tur ekler, son zamanlarda virüsler veya diger zararlilara\n\
sebep olan dosya turleridir.\n\
Eger bu dosyayi gondermeyi amacliyorsaniz, lutfen\n\
dosyayi bir zip dosyasi olarak paketleyip yeniden gonderin."
seen finish
endif
## -----------------------------------------------------------------------
#### Version history
#
# 0.01 5 May 2000
# Initial release
# 0.02 8 May 2000
# Widened list of content-types accepted, added WSF extension
# 0.03 8 May 2000
# Embedded the install notes in for those that don't do manuals
# 0.04 9 May 2000
# Check global content-type header. Efficiency mods to REs
# 0.05 9 May 2000
# More minor efficiency mods, doc changes
# 0.06 20 June 2000
# Added extension handling - thx to Douglas Gray Stephens & Jeff Carnahan
# 0.07 19 July 2000
# Latest MS Outhouse bug catching
# 0.08 19 July 2000
# Changed trigger length to 80 chars, fixed some spelling
# 0.09 29 September 2000
# More extensions... its getting so we should just allow 2 or 3 through
# 0.10 18 January 2001
# Removed exclusion for error messages - this is a little nasty
# since it has other side effects, hence we do still exclude
# on unix like error messages
# 0.11 20 March, 2001
# Added CMD extension, tidied docs slightly, added RCS tag
# ** Missed changing version number at top of file :-(
# 0.12 10 May, 2001
# Added HTA extension
# 0.13 22 May, 2001
# Reformatted regexps and code to build them so that they are
# shorter than the limits on pre exim 3.20 filters. This will
# make them significantly less efficient, but I am getting so
# many queries about this that requiring 3.2x appears unsupportable.
# 0.14 15 August,2001
# Added .lnk extension - most requested item :-)
# Reformatted everything so its now built from a set of short
# library files, cutting down on manual duplication.
# Changed \w in filename detection to . - dodges locale problems
# Explicit application of GPL after queries on license status
# 0.15 17 August, 2001
# Changed the . in filename detect to \S (stops it going mad)
# 0.16 19 September, 2001
# Pile of new extensions including the eml in current use
# 0.17 19 September, 2001
# Syntax fix
#
#### Install Notes
#
# Exim filters run the exim filter language - a very primitive
# scripting language - in place of a user .forward file, or on
# a per system basis (on all messages passing through).
# The filtering capability is documented in the main set of manuals
# a copy of which can be found on the exim web site
# http://www.exim.org/
#
# To install, copy the filter file (with appropriate permissions)
# to /etc/exim/system_filter.exim and add to your exim config file
# [location is installation depedant - typicaly /etc/exim/config ]
# in the first section the line:-
# message_filter = /etc/exim/system_filter.exim
# message_body_visible = 5000
#
# You may also want to set the message_filter_user & message_filter_group
# options, but they default to the standard exim user and so can
# be left untouched. The other message_filter_* options are only
# needed if you modify this to do other functions such as deliveries.
# The main exim documentation is quite thorough and so I see no need
# to expand it here...
#
# Any message that matches the filter will then be bounced.
# If you wish you can change the error message by editing it
# in the section above - however be careful you don't break it.
#
# After install exim should be restarted - a kill -HUP to the
# daemon will do this.
#
#### LIMITATIONS
#
# This filter tries to parse MIME with a regexp... that doesn't
# work too well. It will also only see the amount of the body
# specified in message_body_visible
#
#### BASIS
#
# The regexp that is used to pickup MIME/uuencoded body parts with
# quoted filenames is replicated below (in perl format).
# You need to remember that exim converts newlines to spaces in
# the message_body variable.
#
# (?:Content- # start of content header
# (?:Type: (?>\s*) # rest of c/t header
# [\w-]+/[\w-]+ # content-type (any)
# |Disposition: (?>\s*) # content-disposition hdr
# attachment) # content-disposition
# ;(?>\s*) # ; space or newline
# (?:file)?name= # filename=/name=
# |begin (?>\s+) [0-7]{3,4} (?>\s+)) # begin octal-mode
# (\"[^\"]+\. # quoted filename.
# (?:ad[ep] # list of extns
# |ba[st]
# |chm
# |cmd
# |com
# |cpl
# |crt
# |eml
# |exe
# |hlp
# |hta
# |in[fs]
# |isp
# |jse?
# |lnk
# |md[be]
# |ms[cipt]
# |pcd
# |pif
# |reg
# |scr
# |sct
# |shs
# |url
# |vb[se]
# |ws[fhc])
# \" # end quote
# ) # end of filename capture
# [\s;] # trailing ;/space/newline
#
#
### [End]
/usr/local/cpanel/etc/exim/sysfilter/options dizinine “ek_filtresi” adinda bir dosya açın notepad ile kodları buraya kopyalayın.
Exim’i yeniden başlatın ve zararlı ekler göndererek sisteminizi test edin.
Bir sonraki yazımızda görüşmek üzere