- Added alias "<HOST>" for failregex

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@471 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-11-19 21:25:51 +00:00
parent 911b2b15fc
commit f5d4cb6be2
11 changed files with 50 additions and 24 deletions

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failure messages in the logfile. # Notes.: regex to match the password failure 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.
# Values: TEXT # Values: TEXT
# #
failregex = [[]client (?P<host>\S*)[]] user .*(?:: authentication failure|not found) failregex = [[]client <HOST>[]] user .*(?:: authentication failure|not found)
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failure messages in the logfile. # Notes.: regex to match the password failure 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.
# Values: TEXT # Values: TEXT
# #
failregex = [[]client (?P<host>\S*)[]] File does not exist: .*(\.php|\.asp) failregex = [[]client <HOST>[]] File does not exist: .*(\.php|\.asp)
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -9,10 +9,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = LOGIN FAILED, ip=\[::ffff:(?P<host>\S*)\]$ failregex = LOGIN FAILED, ip=\[<HOST>\]$
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = error,relay=(?:::f{4,6}:)?(?P<host>\S*),.*550 User unknown failregex = error,relay=<HOST>,.*550 User unknown
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = reject: RCPT from (.*)\[(?P<host>\S*)\]: 554 failregex = reject: RCPT from (.*)\[<HOST>\]: 554
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = USER \S+: no such user found from \S* ?\[(?P<host>\S+)\] to \S+\s*$ failregex = USER \S+: no such user found from \S* ?\[<HOST>\] to \S+\s*$
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = (?:[\d,.]+[\d,.] rblsmtpd: |421 badiprbl: ip )(?P<host>\S*) failregex = (?:[\d,.]+[\d,.] rblsmtpd: |421 badiprbl: ip )<HOST>
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = : warning: [-._\w]+\[(?P<host>[.\d]+)\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed$ failregex = : warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed$
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = (?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) (?:::f{4,6}:)?(?P<host>\S*) failregex = (?:(?:Authentication failure|Failed [-/\w+]+) for(?: [iI](?:llegal|nvalid) user)?|[Ii](?:llegal|nvalid) user|ROOT LOGIN REFUSED) .*(?: from|FROM) <HOST>
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -8,10 +8,12 @@
[Definition] [Definition]
# Option: failregex # Option: failregex
# Notes.: regex to match the password failures messages in the logfile. # 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.
# Values: TEXT # Values: TEXT
# #
failregex = vsftpd: \(pam_unix\) authentication failure; .* rhost=(?P<host>\S*) failregex = vsftpd: \(pam_unix\) authentication failure; .* rhost=<HOST>
# Option: ignoreregex # Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored. # Notes.: regex to ignore. If this regex matches, the line is ignored.

View File

@ -167,13 +167,17 @@ class Filter(JailThread):
def setFailRegex(self, value): def setFailRegex(self, value):
try: try:
if value.lstrip() == '': if value.lstrip() == '':
self.__failRegex = value
self.__failRegexObj = None self.__failRegexObj = None
else: else:
self.__failRegexObj = re.compile(value) # Replace "<HOST>" with default regular expression for host.
self.__failRegex = value regex = value.replace("<HOST>", "(?:::f{4,6}:)?(?P<host>\S+)")
logSys.info("Set failregex = %s" % value) self.__failRegex = regex
self.__failRegexObj = re.compile(regex)
logSys.info("Set failregex = %s" % self.__failRegex)
except sre_constants.error: except sre_constants.error:
logSys.error("Unable to compile regular expression " + value) logSys.error("Unable to compile regular expression " +
self.__failRegex)
## ##
# Get the regular expression which matches the failure. # Get the regular expression which matches the failure.
@ -475,6 +479,8 @@ class DNSUtils:
try: try:
return socket.gethostbyname_ex(dns)[2] return socket.gethostbyname_ex(dns)[2]
except socket.gaierror: except socket.gaierror:
logSys.warn("Unable to find a corresponding IP address for %s"
% dns)
return list() return list()
@staticmethod @staticmethod