192 |
- |
1 |
# Fail2Ban filter for asterisk authentication failures
|
|
|
2 |
#
|
|
|
3 |
|
|
|
4 |
[INCLUDES]
|
|
|
5 |
|
|
|
6 |
# Read common prefixes. If any customizations available -- read them from
|
|
|
7 |
# common.local
|
|
|
8 |
before = common.conf
|
|
|
9 |
|
|
|
10 |
[Definition]
|
|
|
11 |
|
|
|
12 |
_daemon = asterisk
|
|
|
13 |
|
|
|
14 |
__pid_re = (?:\s*\[\d+\])
|
|
|
15 |
|
|
|
16 |
iso8601 = \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[+-]\d{4}
|
|
|
17 |
|
|
|
18 |
# All Asterisk log messages begin like this:
|
|
|
19 |
log_prefix= (?:NOTICE|SECURITY|WARNING)%(__pid_re)s:?(?:\[C-[\da-f]*\])?:? [^:]+:\d*(?:(?: in)? [^:]+:)?
|
|
|
20 |
|
|
|
21 |
prefregex = ^%(__prefix_line)s%(log_prefix)s <F-CONTENT>.+</F-CONTENT>$
|
|
|
22 |
|
|
|
23 |
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)$
|
|
|
24 |
^Call from '[^']*' \(<HOST>:\d+\) to extension '[^']*' rejected because extension not found in context
|
|
|
25 |
^(?:Host )?<HOST> (?:failed (?:to authenticate\b|MD5 authentication\b)|tried to authenticate with nonexistent user\b)
|
|
|
26 |
^No registration for peer '[^']*' \(from <HOST>\)$
|
|
|
27 |
^hacking attempt detected '<HOST>'$
|
|
|
28 |
^SecurityEvent="(?:FailedACL|InvalidAccountID|ChallengeResponseFailed|InvalidPassword)"(?:(?:,(?!RemoteAddress=)\w+="[^"]*")*|.*?),RemoteAddress="IPV[46]/[^/"]+/<HOST>/\d+"(?:,(?!RemoteAddress=)\w+="[^"]*")*$
|
|
|
29 |
^"Rejecting unknown SIP connection from <HOST>(?::\d+)?"$
|
|
|
30 |
^Request (?:'[^']*' )?from '(?:[^']*|.*?)' failed for '<HOST>(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\s*$
|
|
|
31 |
|
|
|
32 |
# FreePBX (todo: make optional in v.0.10):
|
|
|
33 |
# ^(%(__prefix_line)s|\[\]\s*WARNING%(__pid_re)s:?(?:\[C-[\da-f]*\])? )[^:]+: Friendly Scanner from <HOST>$
|
|
|
34 |
|
|
|
35 |
ignoreregex =
|
|
|
36 |
|
|
|
37 |
datepattern = {^LN-BEG}
|
|
|
38 |
|
|
|
39 |
# Author: Xavier Devlamynck / Daniel Black
|
|
|
40 |
#
|
|
|
41 |
# General log format - main/logger.c:ast_log
|
|
|
42 |
# Address format - ast_sockaddr_stringify
|
|
|
43 |
#
|
|
|
44 |
# First regex: channels/chan_sip.c
|
|
|
45 |
#
|
|
|
46 |
# main/logger.c:ast_log_vsyslog - "in {functionname}:" only occurs in syslog
|
|
|
47 |
|
|
|
48 |
journalmatch = _SYSTEMD_UNIT=asterisk.service
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
[lt_journal]
|
|
|
52 |
|
|
|
53 |
# asterisk can log timestamp if logs into systemd-journal (optional part matching this timestamp, gh-2383):
|
|
|
54 |
__extra_timestamp = (?:\[[^\]]+\]\s+)?
|
|
|
55 |
__prefix_line = %(known/__prefix_line)s%(__extra_timestamp)s
|