मेरी असफलता के phpMyAdminसाथ अत्यधिक असफल लॉगिन प्रयासों को रोकने की खोज में fail2ban, मैंने एक स्क्रिप्ट बनाई है जिसमें लॉग ने कहा कि फ़ाइल में विफल प्रयास:/var/log/phpmyadmin_auth.log
कस्टम लॉग
/var/log/phpmyadmin_auth.logफ़ाइल का प्रारूप है:
phpMyadmin login failed with username: root; ip: 192.168.1.50; url: http://somedomain.com/phpmyadmin/index.php
phpMyadmin login failed with username: ; ip: 192.168.1.50; url: http://192.168.1.48/phpmyadmin/index.php
कस्टम फ़िल्टर
[Definition]
# Count all bans in the logfile
failregex = phpMyadmin login failed with username: .*; ip: <HOST>;
phpMyAdmin जेल
[phpmyadmin]
enabled = true
port = http,https
filter = phpmyadmin
action = sendmail-whois[name=HTTP]
logpath = /var/log/phpmyadmin_auth.log
maxretry = 6
fail2banलॉग शामिल हैं:
2012-10-04 10:52:22,756 fail2ban.server : INFO Stopping all jails
2012-10-04 10:52:23,091 fail2ban.jail : INFO Jail 'ssh-iptables' stopped
2012-10-04 10:52:23,866 fail2ban.jail : INFO Jail 'fail2ban' stopped
2012-10-04 10:52:23,994 fail2ban.jail : INFO Jail 'ssh' stopped
2012-10-04 10:52:23,994 fail2ban.server : INFO Exiting Fail2ban
2012-10-04 10:52:24,253 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2012-10-04 10:52:24,253 fail2ban.jail : INFO Creating new jail 'ssh'
2012-10-04 10:52:24,253 fail2ban.jail : INFO Jail 'ssh' uses poller
2012-10-04 10:52:24,260 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2012-10-04 10:52:24,260 fail2ban.filter : INFO Set maxRetry = 6
2012-10-04 10:52:24,261 fail2ban.filter : INFO Set findtime = 600
2012-10-04 10:52:24,261 fail2ban.actions: INFO Set banTime = 600
2012-10-04 10:52:24,279 fail2ban.jail : INFO Creating new jail 'ssh-iptables'
2012-10-04 10:52:24,279 fail2ban.jail : INFO Jail 'ssh-iptables' uses poller
2012-10-04 10:52:24,279 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2012-10-04 10:52:24,280 fail2ban.filter : INFO Set maxRetry = 5
2012-10-04 10:52:24,280 fail2ban.filter : INFO Set findtime = 600
2012-10-04 10:52:24,280 fail2ban.actions: INFO Set banTime = 600
2012-10-04 10:52:24,287 fail2ban.jail : INFO Creating new jail 'fail2ban'
2012-10-04 10:52:24,287 fail2ban.jail : INFO Jail 'fail2ban' uses poller
2012-10-04 10:52:24,287 fail2ban.filter : INFO Added logfile = /var/log/fail2ban.log
2012-10-04 10:52:24,287 fail2ban.filter : INFO Set maxRetry = 3
2012-10-04 10:52:24,288 fail2ban.filter : INFO Set findtime = 604800
2012-10-04 10:52:24,288 fail2ban.actions: INFO Set banTime = 604800
2012-10-04 10:52:24,292 fail2ban.jail : INFO Jail 'ssh' started
2012-10-04 10:52:24,293 fail2ban.jail : INFO Jail 'ssh-iptables' started
2012-10-04 10:52:24,297 fail2ban.jail : INFO Jail 'fail2ban' started
जब मैं जारी करता हूं:
sudo service fail2ban restart
fail2banमुझे कहने के लिए ईमेल sshफिर से शुरू हो गए हैं, लेकिन मुझे अपने phpmyadminजेल के बारे में ऐसा कोई ईमेल नहीं मिला है । बार-बार विफल लॉगिन phpMyAdminईमेल भेजने का कारण नहीं बनता है।
क्या मैंने कुछ महत्वपूर्ण सेटअप को याद किया है? क्या मेरे फ़िल्टर की नियमित अभिव्यक्ति गलत है?
अद्यतन: डिफ़ॉल्ट स्थापना से जोड़ा गया परिवर्तन
एक साफ fail2banस्थापना के साथ शुरू :
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
अपना खुद का ईमेल पता बदलें, कार्रवाई करने के लिए:
action = %(action_mwl)s
निम्नलिखित को संलग्न करें jail.local
[phpmyadmin]
enabled = true
port = http,https
filter = phpmyadmin
action = sendmail-whois[name=HTTP]
logpath = /var/log/phpmyadmin_auth.log
maxretry = 4
करने के लिए निम्नलिखित जोड़ें /etc/fail2ban/filter.d/phpmyadmin.conf
# phpmyadmin configuration file
#
# Author: Michael Robinson
#
[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>\S+)
# Values: TEXT
#
# Count all bans in the logfile
failregex = phpMyadmin login failed with username: .*; ip: <HOST>;
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
# Ignore our own bans, to keep our counts exact.
# In your config, name your jail 'fail2ban', or change this line!
ignoreregex =
पुनर्प्रारंभ करें fail2ban
sudo service fail2ban restart
पुनश्च: मुझे अंडे पसंद हैं