Cấu hình

Một phần của tài liệu bảo mật hệ thống call center (Trang 142 - 177)

2

5.3.2.2Cấu hình

Cấu hình file asterisk.conf

Sau khi cài đặt fail2ban, tạo một tập tin có tên asterisk.conf trong thư mục fail2ban filters bằng lệnh:

# /etc/fail2ban/filter.d/asterisk.conf

Bây giờ thêm những phần sau đây vào tập tin vừa tạo: # Fail2Ban configuration file

CHƯƠNG 5: DEMO BẢO MẬT HỆ THỐNG

#

# $Revision: 250 $ #

[INCLUDES]

# Read common prefixes. If any customizations available -- read them from # common.local

#before = common.conf

[Definition]

#_daemon = asterisk

# Option: failregex

# Notes.: regex to match the password failures messages in the logfilẹ The # host must be matched by a group named "host". The tag "<HOST>" can # be used for standard IP/hostname matching and is only an alias for # (?:::f{4,6}:)?(?P<host>\S+)

# Values: TEXT #

failregex = NOTICẸ*.*: Registration from '.*' failed for '<HOST>' - Wrong password

NOTICẸ*.*: Registration from '.*' failed for '<HOST>' - No matching peer found NOTICẸ*.*: Registration from '.*' failed for '<HOST>' - Username/auth name mismatch

NOTICẸ*.*: Registration from '.*' failed for '<HOST>' - Device does not match ACL

NOTICẸ* <HOST> failed to authenticate as '.*'$

NOTICẸ*.*: No registration for peer '.*' \(from <HOST>\)

NOTICẸ*.*: Host <HOST> failed MD5 authentication for '.*' (.*) NOTICẸ*.*: Failed to authenticate user.*@<HOST>.*

# Option: ignoreregex

# Notes.: regex to ignorẹ If this regex matches, the line is ignored. # Values: TEXT

#

ignoreregex =

Trong dòng trên bạn có thể thấy rằng fail2ban sẽ tìm cụm từ: “Wrong password”, “No matching peer found”, “Username/auth name mismatch” and “Device does not match ACL”

CHƯƠNG 5: DEMO BẢO MẬT HỆ THỐNG

Hình 5. 34: Cấu hình asterisk.conf

Cấu hình file jail.conf

Tiếp theo thêm những dòng sau trong

# / etc/fail2ban/jail.conf (adsbygoogle = window.adsbygoogle || []).push({});

[asterisk-iptables] enabled = true filter = asterisk

action = iptables-allports[name=ASTERISK, port=all, protocol=all]

sendmail-whois[name=ASTERISK, dest=root, sender=fail2ban@examplẹorg] logpath = /var/log/asterisk/messages ignoreip = 192.168.1.(máy chủ) 192.168.1.39 maxretry = 3 bantime = 18000 [ssh] enabled = true port = ssh filter = sshd logpath = /var/log/auth.log maxretry = 3

CHƯƠNG 5: DEMO BẢO MẬT HỆ THỐNG [ssh-đos] enabled = true port = ssh filter = sshd-đos logpath = /var/log/auth.log maxretry = 3

Hình 5. 35: Cấu hình file jail.conf

Cấu hình file logger.conf để Asterisk ngày đăng nhập và định dạng thời gian

Dùng lệnh

# /etc/asterisk/logger.conf

Và thêm phần sau đây trước phần [logfiles]. Điều này làm cho ngày và thời gian

được định dạng Năm-tháng-ngày giờ:phút [general]

dateformat=%F %T

Sau đó tải lại các mô-đun logger cho Asterisk, tại dòng lệnh nhập vào lệnh sau đây:

asterisk -rx "logger reload"

Bật và kiểm tra Fail2ban, Iptables

Bật Iptables

# /etc/init.d/iptables start

Bật Fail2ban

# /etc/init.d/fail2ban start

CHƯƠNG 5: DEMO BẢO MẬT HỆ THỐNG

# iptables -L -v

You should see something like the following for the INPUT chain (you will see more if you have other Fail2Ban filters enabled):

Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination

2104K 414M fail2ban-ASTERISK all — any any anywhere anywhere

If you do not seem something similar to that then you have some troubleshooting to, check out /var/log/fail2ban.log

Bật lên

# update-rc.d iptables defaults # update-rc.d fail2ban defaults

CHƯƠNG 6: KẾT QUẢ DEMO BẢO MẬT HỆ THỐNG

CHƯƠNG 6: KT QU DEMO BO MT H THNG

Một phần của tài liệu bảo mật hệ thống call center (Trang 142 - 177)