2013-10-30 13:02:59 +00:00
# Fail2Ban filter for asterisk authentication failures
2012-01-11 15:35:40 +00:00
#
2012-02-28 16:28:06 +00:00
2014-03-13 22:03:27 +00:00
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
2012-01-11 15:35:40 +00:00
[Definition]
2014-03-13 22:03:27 +00:00
_daemon = asterisk
2013-10-30 13:02:59 +00:00
__pid_re = (?:\[\d+\])
2015-05-24 07:46:11 +00:00
iso8601 = \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[+-]\d{4}
2013-10-30 13:02:59 +00:00
# All Asterisk log messages begin like this:
2016-08-22 10:55:03 +00:00
log_prefix= (?:NOTICE|SECURITY|WARNING)%(__pid_re)s:?(?:\[C-[\da-f]*\])? [^:]+:\d*(?:(?: in)? \w+:)?
2016-05-17 09:54:08 +00:00
2017-02-21 14:54:59 +00:00
prefregex = ^%(__prefix_line)s%(log_prefix)s <F-CONTENT>.+</F-CONTENT>$
failregex = ^Registration from '[^']*' failed for '<HOST>(:\d+)?' - (Wrong password|Username/auth name mismatch|No matching peer found|Not a local domain|Device does not match ACL|Peer is not supposed to register|ACL error \(permit/deny\)|Not a local domain)$
^Call from '[^']*' \(<HOST>:\d+\) to extension '[^']*' rejected because extension not found in context
^Host <HOST> failed to authenticate as '[^']*'$
^No registration for peer '[^']*' \(from <HOST>\)$
^Host <HOST> failed MD5 authentication for '[^']*' \([^)]+\)$
^Failed to authenticate (user|device) [^@]+@<HOST>\S*$
^hacking attempt detected '<HOST>'$
^SecurityEvent="(FailedACL|InvalidAccountID|ChallengeResponseFailed|InvalidPassword)",EventTV="([\d-]+|%(iso8601)s)",Severity="[\w]+",Service="[\w]+",EventVersion="\d+",AccountID="(\d*|<unknown>)",SessionID=".+",LocalAddress="IPV[46]/(UDP|TCP|WS)/[\da-fA-F:.]+/\d+",RemoteAddress="IPV[46]/(UDP|TCP|WS)/<HOST>/\d+"(,Challenge="[\w/]+")?(,ReceivedChallenge="\w+")?(,Response="\w+",ExpectedResponse="\w*")?(,ReceivedHash="[\da-f]+")?(,ACLName="\w+")?$
^"Rejecting unknown SIP connection from <HOST>"$
^Request (?:'[^']*' )?from '[^']*' failed for '<HOST>(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\s*$
2016-07-08 09:44:16 +00:00
2012-01-11 15:35:40 +00:00
ignoreregex =
2013-05-14 11:04:11 +00:00
2016-10-05 17:34:21 +00:00
datepattern = {^LN-BEG}
2013-05-14 11:04:11 +00:00
2014-03-13 22:03:27 +00:00
# Author: Xavier Devlamynck / Daniel Black
#
# General log format - main/logger.c:ast_log
# Address format - ast_sockaddr_stringify
#
# First regex: channels/chan_sip.c
#
# main/logger.c:ast_log_vsyslog - "in {functionname}:" only occurs in syslog