Sunteți pe pagina 1din 9

Sumber

https://www.excellent.co.id/product-services/zimbra/implementasi-fail2ban-untuk-meningkatkan-performa-
keamanan-zimbra-mail-server-2/

Implementasi Fail2Ban untuk Meningkatkan Performa &


Keamanan Zimbra Mail Server

Salah satu masalah besar yang dialami oleh para System Administrator
email server adalah serangan spam yang bertubi-tubi. Spam yang datang bisa bervariasi bentuknya, mulai dari upaya
mengakses SMTP relay, brute-force attack password user hingga serangan phising/spoofing. Sistem mail server
yang sudah disetup dengan baik memang mampu menolak serangan ini, namun jika datang bertubi-tubi tentu akan
mengurangi performa sistem mail server.

Untuk mengatasinya, kita dapat meningkatkan kemampuan mail server untuk melakukan proses banned terhadap
upaya spamming yang berulang. Misalnya jika ada upaya relay access yang berulangkali salah atau upaya
authentikasi sistem yang berulangkali gagal dalam interval waktu tertentu, kita bisa memerintahkan sistem untuk
secara otomatis melakukan proses banned.

Salah satu aplikasi yang mudah disetup dan handal untuk keperluan ini adalah aplikasi Fail2Ban. Sesuai namanya,
aplikasi ini menggunakan IPTables untuk melakukan proses banned terhadap kegagalan akses. Fungsinya bukan
hanya sebatas aplikasi SSH seperti yang dilakukan oleh aplikasi Denyhosts, melainkan juga terhadap semua aplikasi
lain yang menggunakan port TCP, seperti SMTP, POP3, IMAP, FTP, Apache dan lain-lain.

Proses integrasi Fail2Ban ke Zimbra relatif tidak terlalu sulit untuk dilakukan. Berikut adalah panduannya, saya set
menggunakan Zimbra yang diinstall diatas sistem SUSE Linux Enterprise Server 11 SP2 (berbasis Minimal Server
Appliance)

1. Instalasi Fail2Ban dan IPtables. Jika menggunakan Minimal Server Appliance, keduanya sudah terinstall.
Jika belum, jalankan perintah berikut :

view sourceprint?

1.zypper ar http://download.opensuse.org/repositories/security/SLE_11/ fail2ban

2.zypper in fail2ban

2. Buat file /etc/fail2ban/filter.d/zimbra.conf. File ini berisi regular expression dari log Zimbra yang akan
memicu proses banned IP jika terjadi beberapa kali dalam interval waktu tertentu. Isi
file /etc/fail2ban/filter.d/zimbra.conf :
view sourceprint?

01.# Fail2Ban configuration file

02.#

03.# Author:

04.#

05.# $Revision: 1 $

06.#

07.

08.[Definition]

09.

10.# Option: failregex

11.# Notes.: regex to match the password failures messages in the logfile. The

12.# host must be matched by a group named "host". The tag "<HOST>" can

13.# be used for standard IP/hostname matching and is only an alias for

14.# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)

15.# Values: TEXT

16.#

17.failregex = \[ip=&lt;HOST&gt;;\] account - authentication failed for .* \(no such account\)$

18.\[ip=&lt;HOST&gt;;\] security - cmd=Auth; .* error=authentication failed for .*, invalid password;$

19.;oip=&lt;HOST&gt;;.* security - cmd=Auth; .* protocol=soap; error=authentication failed for .* invalid


password;$

20.\[oip=&lt;HOST&gt;;.* SoapEngine - handler exception: authentication failed for .*, account not found$

21.WARN .*;ip=&lt;HOST&gt;;ua=ZimbraWebClient .* security - cmd=AdminAuth; .*


error=authentication failed for .*;$

22.NOQUEUE: reject: RCPT from .*\[&lt;HOST&gt;\]: 550 5.1.1 .*: Recipient address rejected:

23.

24.# .*\[ip=<HOST>;\] .* - authentication failed for .* \(invalid password\)


25.#

26.# Option: ignoreregex

27.# Notes.: regex to ignore. If this regex matches, the line is ignored.

28.# Values: TEXT

29.#

30.ignoreregex =

3. Buat/edit file /etc/fail2ban/jail.conf dengan isi sebagai berikut :

view sourceprint?

001.# Fail2Ban configuration file

002.#

003.# Author: Cyril Jaquier

004.#

005.# $Revision: 747 $

006.## The DEFAULT allows a global definition of the options. They can be overridden

007.# in each jail afterwards.

008.[DEFAULT]

009.# "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not

010.# ban a host which matches an address in this list. Several addresses can be

011.# defined using space separator.

012.ignoreip = 127.0.0.1/8 202.43.115.188/32

013.# "bantime" is the number of seconds that a host is banned.

014.bantime = 600

015.# A host is banned if it has generated "maxretry" during the last "findtime"

016.# seconds.

017.findtime = 600
018.

019.# "maxretry" is the number of failures before a host get banned.

020.maxretry = 3

021.

022.# "backend" specifies the backend used to get files modification. Available

023.# options are "gamin", "polling" and "auto". This option can be overridden in

024.# each jail too (use "gamin" for a jail and "polling" for another).

025.#

026.# gamin: requires Gamin (a file alteration monitor) to be installed. If Gamin

027.# is not installed, Fail2ban will use polling.

028.# polling: uses a polling algorithm which does not require external libraries.

029.# auto: will choose Gamin if available and polling otherwise.

030.backend = auto

031.

032.# This jail corresponds to the standard configuration in Fail2ban 0.6.

033.# The mail-whois action send a notification e-mail with a whois request

034.# in the body.

035.

036.[ssh-iptables]

037.

038.enabled = false

039.filter = sshd

040.action = iptables[name=SSH, port=ssh, protocol=tcp]

041.sendmail-whois[name=SSH, dest=zeze@vavai.com, sender=fail2ban@excellent.co.id]

042.logpath = /var/log/messages
043.maxretry = 5

044.

045.# This jail forces the backend to "polling".

046.

047.[sasl-iptables]

048.

049.enabled = false

050.filter = sasl

051.backend = polling

052.action = iptables[name=sasl, port=smtp, protocol=tcp]

053.sendmail-whois[name=sasl, dest=support@excellent.co.id]

054.logpath = /var/log/zimbra.log

055.

056.# Here we use TCP-Wrappers instead of Netfilter/Iptables. "ignoreregex" is

057.# used to avoid banning the user "myuser".

058.

059.[ssh-tcpwrapper]

060.

061.enabled = false

062.filter = sshd

063.action = hostsdeny

064.sendmail-whois[name=SSH, dest=support@excellent.co.id]

065.ignoreregex = for myuser from

066.logpath = /var/log/messages

067.
068.# This jail uses ipfw, the standard firewall on FreeBSD. The "ignoreip"

069.# option is overridden in this jail. Moreover, the action "mail-whois" defines

070.# the variable "name" which contains a comma using "". The characters '' are

071.# valid too.

072.

073.[zimbra-account]

074.enabled = true

075.filter = zimbra

076.action = iptables-allports[name=zimbra-account]

077.sendmail[name=zimbra-account, dest=support@excellent.co.id]

078.logpath = /opt/zimbra/log/mailbox.log

079.bantime = 600

080.maxretry = 5

081.

082.[zimbra-audit]

083.enabled = true

084.filter = zimbra

085.action = iptables-allports[name=zimbra-audit]

086.sendmail[name=Zimbra-audit, dest=support@excellent.co.id]

087.logpath = /opt/zimbra/log/audit.log

088.bantime = 600

089.maxretry = 5

090.

091.[zimbra-recipient]

092.enabled = true
093.filter = zimbra

094.action = iptables-allports[name=zimbra-recipient]

095.sendmail[name=Zimbra-recipient, dest=support@excellent.co.id]

096.logpath = /var/log/zimbra.log

097.#findtime = 604800

098.bantime = 172800

099.maxretry = 5

100.

101.[postfix]

102.enabled = true

103.filter = postfix

104.action = iptables-multiport[name=postfix, port=smtp, protocol=tcp]

105.sendmail-buffered[name=Postfix, dest=support@excellent.co.id]

106.logpath = /var/log/zimbra.log

107.bantime = -1

108.maxretry = 5

109.

110.#[sasl]

111.#enabled = true

112.#port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s

113.#filter = sasl

114.# You might consider monitoring /var/log/warn.log instead

115.# if you are running postfix. See http://bugs.debian.org/507990

116.#logpath = /var/log/zimbra.log

File jail.conf berisi data log file yang hendak dicheck dan alamat email untuk konfirmasi banned. Jangan
lupa mengisi parameter ignoreip untuk memastikan agar akses lokal tidak usah dicheck
4. Edit file /etc/fail2ban/action.d/sendmail.conf dan ganti baris :

view sourceprint?

1.Fail2Ban" | /usr/sbin/sendmail -f &lt;sender&gt; &lt;dest&gt;

Menjadi

view sourceprint?

1.Fail2Ban" | /opt/zimbra/postfix/sbin/sendmail -f &lt;sender&gt; &lt;dest&gt;

5. Setelah selesai semua, lakukan perintah start Fail2Ban

view sourceprint?

1.service fail2ban restart

Setelah fail2ban dipasang, kita akan menerima notifikasi melalui email mengenai IP yang coba-coba melakukan
proses hacking. IP tersebut akan langsung dibanned jika sudah memenuhi syarat sekian kali dalam interval waktu
yang telah didefinisikan. Kita juga bisa memodifikasi fila jail.conf dan file zimbra.conf jika ingin mengecek log-log
lainnya.

Contoh hasil banned yang dikirim ke email :

Karena sangat powerful, Fail2Ban ini bisa dimanfaatkan untuk mengantisipasi serangan semacam bruteforce attack,
baik terhadap email maupun service server lainnya seperti web server, FTP server, database server dan lain-lain.

Sumber

https://www.excellent.co.id/product-services/zimbra/implementasi-fail2ban-untuk-meningkatkan-performa-
keamanan-zimbra-mail-server-2/

S-ar putea să vă placă și