$NetBSD: patch-af,v 1.3 2014/02/04 15:38:16 pettai Exp $ Fix for CVE-2013-6890 (See http://seclists.org/oss-sec/2013/q4/535) Added DSA-2826-2 fix for regression (See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734329) --- DenyHosts/regex.py.orig 2013-12-26 22:46:33.000000000 +0000 +++ DenyHosts/regex.py @@ -6,22 +6,22 @@ import re #DATE_FORMAT_REGEX = re.compile(r"""(?P[A-z]{3,3})\s*(?P\d+)""") -SSHD_FORMAT_REGEX = re.compile(r""".* (sshd.*:|\[sshd\]) (?P.*)""") +SSHD_FORMAT_REGEX = re.compile(r""".*? (sshd.*?:|\[sshd\]) (?P.*)""") #SSHD_FORMAT_REGEX = re.compile(r""".* sshd.*: (?P.*)""") -FAILED_ENTRY_REGEX = re.compile(r"""Failed (?P.*) for (?Pinvalid user |illegal user )?(?P.*?) .*from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})""") +FAILED_ENTRY_REGEX = re.compile(r"""Failed (?P\S*) for (?Pinvalid user |illegal user )?(?P.*) from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})( port \d+)?( ssh2)?$""") -FAILED_ENTRY_REGEX2 = re.compile(r"""(?P(Illegal|Invalid)) user (?P.*?) .*from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})""") +FAILED_ENTRY_REGEX2 = re.compile(r"""(?P(Illegal|Invalid)) user (?P.*) from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$""") -FAILED_ENTRY_REGEX3 = re.compile(r"""Authentication failure for (?P.*) .*from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})""") +FAILED_ENTRY_REGEX3 = None -FAILED_ENTRY_REGEX4 = re.compile(r"""Authentication failure for (?P.*) .*from (?P.*)""") +FAILED_ENTRY_REGEX4 = re.compile(r"""Authentication failure for (?P.*) from (::ffff:)?(?P\S+)$""") -FAILED_ENTRY_REGEX5 = re.compile(r"""User (?P.*) .*from (?P.*) not allowed because none of user's groups are listed in AllowGroups""") +FAILED_ENTRY_REGEX5 = re.compile(r"""User (?P.*) from (::ffff:)?(?P\S+) not allowed because none of user's groups are listed in AllowGroups$""") -FAILED_ENTRY_REGEX6 = re.compile(r"""Did not receive identification string .*from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})""") +FAILED_ENTRY_REGEX6 = re.compile(r"""Did not receive identification string .*from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$""") -FAILED_ENTRY_REGEX7 = re.compile(r"""User (?P.*) not allowed because not listed in AllowUsers""") +FAILED_ENTRY_REGEX7 = re.compile(r"""User (?P.*) from (::ffff:)?(?P\S+) not allowed because not listed in AllowUsers$""") # these are reserved for future versions @@ -42,7 +42,7 @@ for i in FAILED_ENTRY_REGEX_RANGE: FAILED_ENTRY_REGEX_MAP[i] = rx -SUCCESSFUL_ENTRY_REGEX = re.compile(r"""Accepted (?P.*) for (?P.*?) from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})""") +SUCCESSFUL_ENTRY_REGEX = re.compile(r"""Accepted (?P\S+) for (?P.*?) from (::ffff:)?(?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$""") TIME_SPEC_REGEX = re.compile(r"""(?P\d*)\s*(?P[smhdwy])?""")