# Fail2Ban filter for asterisk authentication failures # [INCLUDES] # Read common prefixes. If any customizations available -- read them from # common.local before = common.conf [Definition] _daemon = asterisk __pid_re = (?:\[\d+\]) iso8601 = \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[+-]\d{4} # All Asterisk log messages begin like this: log_prefix= (?:NOTICE|SECURITY|WARNING)%(__pid_re)s:?(?:\[C-[\da-f]*\])? [^:]+:\d*(?:(?: in)? \w+:)? failregex = NOTICE.* Failed to authenticate device .* at '(:[0-9]{1,5})?'$ NOTICE.* .*: Registration from '.*' failed for '' - Wrong password$ NOTICE.* .*: Registration from '.*' failed for '' - No matching peer found$ NOTICE.* .*: Registration from '.*' failed for '' - Username/auth name mismatch$ NOTICE.* .*: Registration from '.*' failed for '' - Device does not match ACL$ NOTICE.* .*: Registration from '.*' failed for '' - Peer is not supposed to register$ NOTICE.* .*: Registration from '.*' failed for '' - Wrong password$ NOTICE.* .*: Registration from '.*' failed for '' - No matching peer found$ NOTICE.* .*: Registration from '.*' failed for '' - Username/auth name mismatch$ NOTICE.* .*: Registration from '.*' failed for '' - Device does not match ACL$ NOTICE.* .*: Registration from '.*' failed for '' - Peer is not supposed to register$ #NOTICE.* failed to authenticate as '.*'$ NOTICE.* .*: No registration for peer '.*' \(from \)$ NOTICE.* .*: Host failed MD5 authentication for '.*' (.*)$ NOTICE.* .*: Failed to authenticate user .*@.*$ NOTICE.* .*: Call from '.?' \(:.*\) to extension '.*' rejected$ NOTICE.* .*: Registration from '.*' failed for ':.*' - Wrong password NOTICE.* .*: Registration from '.*' failed for ':.*' - No matching peer found NOTICE.* .*: Registration from '.*' failed for ':.*' - No matching peer found NOTICE.* .*: Registration from '.*' failed for ':.*' - Username/auth name mismatch NOTICE.* .*: Registration from '.*' failed for ':.*' - Device does not match ACL NOTICE.* .*: Registration from '.*' failed for ':.*' - Peer is not supposed to register NOTICE.* .*: Registration from '.*' failed for ':.*' - ACL error (permit/deny) NOTICE.* .*: Registration from '.*' failed for ':.*' - Device does not match ACL NOTICE.* .*: Registration from '\".*\".*' failed for ':.*' - No matching peer found NOTICE.* .*: Registration from '\".*\".*' failed for ':.*' - Wrong password #NOTICE.* failed to authenticate as '.*'$ NOTICE.* .*: No registration for peer '.*' \(from \) NOTICE.* .*: Host failed MD5 authentication for '.*' (.*) NOTICE.* .*: Failed to authenticate user .*@.* NOTICE.* .*: failed to authenticate as '.*' NOTICE.* .*: tried to authenticate with nonexistent user '.*' #VERBOSE.*SIP/-.*Received incoming SIP connection from unknown peer SECURITY.* SecurityEvent="FailedACL".*RemoteAddress=".+?/.+?//.+?".* SECURITY.* SecurityEvent="InvalidAccountID".*RemoteAddress=".+?/.+?//.+?".* SECURITY.* SecurityEvent="ChallengeResponseFailed".*RemoteAddress=".+?/.+?//.+?".* SECURITY.* SecurityEvent="InvalidPassword".*RemoteAddress=".+?/.+?//.+?".* ^%(__prefix_line)s%(log_prefix)s Registration from '[^']*' failed for '(:\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)$ ^%(__prefix_line)s%(log_prefix)s Call from '[^']*' \(:\d+\) to extension '[^']*' rejected because extension not found in context ^%(__prefix_line)s%(log_prefix)s Host failed to authenticate as '[^']*'$ ^%(__prefix_line)s%(log_prefix)s No registration for peer '[^']*' \(from \)$ ^%(__prefix_line)s%(log_prefix)s Host failed MD5 authentication for '[^']*' \([^)]+\)$ ^%(__prefix_line)s%(log_prefix)s Failed to authenticate (user|device) [^@]+@\S*$ ^%(__prefix_line)s%(log_prefix)s hacking attempt detected ''$ ^%(__prefix_line)s%(log_prefix)s SecurityEvent="(FailedACL|InvalidAccountID|ChallengeResponseFailed|InvalidPassword)",EventTV="([\d-]+|%(iso8601)s)",Severity="[\w]+",Service="[\w]+",EventVersion="\d+",AccountID="(\d*|)",SessionID=".+",LocalAddress="IPV[46]/(UDP|TCP|WS)/[\da-fA-F:.]+/\d+",RemoteAddress="IPV[46]/(UDP|TCP|WS)//\d+"(,Challenge="[\w/]+")?(,ReceivedChallenge="\w+")?(,Response="\w+",ExpectedResponse="\w*")?(,ReceivedHash="[\da-f]+")?(,ACLName="\w+")?$ ^%(__prefix_line)s%(log_prefix)s "Rejecting unknown SIP connection from "$ ^%(__prefix_line)s%(log_prefix)s Request (?:'[^']*' )?from '[^']*' failed for '(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\s*$ ignoreregex = # 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