diff -Nru fail2ban-0.10.2/bin/fail2ban-server fail2ban-0.11.1/bin/fail2ban-server --- fail2ban-0.10.2/bin/fail2ban-server 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/bin/fail2ban-server 2020-01-11 10:01:00.000000000 +0000 @@ -22,7 +22,7 @@ Fail2Ban reads log file that contains password failure report and bans the corresponding IP addresses using firewall rules. -This tools starts/stops fail2ban server or does client/server communication, +This tool starts/stops fail2ban server or does client/server communication to change/read parameters of the server or jails. """ diff -Nru fail2ban-0.10.2/bin/fail2ban-testcases fail2ban-0.11.1/bin/fail2ban-testcases --- fail2ban-0.10.2/bin/fail2ban-testcases 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/bin/fail2ban-testcases 2020-01-11 10:01:00.000000000 +0000 @@ -31,7 +31,7 @@ import unittest # Check if local fail2ban module exists, and use if it exists by -# modifying the path. This is such that tests can be used in dev +# modifying the path. This is done so that tests can be used in dev # environment. if os.path.exists("fail2ban/__init__.py"): sys.path.insert(0, ".") diff -Nru fail2ban-0.10.2/ChangeLog fail2ban-0.11.1/ChangeLog --- fail2ban-0.10.2/ChangeLog 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/ChangeLog 2020-01-11 10:01:00.000000000 +0000 @@ -6,29 +6,276 @@ Fail2Ban: Changelog =================== -Incompatibility list (compared to v.0.9): +ver. 0.11.1 (2020/01/11) - this-is-the-way ----------- -* Filter (or `failregex`) internal capture-groups: +### Compatibility: +* to v.0.10: + - 0.11 is totally compatible to 0.10 (configuration- and API-related stuff), but the database + got some new tables and fields (auto-converted during the first start), so once updated to 0.11, you + have to remove the database /var/lib/fail2ban/fail2ban.sqlite3 (or its different to 0.10 schema) + if you would need to downgrade to 0.10 for some reason. +* to v.0.9: + - Filter (or `failregex`) internal capture-groups: + + * If you've your own `failregex` or custom filters using conditional match `(?P=host)`, you should + rewrite the regex like in example below resp. using `(?:(?P=ip4)|(?P=ip6)` instead of `(?P=host)` + (or `(?:(?P=ip4)|(?P=ip6)|(?P=dns))` corresponding your `usedns` and `raw` settings). + + Of course you can always define your own capture-group (like below `_cond_ip_`) to do this. + ``` + testln="1500000000 failure from 192.0.2.1: bad host 192.0.2.1" + fail2ban-regex "$testln" "^\s*failure from (?P<_cond_ip_>): bad host (?P=_cond_ip_)$" + ``` + * New internal groups (currently reserved for internal usage): + `ip4`, `ip6`, `dns`, `fid`, `fport`, additionally `user` and another captures in lower case if + mapping from tag `` used in failregex (e. g. `user` by ``). - - If you've your own `failregex` or custom filters using conditional match `(?P=host)`, you should - rewrite the regex like in example below resp. using `(?:(?P=ip4)|(?P=ip6)` instead of `(?P=host)` - (or `(?:(?P=ip4)|(?P=ip6)|(?P=dns))` corresponding your `usedns` and `raw` settings). - - Of course you can always define your own capture-group (like below `_cond_ip_`) to do this. - ``` - testln="1500000000 failure from 192.0.2.1: bad host 192.0.2.1" - fail2ban-regex "$testln" "^\s*failure from (?P<_cond_ip_>): bad host (?P=_cond_ip_)$" - ``` - - New internal groups (currently reserved for internal usage): - `ip4`, `ip6`, `dns`, `fid`, `fport`, additionally `user` and another captures in lower case if - mapping from tag `` used in failregex (e. g. `user` by ``). + - v.0.10 and 0.11 use more precise date template handling, that can be theoretically incompatible to some + user configurations resp. `datepattern`. -* v.0.10 uses more precise date template handling, that can be theoretically incompatible to some - user configurations resp. `datepattern`. + - Since v0.10 fail2ban supports the matching of IPv6 addresses, but not all ban actions are + IPv6-capable now. -* Since v0.10 fail2ban supports the matching of the IPv6 addresses, but not all ban actions are - IPv6-capable now. +### Fixes +* purge database will be executed now (within observer). +* restoring currently banned ip after service restart fixed + (now < timeofban + bantime), ignore old log failures (already banned) +* upgrade database: update new created table `bips` with entries from table `bans` (allows restore + current bans after upgrade from version <= 0.10) + +### New Features +* Increment ban time (+ observer) functionality introduced. +* Database functionality extended with bad ips. +* New tags (usable in actions): + - `` - ban count of this offender if known as bad (started by 1 for unknown) + - `` - current ban-time of the ticket (prolongation can be retarded up to 10 sec.) +* Introduced new action command `actionprolong` to prolong ban-time (e. g. set new timeout if expected); + Several actions (like ipset, etc.) rewritten using net logic with `actionprolong`. + Note: because ban-time is dynamic, it was removed from jail.conf as timeout argument (check jail.local). + +### Enhancements +* algorithm of restore current bans after restart changed: update the restored ban-time (and therefore + end of ban) of the ticket with ban-time of jail (as maximum), for all tickets with ban-time greater + (or persistent); not affected if ban-time of the jail is unchanged between stop/start. +* added new setup-option `--without-tests` to skip building and installing of tests files (gh-2287). +* added new command `fail2ban-client get banip ?sep-char|--with-time?` to get the banned ip addresses (gh-1916). + + +ver. 0.10.5 (2020/01/10) - deserve-more-respect-a-jedis-weapon-must +----------- + +Yes, Hrrrm... + +### Fixes +* [compatibility] systemd backend: default flags changed to SYSTEM_ONLY(4), fixed in gh-2444 in order to ignore + user session files per default, so could prevent "Too many open files" errors on a lot of user sessions (see gh-2392) +* [grave] fixed parsing of multi-line filters (`maxlines` > 1) together with systemd backend, + now systemd-filter replaces newlines in message from systemd journal with `\n` (otherwise + multi-line parsing may be broken, because removal of matched string from multi-line buffer window + is confused by such extra new-lines, so they are retained and got matched on every followed + message, see gh-2431) +* [stability] prevent race condition - no unban if the bans occur continuously (gh-2410); + now an unban-check will happen not later than 10 tickets get banned regardless there are + still active bans available (precedence of ban over unban-check is 10 now) +* fixed read of included config-files (`.local` overwrites options of `.conf` for config-files + included with before/after) +* `action.d/abuseipdb.conf`: switched to use AbuseIPDB API v2 (gh-2302) +* `action.d/badips.py`: fixed start of banaction on demand (which may be IP-family related), gh-2390 +* `action.d/helpers-common.conf`: rewritten grep arguments, now options `-wF` used to match only + whole words and fixed string (not as pattern), gh-2298 +* `filter.d/apache-auth.conf`: + - ignore errors from mod_evasive in `normal` mode (mode-controlled now) (gh-2548); + - extended with option `mode` - `normal` (default) and `aggressive` +* `filter.d/sshd.conf`: + - matches `Bad protocol version identification` in `ddos` and `aggressive` modes (gh-2404). + - captures `Disconnecting ...: Change of username or service not allowed` (gh-2239, gh-2279) + - captures `Disconnected from ... [preauth]`, preauth phase only, different handling by `extra` + (with supplied user only) and `ddos`/`aggressive` mode (gh-2115, gh-2239, gh-2279) +* `filter.d/mysqld-auth.conf`: + - MYSQL 8.0.13 compatibility (log-error-verbosity = 3), log-format contains few additional words + enclosed in brackets after "[Note]" (gh-2314) +* `filter.d/sendmail-reject.conf`: + - `mode=extra` now captures port IDs of `TLSMTA` and `MSA` (defaults for ports 465 and 587 on some distros) +* `files/fail2ban.service.in`: fixed systemd-unit template - missing nftables dependency (gh-2313) +* several `action.d/mail*`: fixed usage with multiple log files (ultimate fix for gh-976, gh-2341) +* `filter.d/sendmail-reject.conf`: fixed journal usage for some systems (e. g. CentOS): if only identifier + set to `sm-mta` (no unit `sendmail`) for some messages (gh-2385) +* `filter.d/asterisk.conf`: asterisk can log additional timestamp if logs into systemd-journal + (regex extended with optional part matching this, gh-2383) +* `filter.d/postfix.conf`: + - regexp's accept variable suffix code in status of postfix for precise messages (gh-2442) + - extended with new postfix filter mode `errors` to match "too many errors" (gh-2439), + also included within modes `normal`, `more` (`extra` and `aggressive`), since postfix + parameter `smtpd_hard_error_limit` is default 20 (additionally consider `maxretry`) +* `filter.d/named-refused.conf`: + - support BIND 9.11.0 log format (includes an additional field @0xXXX..., gh-2406); + - `prefregex` extended, more selective now (denied/NOTAUTH suffix moved from failregex, so no catch-all there anymore) +* `filter.d/sendmail-auth.conf`, `filter.d/sendmail-reject.conf` : + - ID in prefix can be longer as 14 characters (gh-2563); +* all filters would accept square brackets around IPv4 addresses also (e. g. monit-filter, gh-2494) +* avoids unhandled exception during flush (gh-2588) +* fixes pass2allow-ftp jail - due to inverted handling, action should prohibit access per default for any IP, + therefore reset start on demand parameter for this action (it will be started immediately by repair); +* auto-detection of IPv6 subsystem availability (important for not on-demand actions or jails, like pass2allow); + +### New Features +* new replacement tags for failregex to match subnets in form of IP-addresses with CIDR mask (gh-2559): + - `` - helper regex to match CIDR (simple integer form of net-mask); + - `` - regex to match sub-net adresses (in form of IP/CIDR, also single IP is matched, so part /CIDR is optional); +* grouped tags (``, ``, ``) recognize IP addresses enclosed in square brackets +* new failregex-flag tag `` for failregex, signaled that the access to service was gained + (ATM used similar to tag ``, but it does not add the log-line to matches, gh-2279) +* filters: introduced new configuration parameter `logtype` (default `file` for file-backends, and + `journal` for journal-backends, gh-2387); can be also set to `rfc5424` to force filters (which include common.conf) + to use RFC 5424 conform prefix-line per default (gh-2467); +* for better performance and safety the option `logtype` can be also used to + select short prefix-line for file-backends too for all filters using `__prefix_line` (`common.conf`), + if message logged only with `hostname svc[nnnn]` prefix (often the case on several systems): +```ini +[jail] +backend = auto +filter = flt[logtype=short] +``` +* `filter.d/common.conf`: differentiate `__prefix_line` for file/journal logtype's (speedup and fix parsing + of systemd-journal); +* `filter.d/traefik-auth.conf`: used to ban hosts, that were failed through traefik +* `filter.d/znc-adminlog.conf`: new filter for ZNC (IRC bouncer); requires the adminlog module to be loaded + +### Enhancements +* introduced new options: `dbmaxmatches` (fail2ban.conf) and `maxmatches` (jail.conf) to contol + how many matches per ticket fail2ban can hold in memory and store in database (gh-2402, gh-2118); +* fail2ban.conf: introduced new section `[Thread]` and option `stacksize` to configure default size + of the stack for threads running in fail2ban (gh-2356), it could be set in `fail2ban.local` to + avoid runtime error "can't start new thread" (see gh-969); +* jail-reader extended (amend to gh-1622): actions support multi-line options now (interpolations + containing new-line); +* fail2ban-client: extended to ban/unban multiple tickets (see gh-2351, gh-2349); + Syntax: + - `fail2ban-client set banip ... ` + - `fail2ban-client set unbanip [--report-absent] ... ` +* fail2ban-client: extended with new feature which allows to inform fail2ban about single or multiple + attempts (failure) for IP (resp. failure-ID), see gh-2351; + Syntax: + - `fail2ban-client set attempt [ ... ]` +* `action.d/nftables.conf`: + - isolate fail2ban rules into a dedicated table and chain (gh-2254) + - `nftables-allports` supports multiple protocols in single rule now + - combined nftables actions to single action `nftables`: + * `nftables-common` is removed (replaced with single action `nftables` now) + * `nftables-allports` is obsolete, superseded by `nftables[type=allports]` + * `nftables-multiport` is obsolete, superseded by `nftables[type=multiport]` + - allowed multiple protocols in `nftables[type=multiport]` action (single set with multiple rules + in chain), following configuration in jail would replace 3 separate actions, see + https://github.com/fail2ban/fail2ban/pull/2254#issuecomment-534684675 +* `action.d/badips.py`: option `loglevel` extended with level of summary message, + following example configuration logging summary with NOTICE and rest with DEBUG log-levels: + `action = badips.py[loglevel="debug, notice"]` +* samplestestcase.py (testSampleRegexsFactory) extended: + - allow coverage of journal logtype; + - new option `fileOptions` to set common filter/test options for whole test-file; +* large enhancement: auto-reban, improved invariant check and conditional operations (gh-2588): + - improves invariant check and repair (avoid unhandled exception, consider family on conditional operations, etc), + prepared for bulk re-ban in repair case (if bulk-ban becomes implemented); + - automatic reban (repeat banning action) after repair/restore sane environment, if already logged ticket causes + new failures (via new action operation `actionreban` or `actionban` if still not defined in action); + * introduces banning epoch for actions and tickets (to distinguish or recognize removed set of the tickets); + * invariant check avoids repair by unban/stop (unless parameter `actionrepair_on_unban` set to `true`); + * better handling for all conditional operations (distinguish families for certain operations like + repair/flush/stop, prepared for other families, e. g. if different handling for subnets expected, etc); + * partially implements gh-980 (more breakdown safe handling); + * closes gh-1680 (better as large-scale banning implementation with on-demand reban by failure, + at least unless a bulk-ban gets implemented); +* fail2ban-regex - several enhancements and fixes: + - improved usage output (don't put a long help if an error occurs); + - new option `--no-check-all` to avoid check of all regex's (first matched only); + - new option `-o`, `--out` to set token only provided in output (disables check-all and outputs only expected data). + + +ver. 0.10.4 (2018/10/04) - ten-four-on-due-date-ten-four +----------- + +### Fixes +* `filter.d/dovecot.conf`: + - failregex enhancement to catch sql password mismatch errors (gh-2153); + - disconnected with "proxy dest auth failed" (gh-2184); +* `filter.d/freeswitch.conf`: + - provide compatibility for log-format from gh-2193: + * extended with new default date-pattern `^(?:%%Y-)?%%m-%%d[ T]%%H:%%M:%%S(?:\.%%f)?` to cover + `YYYY-mm-dd HH:MM::SS.ms` as well as `mm-dd HH:MM::SS.ms` (so year is optional); + * more optional arguments in log-line (so accept [WARN] as well as [WARNING] and optional [SOFIA] hereafter); + - extended with mode parameter, allows to avoid matching of messages like `auth challenge (REGISTER)` + (see gh-2163) (currently `extra` as default to be backwards-compatible), see comments in filter + how to set it to mode `normal`. +* `filter.d/domino-smtp.conf`: + - recognizes failures logged using another format (something like session-id, IP enclosed in square brackets); + - failregex extended to catch connections rejected for policy reasons (gh-2228); +* `action.d/hostsdeny.conf`: fix parameter in config (dynamic parameters stating with '_' are protected + and don't allowed in command-actions), see gh-2114; +* decoding stability fix by wrong encoded characters like utf-8 surrogate pairs, etc (gh-2171): + - fail2ban running in the preferred encoding now (as default encoding also within python 2.x), mostly + `UTF-8` in opposite to `ascii` previously, so minimizes influence of implicit conversions errors; + - actions: avoid possible conversion errors on wrong-chars by replace tags; + - database: improve adapter/converter handlers working on invalid characters in sense of json and/or sqlite-database; + additionally both are exception-safe now, so avoid possible locking of database (closes gh-2137); + - logging in fail2ban is process-wide exception-safe now. +* repaired start-time of initial seek to time (as well as other log-parsing related data), + if parameter `logpath` specified before `findtime`, `backend`, `datepattern`, etc (gh-2173) +* systemd: fixed type error on option `journalflags`: an integer is required (gh-2125); + +### New Features +* new option `ignorecache` to improve performance of ignore failure check (using caching of `ignoreip`, + `ignoreself` and `ignorecommand`), see `man jail.conf` for syntax-example; +* `ignorecommand` extended to use actions-similar replacement (capable to interpolate + all possible tags like ``, ``, ``, `F-USER` etc.) + +### Enhancements +* `filter.d/dovecot.conf`: extended with tags F-USER (and alternatives) to collect user-logins (gh-2168) +* since v.0.10.4, fail2ban-client, fail2ban-server and fail2ban-regex will return version without logo info, + additionally option `-V` can be used to get version in normalized machine-readable short format. + + +ver. 0.10.3 (2018/04/04) - the-time-is-always-right-to-do-what-is-right +----------- + +### ver. 0.10.3.1: +* fixed JSON serialization for the set-object within dump into database (gh-2103). + +### Fixes +* `filter.d/asterisk.conf`: fixed failregex prefix by log over remote syslog server (gh-2060); +* `filter.d/exim.conf`: failregex extended - SMTP call dropped: too many syntax or protocol errors (gh-2048); +* `filter.d/recidive.conf`: fixed if logging into systemd-journal (SYSLOG) with daemon name in prefix, gh-2069; +* `filter.d/sendmail-auth.conf`, `filter.d/sendmail-reject.conf` : + - fixed failregex, sendmail uses prefix 'IPv6:' logging of IPv6 addresses (gh-2064); +* `filter.d/sshd.conf`: + - failregex got an optional space in order to match new log-format (see gh-2061); + - fixed ddos-mode regex to match refactored message (some versions can contain port now, see gh-2062); + - fixed root login refused regex (optional port before preauth, gh-2080); + - avoid banning of legitimate users when pam_unix used in combination with other password method, so + bypass pam_unix failures if accepted available for this user gh-2070; + - amend to gh-1263 with better handling of multiple attempts (failures for different user-names recognized immediatelly); + - mode `ddos` (and `aggressive`) extended to catch `Connection closed by ... [preauth]`, so in DDOS mode + it counts failure on closing connection within preauth-stage (gh-2085); +* `action.d/abuseipdb.conf`: fixed curl cypher errors and comment quote-issue (gh-2044, gh-2101); +* `action.d/badips.py`: implicit convert IPAddr to str, solves an issue "expected string, IPAddr found" (gh-2059); +* `action.d/hostsdeny.conf`: fixed IPv6 syntax (enclosed in square brackets, gh-2066); +* (Free)BSD ipfw actionban fixed to allow same rule added several times (gh-2054); + +### New Features +* several stability and performance optimizations, more effective filter parsing, etc; +* stable runnable within python versions 3.6 (as well as within 3.7-dev); + +### Enhancements +* `filter.d/apache-auth.conf`: detection of Apache SNI errors resp. misredirect attempts (gh-2017, gh-2097); +* `filter.d/apache-noscript.conf`: extend failregex to match "Primary script unknown", e. g. from php-fpm (gh-2073); +* date-detector extended with long epoch (`LEPOCH`) to parse milliseconds/microseconds posix-dates (gh-2029); +* possibility to specify own regex-pattern to match epoch date-time, e. g. `^\[{EPOCH}\]` or `^\[{LEPOCH}\]` (gh-2038); + the epoch-pattern similar to `{DATE}` patterns does the capture and cuts out the match of whole pattern from the log-line, + e. g. date-pattern `^\[{LEPOCH}\]\s+:` will match and cut out `[1516469849551000] :` from begin of the log-line. +* badips.py now uses https instead of plain http when requesting badips.com (gh-2057); +* add support for "any" badips.py bancategory, to be able to retrieve IPs from all categories with a desired score (gh-2056); +* Introduced new parameter `padding` for logging within fail2ban-server (default on, excepting SYSLOG): + Usage `logtarget = target[padding=on|off]` ver. 0.10.2 (2018/01/18) - nothing-burns-like-the-cold @@ -93,7 +340,7 @@ * avoid using "ANSI_X3.4-1968" as preferred encoding (if missing environment variables 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', and 'LANG', see gh-1587). * action.d/pf.conf: several fixes for pf-action like anchoring, etc. (see gh-1866, gh-1867); -* fixed ignorself issue "Retrieving own IPs of localhost failed: inet_pton() argument 2 must be string, not int" (see gh-1865); +* fixed ignoreself issue "Retrieving own IPs of localhost failed: inet_pton() argument 2 must be string, not int" (see gh-1865); * fixed tags `` and ``, could be used without ticket (a. g. in `actionstart` etc., gh-1859). * setup.py: fixed several setup facilities (gh-1874): @@ -193,9 +440,14 @@ - `` - failure identifier (if raw resp. failures without IP address) - `` - PTR reversed representation of IP address - `` - host name of the IP address + - `` - ban count of this offender if known as bad (started by 1 for unknown) + - `` - current ban-time of the ticket (prolongation can be retarded up to 10 sec.) - `` - interpolates to the corresponding filter group capture `...` - `` - fully-qualified name of host (the same as `$(hostname -f)`) - `` - short hostname (the same as `$(uname -n)`) +* Introduced new action command `actionprolong` to prolong ban-time (e. g. set new timeout if expected); + Several actions (like ipset, etc.) rewritten using net logic with `actionprolong`. + Note: because ban-time is dynamic, it was removed from jail.conf as timeout argument (check jail.local). * Allow to use filter options by `fail2ban-regex`, example: fail2ban-regex text.log "sshd[mode=aggressive]" * Samples test case factory extended with filter options - dict in JSON to control @@ -269,6 +521,9 @@ * testSocket: sporadical bug repaired - wait for server thread starts a socket (listener) * testExecuteTimeoutWithNastyChildren: sporadical bug repaired - wait for pid file inside bash, kill tree in any case (gh-1155) +* purge database will be executed now (within observer). +* restoring currently banned ip after service restart fixed + (now < timeofban + bantime), ignore old log failures (already banned) * Fixed high-load of pyinotify-backend, see https://github.com/fail2ban/fail2ban/issues/885#issuecomment-248964591 * Database: stability fix - repack cursor iterator as long as locked @@ -306,6 +561,9 @@ - new conditional section functionality used in config resp. includes: - [Init?family=inet4] - IPv4 qualified hosts only - [Init?family=inet6] - IPv6 qualified hosts only +* Increment ban time (+ observer) functionality introduced. + Thanks Serg G. Brester (sebres) +* Database functionality extended with bad ips. * New reload functionality (now totally without restart, unbanning/rebanning, etc.), see gh-1557 * Several commands extended and new commands introduced: diff -Nru fail2ban-0.10.2/config/action.d/abuseipdb.conf fail2ban-0.11.1/config/action.d/abuseipdb.conf --- fail2ban-0.10.2/config/action.d/abuseipdb.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/abuseipdb.conf 2020-01-11 10:01:00.000000000 +0000 @@ -47,14 +47,17 @@ [Definition] +# bypass action for restored tickets +norestored = 1 + # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = @@ -80,13 +83,10 @@ # wherever you install the helper script. For the PHP helper script, see # # -# --ciphers ecdhe_ecdsa_aes_256_sha is used to workaround a -# "NSS error -12286" from curl as it attempts to connect using -# SSLv3. See https://www.centos.org/forums/viewtopic.php?t=52732 # Tags: See jail.conf(5) man page # Values: CMD # -actionban = curl --fail --ciphers ecdhe_ecdsa_aes_256_sha --data 'key=' --data-urlencode 'comment=' --data 'ip=' --data 'category=' "https://www.abuseipdb.com/report/json" +actionban = lgm=$(printf '%%.1000s\n...' ""); curl -sSf "https://api.abuseipdb.com/api/v2/report" -H "Accept: application/json" -H "Key: " --data-urlencode "comment=$lgm" --data-urlencode "ip=" --data "categories=" # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -101,5 +101,5 @@ # Notes Your API key from abuseipdb.com # Values: STRING Default: None # Register for abuseipdb [https://www.abuseipdb.com], get api key and set below. -# You will need to set the catagory in the action call. +# You will need to set the category in the action call. abuseipdb_apikey = diff -Nru fail2ban-0.10.2/config/action.d/badips.py fail2ban-0.11.1/config/action.d/badips.py --- fail2ban-0.10.2/config/action.d/badips.py 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/badips.py 2020-01-11 10:01:00.000000000 +0000 @@ -18,20 +18,22 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import sys -if sys.version_info < (2, 7): +if sys.version_info < (2, 7): # pragma: no cover raise ImportError("badips.py action requires Python >= 2.7") import json import threading import logging -if sys.version_info >= (3, ): +if sys.version_info >= (3, ): # pragma: 2.x no cover from urllib.request import Request, urlopen from urllib.parse import urlencode from urllib.error import HTTPError -else: +else: # pragma: 3.x no cover from urllib2 import Request, urlopen, HTTPError from urllib import urlencode -from fail2ban.server.actions import ActionBase +from fail2ban.server.actions import Actions, ActionBase, BanTicket +from fail2ban.helpers import splitwords, str2LogLevel + class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable @@ -52,9 +54,6 @@ age : str, optional Age of last report for bad IPs, per badips.com syntax. Default "24h" (24 hours) - key : str, optional - Key issued by badips.com to report bans, for later retrieval - of personalised content. banaction : str, optional Name of banaction to use for blacklisting bad IPs. If `None`, no blacklist of IPs will take place. @@ -65,11 +64,17 @@ "postfix", but want to use whole "mail" category for blacklist. Default `category`. bankey : str, optional - Key issued by badips.com to blacklist IPs reported with the - associated key. + Key issued by badips.com to retrieve personal list + of blacklist IPs. updateperiod : int, optional Time in seconds between updating bad IPs blacklist. Default 900 (15 minutes) + loglevel : int/str, optional + Log level of the message when an IP is (un)banned. + Default `DEBUG`. + Can be also supplied as two-value list (comma- or space separated) to + provide level of the summary message when a group of IPs is (un)banned. + Example `DEBUG,INFO`. agent : str, optional User agent transmitted to server. Default `Fail2Ban/ver.` @@ -81,13 +86,13 @@ """ TIMEOUT = 10 - _badips = "http://www.badips.com" + _badips = "https://www.badips.com" def _Request(self, url, **argv): return Request(url, headers={'User-Agent': self.agent}, **argv) - def __init__(self, jail, name, category, score=3, age="24h", key=None, - banaction=None, bancategory=None, bankey=None, updateperiod=900, agent="Fail2Ban", - timeout=TIMEOUT): + def __init__(self, jail, name, category, score=3, age="24h", + banaction=None, bancategory=None, bankey=None, updateperiod=900, + loglevel='DEBUG', agent="Fail2Ban", timeout=TIMEOUT): super(BadIPsAction, self).__init__(jail, name) self.timeout = timeout @@ -95,10 +100,12 @@ self.category = category self.score = score self.age = age - self.key = key self.banaction = banaction self.bancategory = bancategory or category self.bankey = bankey + loglevel = splitwords(loglevel) + self.sumloglevel = str2LogLevel(loglevel[-1]) + self.loglevel = str2LogLevel(loglevel[0]) self.updateperiod = updateperiod self._bannedips = set() @@ -114,6 +121,15 @@ except Exception as e: # pragma: no cover return False, e + def logError(self, response, what=''): # pragma: no cover - sporadical (502: Bad Gateway, etc) + messages = {} + try: + messages = json.loads(response.read().decode('utf-8')) + except: + pass + self._logSys.error( + "%s. badips.com response: '%s'", what, + messages.get('err', 'Unknown')) def getCategories(self, incParents=False): """Get badips.com categories. @@ -133,11 +149,8 @@ try: response = urlopen( self._Request("/".join([self._badips, "get", "categories"])), timeout=self.timeout) - except HTTPError as response: - messages = json.loads(response.read().decode('utf-8')) - self._logSys.error( - "Failed to fetch categories. badips.com response: '%s'", - messages['err']) + except HTTPError as response: # pragma: no cover + self.logError(response, "Failed to fetch categories") raise else: response_json = json.loads(response.read().decode('utf-8')) @@ -186,12 +199,10 @@ urlencode({'age': age})]) if key: url = "&".join([url, urlencode({'key': key})]) + self._logSys.debug('badips.com: get list, url: %r', url) response = urlopen(self._Request(url), timeout=self.timeout) - except HTTPError as response: - messages = json.loads(response.read().decode('utf-8')) - self._logSys.error( - "Failed to fetch bad IP list. badips.com response: '%s'", - messages['err']) + except HTTPError as response: # pragma: no cover + self.logError(response, "Failed to fetch bad IP list") raise else: return set(response.read().decode('utf-8').split()) @@ -219,7 +230,7 @@ @bancategory.setter def bancategory(self, bancategory): - if bancategory not in self.getCategories(incParents=True): + if bancategory != "any" and bancategory not in self.getCategories(incParents=True): self._logSys.error("Category name '%s' not valid. " "see badips.com for list of valid categories", bancategory) @@ -271,13 +282,8 @@ def _banIPs(self, ips): for ip in ips: try: - self._jail.actions[self.banaction].ban({ - 'ip': ip, - 'failures': 0, - 'matches': "", - 'ipmatches': "", - 'ipjailmatches': "", - }) + ai = Actions.ActionInfo(BanTicket(ip), self._jail) + self._jail.actions[self.banaction].ban(ai) except Exception as e: self._logSys.error( "Error banning IP %s for jail '%s' with action '%s': %s", @@ -285,27 +291,22 @@ exc_info=self._logSys.getEffectiveLevel()<=logging.DEBUG) else: self._bannedips.add(ip) - self._logSys.info( + self._logSys.log(self.loglevel, "Banned IP %s for jail '%s' with action '%s'", ip, self._jail.name, self.banaction) def _unbanIPs(self, ips): for ip in ips: try: - self._jail.actions[self.banaction].unban({ - 'ip': ip, - 'failures': 0, - 'matches': "", - 'ipmatches': "", - 'ipjailmatches': "", - }) + ai = Actions.ActionInfo(BanTicket(ip), self._jail) + self._jail.actions[self.banaction].unban(ai) except Exception as e: - self._logSys.info( + self._logSys.error( "Error unbanning IP %s for jail '%s' with action '%s': %s", ip, self._jail.name, self.banaction, e, exc_info=self._logSys.getEffectiveLevel()<=logging.DEBUG) else: - self._logSys.info( + self._logSys.log(self.loglevel, "Unbanned IP %s for jail '%s' with action '%s'", ip, self._jail.name, self.banaction) finally: @@ -333,12 +334,19 @@ ips = self.getList( self.bancategory, self.score, self.age, self.bankey) # Remove old IPs no longer listed - self._unbanIPs(self._bannedips - ips) + s = self._bannedips - ips + m = len(s) + self._unbanIPs(s) # Add new IPs which are now listed - self._banIPs(ips - self._bannedips) - - self._logSys.info( - "Updated IPs for jail '%s'. Update again in %i seconds", + s = ips - self._bannedips + p = len(s) + self._banIPs(s) + if m != 0 or p != 0: + self._logSys.log(self.sumloglevel, + "Updated IPs for jail '%s' (-%d/+%d)", + self._jail.name, m, p) + self._logSys.debug( + "Next update for jail '%' in %i seconds", self._jail.name, self.updateperiod) finally: self._timer = threading.Timer(self.updateperiod, self.update) @@ -368,19 +376,15 @@ Any issues with badips.com request. """ try: - url = "/".join([self._badips, "add", self.category, aInfo['ip']]) - if self.key: - url = "?".join([url, urlencode({'key': self.key})]) + url = "/".join([self._badips, "add", self.category, str(aInfo['ip'])]) + self._logSys.debug('badips.com: ban, url: %r', url) response = urlopen(self._Request(url), timeout=self.timeout) - except HTTPError as response: - messages = json.loads(response.read().decode('utf-8')) - self._logSys.error( - "Response from badips.com report: '%s'", - messages['err']) + except HTTPError as response: # pragma: no cover + self.logError(response, "Failed to ban") raise else: messages = json.loads(response.read().decode('utf-8')) - self._logSys.info( + self._logSys.debug( "Response from badips.com report: '%s'", messages['suc']) diff -Nru fail2ban-0.10.2/config/action.d/blocklist_de.conf fail2ban-0.11.1/config/action.d/blocklist_de.conf --- fail2ban-0.10.2/config/action.d/blocklist_de.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/blocklist_de.conf 2020-01-11 10:01:00.000000000 +0000 @@ -31,13 +31,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = @@ -54,7 +54,7 @@ # Tags: See jail.conf(5) man page # Values: CMD # -actionban = curl --fail --data-urlencode 'server=' --data 'apikey=' --data 'service=' --data 'ip=' --data-urlencode 'logs=' --data 'format=text' --user-agent "" "https://www.blocklist.de/en/httpreports.html" +actionban = curl --fail --data-urlencode "server=" --data "apikey=" --data "service=" --data "ip=" --data-urlencode "logs=
" --data 'format=text' --user-agent "" "https://www.blocklist.de/en/httpreports.html" # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -64,10 +64,8 @@ # actionunban = -[Init] - # Option: email -# Notes server email address, as per blocklise.de account +# Notes server email address, as per blocklist.de account # Values: STRING Default: None # #email = diff -Nru fail2ban-0.10.2/config/action.d/bsd-ipfw.conf fail2ban-0.11.1/config/action.d/bsd-ipfw.conf --- fail2ban-0.10.2/config/action.d/bsd-ipfw.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/bsd-ipfw.conf 2020-01-11 10:01:00.000000000 +0000 @@ -11,14 +11,14 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = ipfw show | fgrep -c -m 1 -s 'table()' > /dev/null 2>&1 || ( ipfw show | awk 'BEGIN { b = } { if ($1 < b) {} else if ($1 == b) { b = $1 + 1 } else { e = b } } END { if (e) exit e
else exit b }'; num=$?; ipfw -q add $num from table\(
\) to me ; echo $num > "" ) # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = [ ! -f ] || ( read num < ""
ipfw -q delete $num
rm "" ) @@ -38,7 +38,7 @@ # Values: CMD # # requires an ipfw rule like "deny ip from table(1) to me" -actionban = e=`ipfw table
add 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XADD): File exists' ] || { echo "$e" 1>&2; exit $x; } +actionban = e=`ipfw table
add 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XADD): File exists' ] || echo "$e" | grep -q "record already exists" || { echo "$e" 1>&2; exit $x; } # Option: actionunban @@ -47,7 +47,7 @@ # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = e=`ipfw table
delete 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XDEL): No such process' ] || { echo "$e" 1>&2; exit $x; } +actionunban = e=`ipfw table
delete 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XDEL): No such process' ] || echo "$e" | grep -q "record not found" || { echo "$e" 1>&2; exit $x; } [Init] # Option: table diff -Nru fail2ban-0.10.2/config/action.d/cloudflare.conf fail2ban-0.11.1/config/action.d/cloudflare.conf --- fail2ban-0.10.2/config/action.d/cloudflare.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/cloudflare.conf 2020-01-11 10:01:00.000000000 +0000 @@ -15,13 +15,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/complain.conf fail2ban-0.11.1/config/action.d/complain.conf --- fail2ban-0.10.2/config/action.d/complain.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/complain.conf 2020-01-11 10:01:00.000000000 +0000 @@ -41,13 +41,13 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/dshield.conf fail2ban-0.11.1/config/action.d/dshield.conf --- fail2ban-0.10.2/config/action.d/dshield.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/dshield.conf 2020-01-11 10:01:00.000000000 +0000 @@ -32,13 +32,13 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = if [ -f .buffer ]; then diff -Nru fail2ban-0.10.2/config/action.d/dummy.conf fail2ban-0.11.1/config/action.d/dummy.conf --- fail2ban-0.10.2/config/action.d/dummy.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/dummy.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,7 +7,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = if [ ! -z '' ]; then touch ; fi; @@ -22,7 +22,7 @@ echo "%(debug)s clear all" # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = if [ ! -z '' ]; then rm -f ; fi; diff -Nru fail2ban-0.10.2/config/action.d/firewallcmd-ipset.conf fail2ban-0.11.1/config/action.d/firewallcmd-ipset.conf --- fail2ban-0.10.2/config/action.d/firewallcmd-ipset.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/firewallcmd-ipset.conf 2020-01-11 10:01:00.000000000 +0000 @@ -18,7 +18,7 @@ [Definition] -actionstart = ipset create hash:ip timeout +actionstart = ipset create hash:ip timeout firewall-cmd --direct --add-rule filter 0 -m set --match-set src -j actionflush = ipset flush @@ -29,6 +29,8 @@ actionban = ipset add timeout -exist +actionprolong = %(actionban)s + actionunban = ipset del -exist [Init] @@ -40,11 +42,11 @@ # chain = INPUT_direct -# Option: bantime -# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban) +# Option: default-timeout +# Notes: specifies default timeout in seconds (handled default ipset timeout only) # Values: [ NUM ] Default: 600 -bantime = 600 +default-timeout = 600 # Option: actiontype # Notes.: defines additions to the blocking rule diff -Nru fail2ban-0.10.2/config/action.d/helpers-common.conf fail2ban-0.11.1/config/action.d/helpers-common.conf --- fail2ban-0.10.2/config/action.d/helpers-common.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/helpers-common.conf 2020-01-11 10:01:00.000000000 +0000 @@ -1,16 +1,17 @@ -[DEFAULT] - -# Usage: -# _grep_logs_args = 'test' -# (printf %%b "Log-excerpt contains 'test':\n"; %(_grep_logs)s; printf %%b "Log-excerpt contains 'test':\n") | mail ... -# -_grep_logs = logpath=""; grep -E %(_grep_logs_args)s $logpath | -_grep_logs_args = "(^|[^0-9a-fA-F:])$(echo '' | sed 's/\./\\./g')([^0-9a-fA-F:]|$)" - -# Used for actions, that should not by executed if ticket was restored: -_bypass_if_restored = if [ '' = '1' ]; then exit 0; fi; - -[Init] -greplimit = tail -n -grepmax = 1000 -grepopts = -m +[DEFAULT] + +# Usage: +# _grep_logs_args = 'test' +# (printf %%b "Log-excerpt contains 'test':\n"; %(_grep_logs)s; printf %%b "Log-excerpt contains 'test':\n") | mail ... +# +_grep_logs = logpath=""; grep %(_grep_logs_args)s $logpath | +# options `-wF` used to match only whole words and fixed string (not as pattern) +_grep_logs_args = -wF "" + +# Used for actions, that should not by executed if ticket was restored: +_bypass_if_restored = if [ '' = '1' ]; then exit 0; fi; + +[Init] +greplimit = tail -n +grepmax = 1000 +grepopts = -m diff -Nru fail2ban-0.10.2/config/action.d/hostsdeny.conf fail2ban-0.11.1/config/action.d/hostsdeny.conf --- fail2ban-0.10.2/config/action.d/hostsdeny.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/hostsdeny.conf 2020-01-11 10:01:00.000000000 +0000 @@ -8,13 +8,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = @@ -31,7 +31,7 @@ # Tags: See jail.conf(5) man page # Values: CMD # -actionban = IP= && printf %%b ": $IP\n" >> +actionban = printf %%b ": \n" >> # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -39,7 +39,7 @@ # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = IP=$(echo | sed 's/\./\\./g') && sed -i "/^: $IP$/d" +actionunban = IP=$(echo "" | sed 's/[][\.]/\\\0/g') && sed -i "/^: $IP$/d" [Init] @@ -54,3 +54,9 @@ # for hosts.deny/hosts_access. Default is all services. # Values: STR Default: ALL daemon_list = ALL + +# internal variable IP (to differentiate the IPv4 and IPv6 syntax, where it is enclosed in brackets): +ip_value = + +[Init?family=inet6] +ip_value = [] diff -Nru fail2ban-0.10.2/config/action.d/ipfilter.conf fail2ban-0.11.1/config/action.d/ipfilter.conf --- fail2ban-0.10.2/config/action.d/ipfilter.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/ipfilter.conf 2020-01-11 10:01:00.000000000 +0000 @@ -9,7 +9,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # # enable IPF if not already enabled @@ -17,7 +17,7 @@ # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # # don't disable IPF with "/sbin/ipf -D", there may be other filters in use diff -Nru fail2ban-0.10.2/config/action.d/ipfw.conf fail2ban-0.11.1/config/action.d/ipfw.conf --- fail2ban-0.10.2/config/action.d/ipfw.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/ipfw.conf 2020-01-11 10:01:00.000000000 +0000 @@ -8,14 +8,14 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/iptables-allports.conf fail2ban-0.11.1/config/action.d/iptables-allports.conf --- fail2ban-0.10.2/config/action.d/iptables-allports.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-allports.conf 2020-01-11 10:01:00.000000000 +0000 @@ -14,7 +14,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = -N f2b- @@ -22,7 +22,7 @@ -I -p -j f2b- # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p -j f2b- diff -Nru fail2ban-0.10.2/config/action.d/iptables.conf fail2ban-0.11.1/config/action.d/iptables.conf --- fail2ban-0.10.2/config/action.d/iptables.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables.conf 2020-01-11 10:01:00.000000000 +0000 @@ -11,7 +11,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = -N f2b- @@ -19,7 +19,7 @@ -I -p --dport -j f2b- # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p --dport -j f2b- diff -Nru fail2ban-0.10.2/config/action.d/iptables-ipset-proto4.conf fail2ban-0.11.1/config/action.d/iptables-ipset-proto4.conf --- fail2ban-0.10.2/config/action.d/iptables-ipset-proto4.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-ipset-proto4.conf 2020-01-11 10:01:00.000000000 +0000 @@ -24,7 +24,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = ipset --create f2b- iphash @@ -38,7 +38,7 @@ actionflush = ipset --flush f2b- # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p -m multiport --dports -m set --match-set f2b- src -j diff -Nru fail2ban-0.10.2/config/action.d/iptables-ipset-proto6-allports.conf fail2ban-0.11.1/config/action.d/iptables-ipset-proto6-allports.conf --- fail2ban-0.10.2/config/action.d/iptables-ipset-proto6-allports.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-ipset-proto6-allports.conf 2020-01-11 10:01:00.000000000 +0000 @@ -23,10 +23,10 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # -actionstart = ipset create hash:ip timeout +actionstart = ipset create hash:ip timeout -I -m set --match-set src -j # Option: actionflush @@ -36,7 +36,7 @@ actionflush = ipset flush # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -m set --match-set src -j @@ -51,6 +51,8 @@ # actionban = ipset add timeout -exist +actionprolong = %(actionban)s + # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the # command is executed with Fail2Ban user rights. @@ -61,11 +63,11 @@ [Init] -# Option: bantime -# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban) +# Option: default-timeout +# Notes: specifies default timeout in seconds (handled default ipset timeout only) # Values: [ NUM ] Default: 600 -# -bantime = 600 + +default-timeout = 600 ipmset = f2b- familyopt = diff -Nru fail2ban-0.10.2/config/action.d/iptables-ipset-proto6.conf fail2ban-0.11.1/config/action.d/iptables-ipset-proto6.conf --- fail2ban-0.10.2/config/action.d/iptables-ipset-proto6.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-ipset-proto6.conf 2020-01-11 10:01:00.000000000 +0000 @@ -23,10 +23,10 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # -actionstart = ipset create hash:ip timeout +actionstart = ipset create hash:ip timeout -I -p -m multiport --dports -m set --match-set src -j # Option: actionflush @@ -36,7 +36,7 @@ actionflush = ipset flush # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p -m multiport --dports -m set --match-set src -j @@ -51,6 +51,8 @@ # actionban = ipset add timeout -exist +actionprolong = %(actionban)s + # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the # command is executed with Fail2Ban user rights. @@ -61,11 +63,11 @@ [Init] -# Option: bantime -# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban) +# Option: default-timeout +# Notes: specifies default timeout in seconds (handled default ipset timeout only) # Values: [ NUM ] Default: 600 -# -bantime = 600 + +default-timeout = 600 ipmset = f2b- familyopt = diff -Nru fail2ban-0.10.2/config/action.d/iptables-multiport.conf fail2ban-0.11.1/config/action.d/iptables-multiport.conf --- fail2ban-0.10.2/config/action.d/iptables-multiport.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-multiport.conf 2020-01-11 10:01:00.000000000 +0000 @@ -11,7 +11,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = -N f2b- @@ -19,7 +19,7 @@ -I -p -m multiport --dports -j f2b- # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p -m multiport --dports -j f2b- diff -Nru fail2ban-0.10.2/config/action.d/iptables-multiport-log.conf fail2ban-0.11.1/config/action.d/iptables-multiport-log.conf --- fail2ban-0.10.2/config/action.d/iptables-multiport-log.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-multiport-log.conf 2020-01-11 10:01:00.000000000 +0000 @@ -16,7 +16,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = -N f2b- @@ -34,7 +34,7 @@ -F f2b--log # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -p -m multiport --dports -j f2b- diff -Nru fail2ban-0.10.2/config/action.d/iptables-new.conf fail2ban-0.11.1/config/action.d/iptables-new.conf --- fail2ban-0.10.2/config/action.d/iptables-new.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-new.conf 2020-01-11 10:01:00.000000000 +0000 @@ -13,7 +13,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = -N f2b- @@ -21,7 +21,7 @@ -I -m state --state NEW -p --dport -j f2b- # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = -D -m state --state NEW -p --dport -j f2b- diff -Nru fail2ban-0.10.2/config/action.d/iptables-xt_recent-echo.conf fail2ban-0.11.1/config/action.d/iptables-xt_recent-echo.conf --- fail2ban-0.10.2/config/action.d/iptables-xt_recent-echo.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/iptables-xt_recent-echo.conf 2020-01-11 10:01:00.000000000 +0000 @@ -12,7 +12,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # # Changing iptables rules requires root privileges. If fail2ban is @@ -42,7 +42,7 @@ actionflush = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = echo / > /proc/net/xt_recent/ diff -Nru fail2ban-0.10.2/config/action.d/mail-buffered.conf fail2ban-0.11.1/config/action.d/mail-buffered.conf --- fail2ban-0.10.2/config/action.d/mail-buffered.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mail-buffered.conf 2020-01-11 10:01:00.000000000 +0000 @@ -10,7 +10,7 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Hi,\n @@ -20,7 +20,7 @@ Fail2Ban"|mail -s "[Fail2Ban] : started on " # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = if [ -f ]; then diff -Nru fail2ban-0.10.2/config/action.d/mail.conf fail2ban-0.11.1/config/action.d/mail.conf --- fail2ban-0.10.2/config/action.d/mail.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mail.conf 2020-01-11 10:01:00.000000000 +0000 @@ -10,7 +10,7 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Hi,\n @@ -19,7 +19,7 @@ Fail2Ban"|mail -s "[Fail2Ban] : started on " # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = printf %%b "Hi,\n diff -Nru fail2ban-0.10.2/config/action.d/mail-whois-common.conf fail2ban-0.11.1/config/action.d/mail-whois-common.conf --- fail2ban-0.10.2/config/action.d/mail-whois-common.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mail-whois-common.conf 2020-01-11 10:01:00.000000000 +0000 @@ -17,7 +17,7 @@ # character set before sending it to a mail program # make sure you have 'file' and 'iconv' commands installed when opting for that _whois_target_charset = UTF-8 -_whois_convert_charset = whois | +_whois_convert_charset = (%(_whois)s) | { WHOIS_OUTPUT=$(cat) ; WHOIS_CHARSET=$(printf %%b "$WHOIS_OUTPUT" | file -b --mime-encoding -) ; printf %%b "$WHOIS_OUTPUT" | iconv -f $WHOIS_CHARSET -t %(_whois_target_charset)s//TRANSLIT - ; } # choose between _whois and _whois_convert_charset in mail-whois-common.local diff -Nru fail2ban-0.10.2/config/action.d/mail-whois.conf fail2ban-0.11.1/config/action.d/mail-whois.conf --- fail2ban-0.10.2/config/action.d/mail-whois.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mail-whois.conf 2020-01-11 10:01:00.000000000 +0000 @@ -14,7 +14,7 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Hi,\n @@ -23,7 +23,7 @@ Fail2Ban"|mail -s "[Fail2Ban] : started on " # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = printf %%b "Hi,\n diff -Nru fail2ban-0.10.2/config/action.d/mail-whois-lines.conf fail2ban-0.11.1/config/action.d/mail-whois-lines.conf --- fail2ban-0.10.2/config/action.d/mail-whois-lines.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mail-whois-lines.conf 2020-01-11 10:01:00.000000000 +0000 @@ -15,7 +15,7 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Hi,\n @@ -24,7 +24,7 @@ Fail2Ban" | "[Fail2Ban] : started on " # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = printf %%b "Hi,\n diff -Nru fail2ban-0.10.2/config/action.d/mynetwatchman.conf fail2ban-0.11.1/config/action.d/mynetwatchman.conf --- fail2ban-0.10.2/config/action.d/mynetwatchman.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/mynetwatchman.conf 2020-01-11 10:01:00.000000000 +0000 @@ -28,13 +28,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/nftables-allports.conf fail2ban-0.11.1/config/action.d/nftables-allports.conf --- fail2ban-0.10.2/config/action.d/nftables-allports.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nftables-allports.conf 2020-01-11 10:01:00.000000000 +0000 @@ -6,17 +6,12 @@ # Modified: Alexander Belykh # adapted for nftables # +# Obsolete: superseded by nftables[type=allports] [INCLUDES] -before = nftables-common.conf +before = nftables.conf [Definition] -# Option: nftables_mode -# Notes.: additional expressions for nftables filter rule -# Values: nftables expressions -# -nftables_mode = meta l4proto - -[Init] +type = allports diff -Nru fail2ban-0.10.2/config/action.d/nftables-common.conf fail2ban-0.11.1/config/action.d/nftables-common.conf --- fail2ban-0.10.2/config/action.d/nftables-common.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nftables-common.conf 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -# Fail2Ban configuration file -# -# Author: Daniel Black -# Author: Cyril Jaquier -# Modified: Yaroslav O. Halchenko -# made active on all ports from original iptables.conf -# Modified: Alexander Belykh -# adapted for nftables -# -# This is a included configuration file and includes the definitions for the nftables -# used in all nftables based actions by default. -# -# The user can override the defaults in nftables-common.local - -[INCLUDES] - -after = nftables-common.local - -[Definition] - -# Option: nftables_mode -# Notes.: additional expressions for nftables filter rule -# Values: nftables expressions -# -nftables_mode = dport \{ \} - -# Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. -# Values: CMD -# -actionstart = add set \{ type \; \} - insert rule %(nftables_mode)s saddr @ - -_nft_list = --handle --numeric list chain -_nft_get_handle_id = grep -m1 ' saddr @ # handle' | grep -oe ' handle [0-9]*' - -# Option: actionstop -# Notes.: command executed once at the end of Fail2Ban -# Values: CMD -# -actionstop = HANDLE_ID=$(%(_nft_list)s | %(_nft_get_handle_id)s) - delete rule $HANDLE_ID - delete set - -# Option: actioncheck -# Notes.: command executed once before each actionban command -# Values: CMD -# -actioncheck = list chain | grep -q '@[ \t]' - -# Option: actionban -# Notes.: command executed when banning an IP. Take care that the -# command is executed with Fail2Ban user rights. -# Tags: See jail.conf(5) man page -# Values: CMD -# -actionban = add element \{ \} - -# Option: actionunban -# Notes.: command executed when unbanning an IP. Take care that the -# command is executed with Fail2Ban user rights. -# Tags: See jail.conf(5) man page -# Values: CMD -# -actionunban = delete element \{ \} - -[Init] - -# Option: nftables_type -# Notes.: address type to work with -# Values: [ipv4_addr | ipv6_addr] Default: ipv4_addr -# -nftables_type = ipv4_addr - -# Option: nftables_family -# Notes.: address family to work in -# Values: [ip | ip6 | inet] Default: inet -# -nftables_family = inet - -# Option: nftables_table -# Notes.: table in the address family to work in -# Values: STRING Default: filter -# -nftables_table = filter - -# Option: chain -# Notes specifies the nftables chain to which the Fail2Ban rules should be -# added -# Values: STRING Default: input -chain = input - -# Default name of the filtering set -# -name = default - -# Option: port -# Notes.: specifies port to monitor -# Values: [ NUM | STRING ] Default: -# -port = ssh - -# Option: protocol -# Notes.: internally used by config reader for interpolations. -# Values: [ tcp | udp ] Default: tcp -# -protocol = tcp - -# Option: blocktype -# Note: This is what the action does with rules. This can be any jump target -# as per the nftables man page (section 8). Common values are drop -# reject, reject with icmp type host-unreachable -# Values: STRING -blocktype = reject - -# Option: nftables -# Notes.: Actual command to be executed, including common to all calls options -# Values: STRING -nftables = nft - -# Option: set_name -# Notes.: The name of the nft set used to store banned addresses -# Values: STRING -set_name = f2b- - -# Option: address_family -# Notes.: The family of the banned addresses -# Values: [ ip | ip6 ] -address_family = ip - -[Init?family=inet6] - -nftables_type = ipv6_addr -set_name = f2b-6 -address_family = ip6 diff -Nru fail2ban-0.10.2/config/action.d/nftables.conf fail2ban-0.11.1/config/action.d/nftables.conf --- fail2ban-0.10.2/config/action.d/nftables.conf 1970-01-01 00:00:00.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nftables.conf 2020-01-11 10:01:00.000000000 +0000 @@ -0,0 +1,203 @@ +# Fail2Ban configuration file +# +# Author: Daniel Black +# Author: Cyril Jaquier +# Modified: Yaroslav O. Halchenko +# made active on all ports from original iptables.conf +# Modified: Alexander Belykh +# adapted for nftables +# +# This is a included configuration file and includes the definitions for the nftables +# used in all nftables based actions by default. +# +# The user can override the defaults in nftables-common.local +# Example: redirect flow to honeypot +# +# [Init] +# table_family = ip +# chain_type = nat +# chain_hook = prerouting +# chain_priority = -50 +# blocktype = counter redirect to 2222 + +[INCLUDES] + +after = nftables-common.local + +[Definition] + +# Option: type +# Notes.: type of the action. +# Values: [ multiport | allports ] Default: multiport +# +type = multiport + +rule_match-custom = +rule_match-allports = meta l4proto \{ \} +rule_match-multiport = $proto dport \{ \} +match = > + +# Option: rule_stat +# Notes.: statement for nftables filter rule. +# leaving it empty will block all (include udp and icmp) +# Values: nftables statement +# +rule_stat = %(match)s saddr @ + +# optional interator over protocol's: +_nft_for_proto-custom-iter = +_nft_for_proto-custom-done = +_nft_for_proto-allports-iter = +_nft_for_proto-allports-done = +_nft_for_proto-multiport-iter = for proto in $(echo '' | sed 's/,/ /g'); do +_nft_for_proto-multiport-done = done + +_nft_list = -a list chain
+_nft_get_handle_id = grep -oP '@\s+.*\s+\Khandle\s+(\d+)$' + +_nft_add_set = add set
\{ type \; \} + <_nft_for_proto--iter> + add rule
%(rule_stat)s + <_nft_for_proto--done> +_nft_del_set = { %(_nft_list)s | %(_nft_get_handle_id)s; } | while read -r hdl; do + delete rule
$hdl; done + delete set
+ +# Option: _nft_shutdown_table +# Notes.: command executed after the stop in order to delete table (it checks that no sets are available): +# Values: CMD +# +_nft_shutdown_table = { list table
| grep -qP '^\s+set\s+'; } || { + delete table
+ } + +# Option: actionstart +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). +# Values: CMD +# +actionstart = add table
+ -- add chain
\{ type hook priority \; \} + %(_nft_add_set)s + +# Option: actionflush +# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action); +# uses `nft flush set ...` and as fallback (e. g. unsupported) recreates the set (with references) +# Values: CMD +# +actionflush = { flush set
2> /dev/null; } || { + %(_nft_del_set)s + %(_nft_add_set)s + } + +# Option: actionstop +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) +# Values: CMD +# +actionstop = %(_nft_del_set)s + <_nft_shutdown_table> + +# Option: actioncheck +# Notes.: command executed once before each actionban command +# Values: CMD +# +actioncheck = list chain
| grep -q '@[ \t]' + +# Option: actionban +# Notes.: command executed when banning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionban = add element
\{ \} + +# Option: actionunban +# Notes.: command executed when unbanning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionunban = delete element
\{ \} + +[Init] + +# Option: table +# Notes.: main table to store chain and sets (automatically created on demand) +# Values: STRING Default: f2b-table +table = f2b-table + +# Option: table_family +# Notes.: address family to work in +# Values: [ip | ip6 | inet] Default: inet +table_family = inet + +# Option: chain +# Notes.: main chain to store rules +# Values: STRING Default: f2b-chain +chain = f2b-chain + +# Option: chain_type +# Notes.: refers to the kind of chain to be created +# Values: [filter | route | nat] Default: filter +# +chain_type = filter + +# Option: chain_hook +# Notes.: refers to the kind of chain to be created +# Values: [ prerouting | input | forward | output | postrouting ] Default: input +# +chain_hook = input + +# Option: chain_priority +# Notes.: priority in the chain. +# Values: NUMBER Default: -1 +# +chain_priority = -1 + +# Option: addr_type +# Notes.: address type to work with +# Values: [ipv4_addr | ipv6_addr] Default: ipv4_addr +# +addr_type = ipv4_addr + +# Default name of the filtering set +# +name = default + +# Option: port +# Notes.: specifies port to monitor +# Values: [ NUM | STRING ] Default: +# +port = ssh + +# Option: protocol +# Notes.: internally used by config reader for interpolations. +# Values: [ tcp | udp ] Default: tcp +# +protocol = tcp + +# Option: blocktype +# Note: This is what the action does with rules. This can be any jump target +# as per the nftables man page (section 8). Common values are drop, +# reject, reject with icmpx type host-unreachable, redirect to 2222 +# Values: STRING +blocktype = reject + +# Option: nftables +# Notes.: Actual command to be executed, including common to all calls options +# Values: STRING +nftables = nft + +# Option: addr_set +# Notes.: The name of the nft set used to store banned addresses +# Values: STRING +addr_set = addr-set- + +# Option: addr_family +# Notes.: The family of the banned addresses +# Values: [ ip | ip6 ] +addr_family = ip + +[Init?family=inet6] +addr_family = ip6 +addr_type = ipv6_addr +addr_set = addr6-set- diff -Nru fail2ban-0.10.2/config/action.d/nftables-multiport.conf fail2ban-0.11.1/config/action.d/nftables-multiport.conf --- fail2ban-0.10.2/config/action.d/nftables-multiport.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nftables-multiport.conf 2020-01-11 10:01:00.000000000 +0000 @@ -6,17 +6,12 @@ # Modified: Alexander Belykh # adapted for nftables # +# Obsolete: superseded by nftables[type=multiport] [INCLUDES] -before = nftables-common.conf +before = nftables.conf [Definition] -# Option: nftables_mode -# Notes.: additional expressions for nftables filter rule -# Values: nftables expressions -# -nftables_mode = dport \{ \} - -[Init] +type = multiport \ No newline at end of file diff -Nru fail2ban-0.10.2/config/action.d/nginx-block-map.conf fail2ban-0.11.1/config/action.d/nginx-block-map.conf --- fail2ban-0.10.2/config/action.d/nginx-block-map.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nginx-block-map.conf 2020-01-11 10:01:00.000000000 +0000 @@ -105,4 +105,4 @@ actionban = echo "\\\\ 1;" >> '%(blck_lst_file)s'; %(blck_lst_reload)s -actionunban = id=$(echo "" | sed -e 's/[]\/$*.^|[]/\\&/g'); sed -i "/$id 1;/d" %(blck_lst_file)s; %(blck_lst_reload)s +actionunban = id=$(echo "" | sed -e 's/[]\/$*.^|[]/\\&/g'); sed -i "/^\\\\$id 1;$/d" %(blck_lst_file)s; %(blck_lst_reload)s diff -Nru fail2ban-0.10.2/config/action.d/npf.conf fail2ban-0.11.1/config/action.d/npf.conf --- fail2ban-0.10.2/config/action.d/npf.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/npf.conf 2020-01-11 10:01:00.000000000 +0000 @@ -9,7 +9,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # # we don't enable NPF automatically, as it will be enabled elsewhere @@ -17,7 +17,7 @@ # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # # we don't disable NPF automatically either diff -Nru fail2ban-0.10.2/config/action.d/nsupdate.conf fail2ban-0.11.1/config/action.d/nsupdate.conf --- fail2ban-0.10.2/config/action.d/nsupdate.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/nsupdate.conf 2020-01-11 10:01:00.000000000 +0000 @@ -42,14 +42,14 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/osx-afctl.conf fail2ban-0.11.1/config/action.d/osx-afctl.conf --- fail2ban-0.10.2/config/action.d/osx-afctl.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/osx-afctl.conf 2020-01-11 10:01:00.000000000 +0000 @@ -12,5 +12,5 @@ actionban = /usr/libexec/afctl -a -t actionunban = /usr/libexec/afctl -r -[Init] -bantime = 2880 +actionprolong = %(actionunban)s && %(actionban)s + diff -Nru fail2ban-0.10.2/config/action.d/osx-ipfw.conf fail2ban-0.11.1/config/action.d/osx-ipfw.conf --- fail2ban-0.10.2/config/action.d/osx-ipfw.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/osx-ipfw.conf 2020-01-11 10:01:00.000000000 +0000 @@ -9,14 +9,14 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/pf.conf fail2ban-0.11.1/config/action.d/pf.conf --- fail2ban-0.10.2/config/action.d/pf.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/pf.conf 2020-01-11 10:01:00.000000000 +0000 @@ -10,7 +10,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # # we don't enable PF automatically; to enable run pfctl -e @@ -35,7 +35,7 @@ actionstart_on_demand = false # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # # we only disable PF rules we've installed prior diff -Nru fail2ban-0.10.2/config/action.d/sendmail-buffered.conf fail2ban-0.11.1/config/action.d/sendmail-buffered.conf --- fail2ban-0.10.2/config/action.d/sendmail-buffered.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-buffered.conf 2020-01-11 10:01:00.000000000 +0000 @@ -14,7 +14,7 @@ norestored = 1 # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Subject: [Fail2Ban] : started on @@ -24,10 +24,10 @@ The jail has been started successfully.\n Output will be buffered until lines are available.\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = if [ -f ]; then @@ -38,7 +38,7 @@ These hosts have been banned by Fail2Ban.\n `cat ` Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | rm fi printf %%b "Subject: [Fail2Ban] : stopped on @@ -47,7 +47,7 @@ Hi,\n The jail has been stopped.\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | # Option: actioncheck # Notes.: command executed once before each actionban command @@ -71,7 +71,7 @@ These hosts have been banned by Fail2Ban.\n `cat ` Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | rm fi diff -Nru fail2ban-0.10.2/config/action.d/sendmail-common.conf fail2ban-0.11.1/config/action.d/sendmail-common.conf --- fail2ban-0.10.2/config/action.d/sendmail-common.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-common.conf 2020-01-11 10:01:00.000000000 +0000 @@ -11,7 +11,7 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "Subject: [Fail2Ban] : started on @@ -21,10 +21,10 @@ Hi,\n The jail has been started successfully.\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = printf %%b "Subject: [Fail2Ban] : stopped on @@ -34,7 +34,7 @@ Hi,\n The jail has been stopped.\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | # Option: actioncheck # Notes.: command executed once before each actionban command @@ -60,6 +60,10 @@ [Init] +# Your system mail command +# +mailcmd = /usr/sbin/sendmail -f "" "" + # Recipient mail address # dest = root diff -Nru fail2ban-0.10.2/config/action.d/sendmail.conf fail2ban-0.11.1/config/action.d/sendmail.conf --- fail2ban-0.10.2/config/action.d/sendmail.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail.conf 2020-01-11 10:01:00.000000000 +0000 @@ -27,7 +27,7 @@ The IP has just been banned by Fail2Ban after attempts against .\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-geoip-lines.conf fail2ban-0.11.1/config/action.d/sendmail-geoip-lines.conf --- fail2ban-0.10.2/config/action.d/sendmail-geoip-lines.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-geoip-lines.conf 2020-01-11 10:01:00.000000000 +0000 @@ -37,11 +37,11 @@ Country:`geoiplookup -f /usr/share/GeoIP/GeoIP.dat "" | cut -d':' -f2-` AS:`geoiplookup -f /usr/share/GeoIP/GeoIPASNum.dat "" | cut -d':' -f2-` hostname: \n\n - Lines containing failures of \n"; + Lines containing failures of (max )\n"; %(_grep_logs)s; printf %%b "\n Regards,\n - Fail2Ban" ) | /usr/sbin/sendmail -f + Fail2Ban" ) | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-whois.conf fail2ban-0.11.1/config/action.d/sendmail-whois.conf --- fail2ban-0.10.2/config/action.d/sendmail-whois.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-whois.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,6 +7,7 @@ [INCLUDES] before = sendmail-common.conf + mail-whois-common.conf [Definition] @@ -27,9 +28,9 @@ The IP has just been banned by Fail2Ban after attempts against .\n\n Here is more information about :\n - `/usr/bin/whois || echo missing whois program`\n + `%(_whois_command)s`\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-whois-ipjailmatches.conf fail2ban-0.11.1/config/action.d/sendmail-whois-ipjailmatches.conf --- fail2ban-0.10.2/config/action.d/sendmail-whois-ipjailmatches.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-whois-ipjailmatches.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,6 +7,7 @@ [INCLUDES] before = sendmail-common.conf + mail-whois-common.conf [Definition] @@ -27,11 +28,11 @@ The IP has just been banned by Fail2Ban after attempts against .\n\n Here is more information about :\n - `/usr/bin/whois `\n\n + `%(_whois_command)s`\n\n Matches for with failures IP:\n \n\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-whois-ipmatches.conf fail2ban-0.11.1/config/action.d/sendmail-whois-ipmatches.conf --- fail2ban-0.10.2/config/action.d/sendmail-whois-ipmatches.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-whois-ipmatches.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,6 +7,7 @@ [INCLUDES] before = sendmail-common.conf + mail-whois-common.conf [Definition] @@ -27,11 +28,11 @@ The IP has just been banned by Fail2Ban after attempts against .\n\n Here is more information about :\n - `/usr/bin/whois `\n\n + `%(_whois_command)s`\n\n Matches with failures IP:\n \n\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-whois-lines.conf fail2ban-0.11.1/config/action.d/sendmail-whois-lines.conf --- fail2ban-0.10.2/config/action.d/sendmail-whois-lines.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-whois-lines.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,6 +7,7 @@ [INCLUDES] before = sendmail-common.conf + mail-whois-common.conf helpers-common.conf [Definition] @@ -27,13 +28,13 @@ Hi,\n The IP has just been banned by Fail2Ban after attempts against .\n\n - Here is more information about :\n - `/usr/bin/whois || echo missing whois program`\n\n - Lines containing failures of \n"; + Here is more information about :\n" + %(_whois_command)s; + printf %%b "\nLines containing failures of (max )\n"; %(_grep_logs)s; printf %%b "\n Regards,\n - Fail2Ban" ) | /usr/sbin/sendmail -f + Fail2Ban" ) | [Init] diff -Nru fail2ban-0.10.2/config/action.d/sendmail-whois-matches.conf fail2ban-0.11.1/config/action.d/sendmail-whois-matches.conf --- fail2ban-0.10.2/config/action.d/sendmail-whois-matches.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/sendmail-whois-matches.conf 2020-01-11 10:01:00.000000000 +0000 @@ -7,6 +7,7 @@ [INCLUDES] before = sendmail-common.conf + mail-whois-common.conf [Definition] @@ -27,11 +28,11 @@ The IP has just been banned by Fail2Ban after attempts against .\n\n Here is more information about :\n - `/usr/bin/whois `\n\n + `%(_whois_command)s`\n\n Matches:\n \n\n Regards,\n - Fail2Ban" | /usr/sbin/sendmail -f + Fail2Ban" | [Init] diff -Nru fail2ban-0.10.2/config/action.d/shorewall.conf fail2ban-0.11.1/config/action.d/shorewall.conf --- fail2ban-0.10.2/config/action.d/shorewall.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/shorewall.conf 2020-01-11 10:01:00.000000000 +0000 @@ -9,7 +9,7 @@ # connections. So if the attempter goes on trying using the same connection # he could even log in. In order to get the same behavior of the iptable # action (so that the ban is immediate) the /etc/shorewall/shorewall.conf -# file should me modified with "BLACKLISTNEWONLY=No". Note that as of +# file should be modified with "BLACKLISTNEWONLY=No". Note that as of # Shorewall 4.5.13 BLACKLISTNEWONLY is deprecated; however the equivalent # of BLACKLISTNEWONLY=No can now be achieved by setting BLACKLIST="ALL". # @@ -17,13 +17,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/shorewall-ipset-proto6.conf fail2ban-0.11.1/config/action.d/shorewall-ipset-proto6.conf --- fail2ban-0.10.2/config/action.d/shorewall-ipset-proto6.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/shorewall-ipset-proto6.conf 2020-01-11 10:01:00.000000000 +0000 @@ -47,15 +47,15 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = if ! ipset -quiet -name list f2b- >/dev/null; - then ipset -quiet -exist create f2b- hash:ip timeout ; + then ipset -quiet -exist create f2b- hash:ip timeout ; fi # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = ipset flush f2b- @@ -68,6 +68,8 @@ # actionban = ipset add f2b- timeout -exist +actionprolong = %(actionban)s + # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the # command is executed with Fail2Ban user rights. @@ -76,10 +78,8 @@ # actionunban = ipset del f2b- -exist -[Init] - -# Option: bantime -# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban) +# Option: default-timeout +# Notes: specifies default timeout in seconds (handled default ipset timeout only) # Values: [ NUM ] Default: 600 -# -bantime = 600 + +default-timeout = 600 diff -Nru fail2ban-0.10.2/config/action.d/smtp.py fail2ban-0.11.1/config/action.d/smtp.py --- fail2ban-0.10.2/config/action.d/smtp.py 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/smtp.py 2020-01-11 10:01:00.000000000 +0000 @@ -159,25 +159,25 @@ try: self._logSys.debug("Connected to SMTP '%s', response: %i: %s", self.host, *smtp.connect(self.host)) - if self.user and self.password: + if self.user and self.password: # pragma: no cover (ATM no tests covering that) smtp.login(self.user, self.password) failed_recipients = smtp.sendmail( self.fromaddr, self.toaddr.split(", "), msg.as_string()) - except smtplib.SMTPConnectError: + except smtplib.SMTPConnectError: # pragma: no cover self._logSys.error("Error connecting to host '%s'", self.host) raise - except smtplib.SMTPAuthenticationError: + except smtplib.SMTPAuthenticationError: # pragma: no cover self._logSys.error( "Failed to authenticate with host '%s' user '%s'", self.host, self.user) raise - except smtplib.SMTPException: + except smtplib.SMTPException: # pragma: no cover self._logSys.error( "Error sending mail to host '%s' from '%s' to '%s'", self.host, self.fromaddr, self.toaddr) raise else: - if failed_recipients: + if failed_recipients: # pragma: no cover self._logSys.warning( "Email to '%s' failed to following recipients: %r", self.toaddr, failed_recipients) @@ -186,7 +186,7 @@ try: self._logSys.debug("Disconnected from '%s', response %i: %s", self.host, *smtp.quit()) - except smtplib.SMTPServerDisconnected: + except smtplib.SMTPServerDisconnected: # pragma: no cover pass # Not connected def start(self): diff -Nru fail2ban-0.10.2/config/action.d/symbiosis-blacklist-allports.conf fail2ban-0.11.1/config/action.d/symbiosis-blacklist-allports.conf --- fail2ban-0.10.2/config/action.d/symbiosis-blacklist-allports.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/symbiosis-blacklist-allports.conf 2020-01-11 10:01:00.000000000 +0000 @@ -10,13 +10,13 @@ [Definition] # Option: actionstart -# Notes.: command executed once at the start of Fail2Ban. +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = # Option: actionstop -# Notes.: command executed once at the end of Fail2Ban +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = diff -Nru fail2ban-0.10.2/config/action.d/xarf-login-attack.conf fail2ban-0.11.1/config/action.d/xarf-login-attack.conf --- fail2ban-0.10.2/config/action.d/xarf-login-attack.conf 2018-01-18 13:49:01.000000000 +0000 +++ fail2ban-0.11.1/config/action.d/xarf-login-attack.conf 2020-01-11 10:01:00.000000000 +0000 @@ -41,7 +41,12 @@ actioncheck = -actionban = oifs=${IFS}; IFS=.;SEP_IP=( ); set -- ${SEP_IP}; ADDRESSES=$(dig +short -t txt -q $4.$3.$2.$1.abuse-contacts.abusix.org); IFS=${oifs} +actionban = oifs=${IFS}; + RESOLVER_ADDR="%(addr_resolver)s" + if [ "" -gt 0 ]; then echo "try to resolve $RESOLVER_ADDR"; fi + ADDRESSES=$(dig +short -t txt -q $RESOLVER_ADDR | tr -d '"') + IFS=,; ADDRESSES=$(echo $ADDRESSES) + IFS=${oifs} IP= FROM= SERVICE= @@ -51,26 +56,37 @@ PORT= DATE=`LC_ALL=C date --date=@