Skip to content

Commit 74981e4

Browse files
authored
Merge pull request fail2ban#3254 from evanlinde/master
New filter for XRDP
2 parents ef65652 + 4545382 commit 74981e4

5 files changed

Lines changed: 79 additions & 2 deletions

File tree

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ ver. 1.1.1-dev-1 (20??/??/??) - development nightly edition
116116
* `filter.d/openvpn.conf` - new filter and jail for openvpn recognizing failed TLS handshakes (gh-2702)
117117
* `filter.d/sendmail-reject.conf` - also recognize "Domain of sender address ... does not resolve" (gh-4035)
118118
* `filter.d/vaultwarden.conf` - new filter and jail for Vaultwarden (gh-3979)
119+
* `filter.d/xrdp.conf` - new filter for XRDP, an open source RDP server (gh-3254)
119120
* `fail2ban-regex` extended with new option `-i` or `--invert` to output not-matched lines by `-o` or `--out` (gh-4001)
120121

121122

config/filter.d/xrdp.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Fail2Ban filter for XRDP
3+
#
4+
# Detects login attempts with invalid credentials
5+
#
6+
# Requirements:
7+
# - xrdp >= 0.9.19
8+
# - The log level in sesman.ini should be set to `INFO` or higher
9+
# to emit the log messages needed for this filter.
10+
#
11+
# Author: Evan Linde
12+
#
13+
14+
[INCLUDES]
15+
16+
# Read common prefixes. If any customizations available -- read them from
17+
# common.local
18+
before = common.conf
19+
20+
21+
[DEFAULT]
22+
23+
_daemon = xrdp-sesman
24+
25+
26+
[Definition]
27+
28+
authfail_re = \[INFO \] AUTHFAIL: user=<F-USER>(?:\S+|.+)</F-USER> ip=<ADDR> time=\d+
29+
30+
failregex = ^%(__prefix_line)s%(authfail_re)s$
31+
32+
ignoreregex =
33+
34+
datepattern = ^\[?%%ExY%%Exm%%Exd-%%ExH:%%ExM:%%ExS\]?
35+
^{DATE}

config/jail.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,3 +995,7 @@ logpath = /var/log/daemon.log
995995
[vaultwarden]
996996
port = http,https
997997
logpath = /var/log/vaultwarden.log
998+
999+
[xrdp]
1000+
port = 3389
1001+
logpath = /var/log/xrdp-sesman.log

fail2ban/server/datedetector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def _cacheTemplate(self, template):
165165
r"%b %d, %ExY %I:%M:%S %p",
166166
# ASSP: Apr-27-13 02:33:06
167167
r"^%b-%d-%Exy %k:%M:%S",
168-
# 20050123T215959, 20050123 215959, 20050123 85959
169-
r"%ExY%Exm%Exd(?:T| ?)%ExH%ExM%ExS(?:[.,]%f)?(?:\s*%z)?",
168+
# 20050123T215959, 20050123 215959, 20050123 85959, 20050123-21:59:59
169+
r"%ExY%Exm%Exd(?:-|T| ?)%ExH:?%ExM:?%ExS(?:[.,]%f)?(?:\s*%z)?",
170170
# prefixed with optional named time zone (monit):
171171
# PDT Apr 16 21:05:29
172172
r"(?:%Z )?(?:%a )?%b %d %k:%M:%S(?:\.%f)?(?: %ExY)?",

fail2ban/tests/files/logs/xrdp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# /var/log/xrdp-sesman.log -- should be about the same on any linux distro
3+
#
4+
5+
# failJSON: { "time": "2022-04-07T12:11:06", "match": true, "host": "10.171.161.151"}
6+
[20220407-12:11:06] [INFO ] AUTHFAIL: user=badtypist ip=::ffff:10.171.161.151 time=1649351466
7+
8+
# ip injection: 10.171.161.151 should be matched as the host; 192.168.0.1 is an innocent, injected address
9+
# failJSON: { "time": "2022-04-07T12:11:24", "match": true, "host": "10.171.161.151", "desc": "specifying ip address as username"}
10+
[20220407-12:11:24] [INFO ] AUTHFAIL: user=192.168.0.1 ip=::ffff:10.171.161.151 time=1649351484
11+
12+
# ip injection: 10.171.161.151 should be matched as the host; 192.168.0.4 is an innocent, injected address
13+
# failJSON: { "time": "2022-04-07T12:22:02", "match": true, "host": "10.171.161.151", "desc": "more devious log injection"}
14+
[20220407-12:22:02] [INFO ] AUTHFAIL: user=loginjector ip=192.168.0.4 time=123456789\n[20220407-12:16:59] [INFO ] AUTHFAIL: user=endinjection ip=::ffff:10.171.161.151 time=1649352122
15+
16+
17+
#
18+
# /var/log/messages -- RHEL/Fedora family
19+
#
20+
21+
# failJSON: { "time": "2005-04-07T12:11:06", "match": true, "host": "10.171.161.151"}
22+
Apr 7 12:11:06 servername xrdp-sesman[41441]: [INFO ] AUTHFAIL: user=badtypist ip=::ffff:10.171.161.151 time=1649351466
23+
24+
# ip injection: 10.171.161.151 should be matched as the host; 192.168.0.1 is an innocent, injected address
25+
# failJSON: { "time": "2005-04-07T12:11:24", "match": true, "host": "10.171.161.151", "desc": "specifying ip address as username"}
26+
Apr 7 12:11:24 servername xrdp-sesman[41441]: [INFO ] AUTHFAIL: user=192.168.0.1 ip=::ffff:10.171.161.151 time=1649351484
27+
28+
# ip injection: 10.171.161.151 should be matched as the host; 192.168.0.4 is an innocent, injected address
29+
# failJSON: { "time": "2005-04-07T12:22:02", "match": true, "host": "10.171.161.151", "desc": "more devious log injection"}
30+
Apr 7 12:22:02 servername xrdp-sesman[41441]: [INFO ] AUTHFAIL: user=loginjector ip=192.168.0.4 time=123456789\n[20220407-12:16:59] [INFO ] AUTHFAIL: user=endinjection ip=::ffff:10.171.161.151 time=1649352122
31+
32+
# ip injection: innocent, injected ip 192.168.0.4 in a line that shouldn't contain a host
33+
# failJSON: { "match": false }
34+
Apr 7 12:22:02 servername xrdp[52415]: [INFO ] xrdp_wm_log_msg: login failed for user loginjector ip=192.168.0.4 time=12345\n[20220407-12:16:59] [INFO ] AUTHFAIL: user=endinjection
35+
36+
# failJSON: { "match": false }
37+
Apr 7 12:22:02 servername xrdp[52415]: [INFO ] n[20220407-12:16:59] [INFO ] AUTHFAIL: user=endinjection

0 commit comments

Comments
 (0)