We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Регулярка для fail2ban, защита админки WP
Регулярка для fail2ban, защита админки WP
Коллеги, нужна ваша помощь по составлению регулярки для файла конфига fail2ban.
Что имеем:
1) Сообщения о неуспешной авторизации пишутся в /var/log/httpd/domains/domain.ru.error.log в виде
2) В файле /etc/fail2ban/filter.d/wordpress-auth.conf написано правило:
3) В jail.local секция:
Но в итоге не работает, чувствую что проблема регулярке, но самостоятельно ее решить, к сожалению, не могу. Надеюсь на вашу помощь.
Что имеем:
1) Сообщения о неуспешной авторизации пишутся в /var/log/httpd/domains/domain.ru.error.log в виде
Code: Select all
[Sat Jun 18 19:20:15.575081 2016] [:error] [pid 6441] [client 5.166.162.172:56291] WP LOGIN FAILED for username: 121221, referer: http://domain.ru/wp-login.php
Code: Select all
[Definition]
failregex = \[*\]. \[*\]. \[*\] .\[client <HOST>\].* WP LOGIN FAILED.*
Code: Select all
[wordpress]
enabled = true
port = http,https
filter = wordpress-auth
logpath = /var/log/httpd/domains/*.error.log
maxretry = 3
bantime = 3600
Code: Select all
root@54161 ~]# fail2ban-regex /var/log/httpd/domains/domain.ru.error.log "\[*\]. \[*\]. \[*\] .\[client <HOST>\].* WP LOGIN FAILED for username:.*"
Running tests
=============
Use failregex line : \[*\]. \[*\]. \[*\] .\[client <HOST>\].* WP LOGIN ...
Use log file : /var/log/httpd/domains/domain.ru.error.log
Use encoding : UTF-8
Results
=======
Failregex: 0 total
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| [141] Year(?P<_sep>[-/.])Month(?P=_sep)Day 24hour:Minute:Second(?:,Microseconds)?
| [141] (?:DAY )?MON Day 24hour:Minute:Second(?:\.Microseconds)?(?: Year)?
`-
Lines: 282 lines, 0 ignored, 0 matched, 282 missed [processed in 0.04 sec]
Missed line(s): too many to print. Use --print-all-missed to print all 282 lines
Re: Регулярка для fail2ban, защита админки WP
А логи fail2ban, без ошибок ?
-
- Posts: 129
- Joined: Tue Mar 08, 2016 8:03 pm
- Os: CentOS 6x
- Web: nginx + php-fpm
Re: Регулярка для fail2ban, защита админки WP
Попробуйте вот так:
Коряво, но возможно сработает. (domain.ru замените на нужный адрес)
Проверить "на местах" можно выполнив один из вариантов:
Code: Select all
\[:error\]\s\[pid\s\d+\]\s\[client\s<HOST>:\d+\]\sWP LOGIN FAILED for username:\s\d+,\sreferer:\shttp:\/\/domain.ru\/wp-login.php
Проверить "на местах" можно выполнив один из вариантов:
Code: Select all
fail2ban-regex путь_к_логу путь_к_фильтру
fail2ban-regex <строка из лога> путь_к_фильтру
fail2ban-regex <строка из лога> <строка регулярного выражения>
Re: Регулярка для fail2ban, защита админки WP
В итоге совместными усилиями найдено решение:
Надеюсь пригодится кому-то еще.
Code: Select all
[Definition]
failregex = \[*.*?\]* \[*.*?\]* \[.*?\]* \[*client <HOST>:\d+\]*.* WP LOGIN FAILED.*