![Fail2ban이 SMTP 비밀번호 무차별 대입 공격을 포착하지 못함](https://rvso.com/image/1554872/Fail2ban%EC%9D%B4%20SMTP%20%EB%B9%84%EB%B0%80%EB%B2%88%ED%98%B8%20%EB%AC%B4%EC%B0%A8%EB%B3%84%20%EB%8C%80%EC%9E%85%20%EA%B3%B5%EA%B2%A9%EC%9D%84%20%ED%8F%AC%EC%B0%A9%ED%95%98%EC%A7%80%20%EB%AA%BB%ED%95%A8.png)
스패머가 내 서버에서 무차별 암호 추측 공격을 실행하고 있습니다(Debian의 경우 postfix). 그들은 이미 두 명의 사용자 비밀번호를 추측하고 내 서버를 사용하여 스팸을 보내기 시작했습니다. 비밀번호가 변경되고 공격이 완화되었지만(현재로서는) 완전히 차단하고 싶습니다.
Fail2ban을 설치했는데 어떤 이유로 공격을 감지하지 못했습니다.
/etc/fail2ban/fail.conf
다음을 포함합니다:
[sasl]
enabled = true
port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
filter = sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
#logpath = /var/log/mail.log
logpath = /var/log/mail.warn
/etc/fail2ban/filter.d/sasl.conf
다음을 포함합니다:
# Fail2Ban configuration file
#
# Author: Yaroslav Halchenko
#
# $Revision$
#
[Definition]
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. 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>[\w\-.^_]+)
# Values: TEXT
#
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
에서 필터를 실행하면 /var/log/mail.warn
결과가 생성됩니다.
# fail2ban-regex /var/log/mail.warn '(?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$'
Running tests
=============
Use regex line : (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|P...
Use log file : /var/log/mail.warn
Results
=======
Failregex
|- Regular expressions:
| [1] (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$
|
`- Number of matches:
[1] 15293 match(es)
Ignoreregex
|- Regular expressions:
|
`- Number of matches:
Summary
=======
Addresses found:
[1]
123.169.7.222 (Sun Feb 25 06:40:18 2018)
123.169.7.222 (Sun Feb 25 06:40:21 2018)
...
185.173.176.157 (Fri Mar 02 10:12:46 2018)
185.173.176.157 (Fri Mar 02 10:13:15 2018)
185.173.176.157 (Fri Mar 02 10:13:43 2018)
185.173.176.157 (Fri Mar 02 10:14:11 2018)
185.173.176.157 (Fri Mar 02 10:14:41 2018)
185.173.176.157 (Fri Mar 02 10:15:13 2018)
185.173.176.157 (Fri Mar 02 10:15:42 2018)
185.173.176.157 (Fri Mar 02 10:16:13 2018)
185.173.176.157 (Fri Mar 02 10:16:42 2018)
185.173.176.157 (Fri Mar 02 10:17:10 2018)
Date template hits:
34294 hit(s): MONTH Day Hour:Minute:Second
0 hit(s): WEEKDAY MONTH Day Hour:Minute:Second Year
0 hit(s): WEEKDAY MONTH Day Hour:Minute:Second
0 hit(s): Year/Month/Day Hour:Minute:Second
0 hit(s): Day/Month/Year Hour:Minute:Second
0 hit(s): Day/Month/Year Hour:Minute:Second
0 hit(s): Day/MONTH/Year:Hour:Minute:Second
0 hit(s): Month/Day/Year:Hour:Minute:Second
0 hit(s): Year-Month-Day Hour:Minute:Second
0 hit(s): Year.Month.Day Hour:Minute:Second
0 hit(s): Day-MONTH-Year Hour:Minute:Second[.Millisecond]
0 hit(s): Day-Month-Year Hour:Minute:Second
0 hit(s): TAI64N
0 hit(s): Epoch
0 hit(s): ISO 8601
0 hit(s): Hour:Minute:Second
0 hit(s): <Month/Day/Year@Hour:Minute:Second>
Success, the total number of match is 15293
However, look at the above section 'Running tests' which could contain important
information.
그럼에도 불구하고 /var/log/fail2ban.log
문제가 되는 IP 주소를 차단하는 것은 표시되지 않습니다.
업데이트
제안에 따라 로그 수준을 높였습니다. 이는 다음을 보여줍니다.
2018-03-02 12:47:55,920 fail2ban.filter : DEBUG Processing line with time:1519986602.0 and ip:185.173.176.157
2018-03-02 12:47:55,920 fail2ban.filter : DEBUG Ignore line since time 1519986602.0 < 1519987675.92 - 600
2018-03-02 12:47:55,920 fail2ban.filter : DEBUG Processing line with time:1519986635.0 and ip:185.173.176.157
2018-03-02 12:47:55,920 fail2ban.filter : DEBUG Ignore line since time 1519986635.0 < 1519987675.92 - 600
Jail.conf에는 다음이 포함됩니다.
bantime = 600
maxretry = 3
답변1
Ignore line since time 1519986602.0 < 1519987675.92 - 600
로그 기록 에서문서, 나는 그것이 옵션 600
의 가치라고 생각합니다 findtime
. 즉, 특정 IP로부터의 크랙 시도는 보다 큰 진전을 보이는 것처럼 보이 findtime
므로 에 의해 무시됩니다 fail2ban
.
1519987675.92-1519986602.0
1073.92
약 18분 정도 입니다 .
완벽한 솔루션은 인터넷 연결 인터페이스에서 TLS 사용을 의무화하고 클라이언트가 제시한 인증서가 신뢰할 수 있는 CA에서 발행되었는지 확인하도록 의무화하는 것입니다.