committing changes in /etc made by "-bash"
Package changes:
This commit is contained in:
171
.etckeeper
171
.etckeeper
@@ -22,6 +22,12 @@ mkdir -p './dnf/aliases.d'
|
|||||||
mkdir -p './dnf/modules.defaults.d'
|
mkdir -p './dnf/modules.defaults.d'
|
||||||
mkdir -p './dnf/plugins/copr.d'
|
mkdir -p './dnf/plugins/copr.d'
|
||||||
mkdir -p './exports.d'
|
mkdir -p './exports.d'
|
||||||
|
mkdir -p './fail2ban/fail2ban.d'
|
||||||
|
mkdir -p './firewalld/helpers'
|
||||||
|
mkdir -p './firewalld/icmptypes'
|
||||||
|
mkdir -p './firewalld/ipsets'
|
||||||
|
mkdir -p './firewalld/policies'
|
||||||
|
mkdir -p './firewalld/services'
|
||||||
mkdir -p './glvnd'
|
mkdir -p './glvnd'
|
||||||
mkdir -p './gnupg'
|
mkdir -p './gnupg'
|
||||||
mkdir -p './groff/site-font'
|
mkdir -p './groff/site-font'
|
||||||
@@ -673,39 +679,192 @@ maybe chmod 0644 'exports'
|
|||||||
maybe chmod 0755 'exports.d'
|
maybe chmod 0755 'exports.d'
|
||||||
maybe chmod 0755 'fail2ban'
|
maybe chmod 0755 'fail2ban'
|
||||||
maybe chmod 0755 'fail2ban/action.d'
|
maybe chmod 0755 'fail2ban/action.d'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/abuseipdb.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/apf.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/badips.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/badips.py'
|
||||||
maybe chmod 0644 'fail2ban/action.d/badips.py.rpmnew'
|
maybe chmod 0644 'fail2ban/action.d/badips.py.rpmnew'
|
||||||
maybe chmod 0644 'fail2ban/action.d/badips.py.rpmsave'
|
maybe chmod 0644 'fail2ban/action.d/badips.py.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/blocklist_de.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/cloudflare.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/dshield.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/dummy.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-allports.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-ipset.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-multiport.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-new.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-rich-logging.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/firewallcmd-rich-rules.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/helpers-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-allports.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-common.conf'
|
||||||
maybe chmod 0644 'fail2ban/action.d/iptables-common.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/action.d/iptables-common.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-ipset-proto4.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-ipset-proto6-allports.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-ipset-proto6.conf'
|
||||||
maybe chmod 0640 'fail2ban/action.d/iptables-ipset.conf'
|
maybe chmod 0640 'fail2ban/action.d/iptables-ipset.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-multiport-log.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-multiport.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-new.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables-xt_recent-echo.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/iptables.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/mail-whois-common.conf'
|
||||||
maybe chmod 0644 'fail2ban/action.d/mail.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/action.d/mail.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/mynetwatchman.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/netscaler.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/nftables-allports.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/nftables-multiport.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/nftables.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/nginx-block-map.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/npf.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/nsupdate.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/route.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-buffered.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-geoip-lines.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-whois-ipjailmatches.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-whois-ipmatches.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-whois-lines.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-whois-matches.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail-whois.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/sendmail.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/shorewall-ipset-proto6.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/smtp.py'
|
||||||
maybe chmod 0644 'fail2ban/action.d/smtp.py.rpmnew'
|
maybe chmod 0644 'fail2ban/action.d/smtp.py.rpmnew'
|
||||||
maybe chmod 0644 'fail2ban/action.d/smtp.py.rpmsave'
|
maybe chmod 0644 'fail2ban/action.d/smtp.py.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/symbiosis-blacklist-allports.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/action.d/xarf-login-attack.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/fail2ban.conf'
|
||||||
maybe chmod 0644 'fail2ban/fail2ban.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/fail2ban.conf.rpmsave'
|
||||||
|
maybe chmod 0755 'fail2ban/fail2ban.d'
|
||||||
maybe chmod 0755 'fail2ban/filter.d'
|
maybe chmod 0755 'fail2ban/filter.d'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/3proxy.conf'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/a.txt'
|
maybe chmod 0640 'fail2ban/filter.d/a.txt'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-badbots.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-botsearch.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-fakegooglebot.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-modsecurity.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-nohome.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-noscript.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-overflows.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-pass.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/apache-shellshock.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/assp.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/asterisk.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/bitwarden.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/botsearch-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/centreon.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/counter-strike.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/courier-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/courier-smtp.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/cyrus-imap.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/directadmin.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/domino-smtp.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/dovecot.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/dovecot.conf.rpmnew'
|
maybe chmod 0644 'fail2ban/filter.d/dovecot.conf.rpmnew'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/dovecot.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/filter.d/dovecot.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/dropbear.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/drupal-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/ejabberd-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/exim-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/exim-spam.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/exim.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/freeswitch.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/froxlor-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/gitlab.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/grafana.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/groupoffice.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/gssftpd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/guacamole.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/haproxy-http-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/horde.conf'
|
||||||
maybe chmod 0755 'fail2ban/filter.d/ignorecommands'
|
maybe chmod 0755 'fail2ban/filter.d/ignorecommands'
|
||||||
|
maybe chmod 0755 'fail2ban/filter.d/ignorecommands/apache-fakegooglebot'
|
||||||
maybe chmod 0755 'fail2ban/filter.d/ignorecommands/apache-fakegooglebot.rpmsave'
|
maybe chmod 0755 'fail2ban/filter.d/ignorecommands/apache-fakegooglebot.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/kerio.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/lighttpd-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/mongodb-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/monit.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/murmur.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/mysqld-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/nagios.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/named-refused.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/named-refused.conf.rpmnew'
|
maybe chmod 0644 'fail2ban/filter.d/named-refused.conf.rpmnew'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/named-refused.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/filter.d/named-refused.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/nginx-botsearch.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/nginx-botsearch.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/filter.d/nginx-botsearch.conf.rpmsave'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/nginx-forbidden.conf'
|
maybe chmod 0640 'fail2ban/filter.d/nginx-forbidden.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/nginx-http-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/nginx-limit-req.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/nsd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/openhab.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/openwebmail.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/oracleims.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/pam-generic.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/perdition.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/php-url-fopen.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/phpmyadmin-syslog.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/portsentry.conf'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/postfix-auth.conf'
|
maybe chmod 0640 'fail2ban/filter.d/postfix-auth.conf'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/postfix-rbl.conf'
|
maybe chmod 0640 'fail2ban/filter.d/postfix-rbl.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/postfix-sasl.conf'
|
maybe chmod 0644 'fail2ban/filter.d/postfix-sasl.conf'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/postfix-smtp-reject.conf'
|
maybe chmod 0640 'fail2ban/filter.d/postfix-smtp-reject.conf'
|
||||||
maybe chmod 0640 'fail2ban/filter.d/postfix-ssl-error.conf'
|
maybe chmod 0640 'fail2ban/filter.d/postfix-ssl-error.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/postfix.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/proftpd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/pure-ftpd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/qmail.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/recidive.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/recidive.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/filter.d/recidive.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/roundcube-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/screensharingd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/selinux-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/selinux-ssh.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/sendmail-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/sendmail-reject.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/sieve.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/slapd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/softethervpn.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/sogo-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/solid-pop3d.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/squid.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/squirrelmail.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/sshd.conf'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/sshd.conf.rpmnew'
|
maybe chmod 0644 'fail2ban/filter.d/sshd.conf.rpmnew'
|
||||||
maybe chmod 0644 'fail2ban/filter.d/sshd.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/filter.d/sshd.conf.rpmsave'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/stunnel.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/suhosin.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/tine20.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/traefik-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/uwimap-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/vsftpd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/webmin-auth.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/wuftpd.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/xinetd-fail.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/znc-adminlog.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/filter.d/zoneminder.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/jail.conf'
|
||||||
maybe chmod 0644 'fail2ban/jail.conf.rpmsave'
|
maybe chmod 0644 'fail2ban/jail.conf.rpmsave'
|
||||||
maybe chmod 0755 'fail2ban/jail.d'
|
maybe chmod 0755 'fail2ban/jail.d'
|
||||||
|
maybe chmod 0644 'fail2ban/jail.d/00-firewalld.conf'
|
||||||
maybe chmod 0640 'fail2ban/jail.d/default.conf'
|
maybe chmod 0640 'fail2ban/jail.d/default.conf'
|
||||||
maybe chmod 0644 'fail2ban/jail.d/recidive.conf'
|
maybe chmod 0644 'fail2ban/jail.d/recidive.conf'
|
||||||
maybe chmod 0640 'fail2ban/jail.local'
|
maybe chmod 0640 'fail2ban/jail.local'
|
||||||
|
maybe chmod 0644 'fail2ban/paths-common.conf'
|
||||||
|
maybe chmod 0644 'fail2ban/paths-fedora.conf'
|
||||||
maybe chmod 0644 'filesystems'
|
maybe chmod 0644 'filesystems'
|
||||||
maybe chmod 0750 'firewalld'
|
maybe chmod 0750 'firewalld'
|
||||||
|
maybe chmod 0644 'firewalld/firewalld.conf'
|
||||||
|
maybe chmod 0750 'firewalld/helpers'
|
||||||
|
maybe chmod 0750 'firewalld/icmptypes'
|
||||||
|
maybe chmod 0750 'firewalld/ipsets'
|
||||||
|
maybe chmod 0644 'firewalld/lockdown-whitelist.xml'
|
||||||
|
maybe chmod 0750 'firewalld/policies'
|
||||||
|
maybe chmod 0750 'firewalld/services'
|
||||||
maybe chmod 0750 'firewalld/zones'
|
maybe chmod 0750 'firewalld/zones'
|
||||||
maybe chmod 0644 'firewalld/zones/public.xml'
|
maybe chmod 0644 'firewalld/zones/public.xml'
|
||||||
maybe chmod 0755 'fonts'
|
maybe chmod 0755 'fonts'
|
||||||
@@ -2541,7 +2700,9 @@ maybe chmod 0644 'logrotate.d/btmp'
|
|||||||
maybe chmod 0644 'logrotate.d/chrony'
|
maybe chmod 0644 'logrotate.d/chrony'
|
||||||
maybe chmod 0644 'logrotate.d/clamav-unofficial-sigs'
|
maybe chmod 0644 'logrotate.d/clamav-unofficial-sigs'
|
||||||
maybe chmod 0644 'logrotate.d/dnf'
|
maybe chmod 0644 'logrotate.d/dnf'
|
||||||
|
maybe chmod 0644 'logrotate.d/fail2ban'
|
||||||
maybe chmod 0644 'logrotate.d/fail2ban.rpmsave'
|
maybe chmod 0644 'logrotate.d/fail2ban.rpmsave'
|
||||||
|
maybe chmod 0644 'logrotate.d/firewalld'
|
||||||
maybe chmod 0644 'logrotate.d/httpd'
|
maybe chmod 0644 'logrotate.d/httpd'
|
||||||
maybe chmod 0644 'logrotate.d/iptraf-ng'
|
maybe chmod 0644 'logrotate.d/iptraf-ng'
|
||||||
maybe chmod 0644 'logrotate.d/kvm_stat'
|
maybe chmod 0644 'logrotate.d/kvm_stat'
|
||||||
@@ -3316,6 +3477,7 @@ maybe chmod 0644 'mock/templates/rocky-8.tpl'
|
|||||||
maybe chmod 0755 'modprobe.d'
|
maybe chmod 0755 'modprobe.d'
|
||||||
maybe chmod 0644 'modprobe.d/blacklist-firewire.conf'
|
maybe chmod 0644 'modprobe.d/blacklist-firewire.conf'
|
||||||
maybe chmod 0640 'modprobe.d/cramfs.conf'
|
maybe chmod 0640 'modprobe.d/cramfs.conf'
|
||||||
|
maybe chmod 0644 'modprobe.d/firewalld-sysctls.conf'
|
||||||
maybe chmod 0644 'modprobe.d/lockd.conf'
|
maybe chmod 0644 'modprobe.d/lockd.conf'
|
||||||
maybe chmod 0644 'modprobe.d/mlx4.conf'
|
maybe chmod 0644 'modprobe.d/mlx4.conf'
|
||||||
maybe chmod 0644 'modprobe.d/nodccp.conf'
|
maybe chmod 0644 'modprobe.d/nodccp.conf'
|
||||||
@@ -3362,6 +3524,12 @@ maybe chmod 0755 'newrelic-infra/logging.d'
|
|||||||
maybe chmod 0644 'newrelic-infra/logging.d/postfix.yml'
|
maybe chmod 0644 'newrelic-infra/logging.d/postfix.yml'
|
||||||
maybe chmod 0644 'nfs.conf'
|
maybe chmod 0644 'nfs.conf'
|
||||||
maybe chmod 0644 'nfsmount.conf'
|
maybe chmod 0644 'nfsmount.conf'
|
||||||
|
maybe chmod 0700 'nftables'
|
||||||
|
maybe chmod 0600 'nftables/main.nft'
|
||||||
|
maybe chmod 0600 'nftables/nat.nft'
|
||||||
|
maybe chmod 0700 'nftables/osf'
|
||||||
|
maybe chmod 0600 'nftables/osf/pf.os'
|
||||||
|
maybe chmod 0600 'nftables/router.nft'
|
||||||
maybe chmod 0755 'nginx'
|
maybe chmod 0755 'nginx'
|
||||||
maybe chown 'nginx' 'nginx/.anaf'
|
maybe chown 'nginx' 'nginx/.anaf'
|
||||||
maybe chgrp 'nginx' 'nginx/.anaf'
|
maybe chgrp 'nginx' 'nginx/.anaf'
|
||||||
@@ -4963,6 +5131,8 @@ maybe chmod 0644 'sysconfig/chronyd'
|
|||||||
maybe chmod 0755 'sysconfig/console'
|
maybe chmod 0755 'sysconfig/console'
|
||||||
maybe chmod 0644 'sysconfig/cpupower'
|
maybe chmod 0644 'sysconfig/cpupower'
|
||||||
maybe chmod 0644 'sysconfig/crond'
|
maybe chmod 0644 'sysconfig/crond'
|
||||||
|
maybe chmod 0600 'sysconfig/ebtables-config'
|
||||||
|
maybe chmod 0644 'sysconfig/firewalld'
|
||||||
maybe chmod 0644 'sysconfig/firstboot'
|
maybe chmod 0644 'sysconfig/firstboot'
|
||||||
maybe chmod 0644 'sysconfig/garb'
|
maybe chmod 0644 'sysconfig/garb'
|
||||||
maybe chmod 0644 'sysconfig/htcacheclean'
|
maybe chmod 0644 'sysconfig/htcacheclean'
|
||||||
@@ -5011,6 +5181,7 @@ maybe chmod 0755 'sysconfig/network-scripts/init.ipv6-global'
|
|||||||
maybe chmod 0644 'sysconfig/network-scripts/network-functions'
|
maybe chmod 0644 'sysconfig/network-scripts/network-functions'
|
||||||
maybe chmod 0644 'sysconfig/network-scripts/network-functions-ipv6'
|
maybe chmod 0644 'sysconfig/network-scripts/network-functions-ipv6'
|
||||||
maybe chmod 0644 'sysconfig/network-scripts/route-eth0'
|
maybe chmod 0644 'sysconfig/network-scripts/route-eth0'
|
||||||
|
maybe chmod 0600 'sysconfig/nftables.conf'
|
||||||
maybe chmod 0644 'sysconfig/node_exporter'
|
maybe chmod 0644 'sysconfig/node_exporter'
|
||||||
maybe chmod 0644 'sysconfig/nrpe'
|
maybe chmod 0644 'sysconfig/nrpe'
|
||||||
maybe chmod 0644 'sysconfig/opendkim'
|
maybe chmod 0644 'sysconfig/opendkim'
|
||||||
|
|||||||
104
fail2ban/action.d/abuseipdb.conf
Normal file
104
fail2ban/action.d/abuseipdb.conf
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
# Fail2ban configuration file
|
||||||
|
#
|
||||||
|
# Action to report IP address to abuseipdb.com
|
||||||
|
# You must sign up to obtain an API key from abuseipdb.com.
|
||||||
|
#
|
||||||
|
# NOTE: These reports may include sensitive Info.
|
||||||
|
# If you want cleaner reports that ensure no user data see the helper script at the below website.
|
||||||
|
#
|
||||||
|
# IMPORTANT:
|
||||||
|
#
|
||||||
|
# Reporting an IP of abuse is a serious complaint. Make sure that it is
|
||||||
|
# serious. Fail2ban developers and network owners recommend you only use this
|
||||||
|
# action for:
|
||||||
|
# * The recidive where the IP has been banned multiple times
|
||||||
|
# * Where maxretry has been set quite high, beyond the normal user typing
|
||||||
|
# password incorrectly.
|
||||||
|
# * For filters that have a low likelihood of receiving human errors
|
||||||
|
#
|
||||||
|
# This action relies on a api_key being added to the above action conf,
|
||||||
|
# and the appropriate categories set.
|
||||||
|
#
|
||||||
|
# Example, for ssh bruteforce (in section [sshd] of `jail.local`):
|
||||||
|
# action = %(known/action)s
|
||||||
|
# abuseipdb[abuseipdb_apikey="my-api-key", abuseipdb_category="18,22"]
|
||||||
|
#
|
||||||
|
# See below for categories.
|
||||||
|
#
|
||||||
|
# Added to fail2ban by Andrew James Collett (ajcollett)
|
||||||
|
|
||||||
|
## abuseIPDB Categories, `the abuseipdb_category` MUST be set in the jail.conf action call.
|
||||||
|
# Example, for ssh bruteforce: action = %(action_abuseipdb)s[abuseipdb_category="18,22"]
|
||||||
|
# ID Title Description
|
||||||
|
# 3 Fraud Orders
|
||||||
|
# 4 DDoS Attack
|
||||||
|
# 9 Open Proxy
|
||||||
|
# 10 Web Spam
|
||||||
|
# 11 Email Spam
|
||||||
|
# 14 Port Scan
|
||||||
|
# 18 Brute-Force
|
||||||
|
# 19 Bad Web Bot
|
||||||
|
# 20 Exploited Host
|
||||||
|
# 21 Web App Attack
|
||||||
|
# 22 SSH Secure Shell (SSH) abuse. Use this category in combination with more specific categories.
|
||||||
|
# 23 IoT Targeted
|
||||||
|
# See https://abuseipdb.com/categories for more descriptions
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass action for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# Option: actionban
|
||||||
|
# Notes.: command executed when banning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
#
|
||||||
|
# ** IMPORTANT! **
|
||||||
|
#
|
||||||
|
# By default, this posts directly to AbuseIPDB's API, unfortunately
|
||||||
|
# this results in a lot of backslashes/escapes appearing in the
|
||||||
|
# reports. This also may include info like your hostname.
|
||||||
|
# If you have your own web server with PHP available, you can
|
||||||
|
# use my (Shaun's) helper PHP script by commenting out the first #actionban
|
||||||
|
# line below, uncommenting the second one, and pointing the URL at
|
||||||
|
# wherever you install the helper script. For the PHP helper script, see
|
||||||
|
# <https://wiki.shaunc.com/wikka.php?wakka=ReportingToAbuseIPDBWithFail2Ban>
|
||||||
|
#
|
||||||
|
# Tags: See jail.conf(5) man page
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionban = lgm=$(printf '%%.1000s\n...' "<matches>"); curl -sSf "https://api.abuseipdb.com/api/v2/report" -H "Accept: application/json" -H "Key: <abuseipdb_apikey>" --data-urlencode "comment=$lgm" --data-urlencode "ip=<ip>" --data "categories=<abuseipdb_category>"
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
# Option: abuseipdb_apikey
|
||||||
|
# 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 category in the action call.
|
||||||
|
abuseipdb_apikey =
|
||||||
25
fail2ban/action.d/apf.conf
Normal file
25
fail2ban/action.d/apf.conf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
# https://www.rfxn.com/projects/advanced-policy-firewall/
|
||||||
|
#
|
||||||
|
# Note: APF doesn't play nicely with other actions. It has been observed to
|
||||||
|
# remove bans created by other iptables based actions. If you are going to use
|
||||||
|
# this action, use it for all of your jails.
|
||||||
|
#
|
||||||
|
# DON'T MIX APF and other IPTABLES based actions
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart =
|
||||||
|
actionstop =
|
||||||
|
actioncheck =
|
||||||
|
actionban = apf --deny <ip> "banned by Fail2Ban <name>"
|
||||||
|
actionunban = apf --remove <ip>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Name used in APF configuration
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: Mark McKinstry
|
||||||
19
fail2ban/action.d/badips.conf
Normal file
19
fail2ban/action.d/badips.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Fail2ban reporting to badips.com
|
||||||
|
#
|
||||||
|
# Note: This reports an IP only and does not actually ban traffic. Use
|
||||||
|
# another action in the same jail if you want bans to occur.
|
||||||
|
#
|
||||||
|
# Set the category to the appropriate value before use.
|
||||||
|
#
|
||||||
|
# To get see register and optional key to get personalised graphs see:
|
||||||
|
# http://www.badips.com/blog/personalized-statistics-track-the-attackers-of-all-your-servers-with-one-key
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionban = curl --fail --user-agent "<agent>" http://www.badips.com/add/<category>/<ip>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: category
|
||||||
|
# Notes.: Values are from the list here: http://www.badips.com/get/categories
|
||||||
|
category =
|
||||||
392
fail2ban/action.d/badips.py
Normal file
392
fail2ban/action.d/badips.py
Normal file
@@ -0,0 +1,392 @@
|
|||||||
|
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
|
||||||
|
# vi: set ft=python sts=4 ts=4 sw=4 noet :
|
||||||
|
|
||||||
|
# This file is part of Fail2Ban.
|
||||||
|
#
|
||||||
|
# Fail2Ban is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Fail2Ban is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Fail2Ban; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
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, ): # pragma: 2.x no cover
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
else: # pragma: 3.x no cover
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
from fail2ban.server.actions import Actions, ActionBase, BanTicket
|
||||||
|
from fail2ban.helpers import splitwords, str2LogLevel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class BadIPsAction(ActionBase): # pragma: no cover - may be unavailable
|
||||||
|
"""Fail2Ban action which reports bans to badips.com, and also
|
||||||
|
blacklist bad IPs listed on badips.com by using another action's
|
||||||
|
ban method.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
jail : Jail
|
||||||
|
The jail which the action belongs to.
|
||||||
|
name : str
|
||||||
|
Name assigned to the action.
|
||||||
|
category : str
|
||||||
|
Valid badips.com category for reporting failures.
|
||||||
|
score : int, optional
|
||||||
|
Minimum score for bad IPs. Default 3.
|
||||||
|
age : str, optional
|
||||||
|
Age of last report for bad IPs, per badips.com syntax.
|
||||||
|
Default "24h" (24 hours)
|
||||||
|
banaction : str, optional
|
||||||
|
Name of banaction to use for blacklisting bad IPs. If `None`,
|
||||||
|
no blacklist of IPs will take place.
|
||||||
|
Default `None`.
|
||||||
|
bancategory : str, optional
|
||||||
|
Name of category to use for blacklisting, which can differ
|
||||||
|
from category used for reporting. e.g. may want to report
|
||||||
|
"postfix", but want to use whole "mail" category for blacklist.
|
||||||
|
Default `category`.
|
||||||
|
bankey : str, optional
|
||||||
|
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.`
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
ValueError
|
||||||
|
If invalid `category`, `score`, `banaction` or `updateperiod`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
TIMEOUT = 10
|
||||||
|
_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",
|
||||||
|
banaction=None, bancategory=None, bankey=None, updateperiod=900,
|
||||||
|
loglevel='DEBUG', agent="Fail2Ban", timeout=TIMEOUT):
|
||||||
|
super(BadIPsAction, self).__init__(jail, name)
|
||||||
|
|
||||||
|
self.timeout = timeout
|
||||||
|
self.agent = agent
|
||||||
|
self.category = category
|
||||||
|
self.score = score
|
||||||
|
self.age = age
|
||||||
|
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()
|
||||||
|
# Used later for threading.Timer for updating badips
|
||||||
|
self._timer = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def isAvailable(timeout=1):
|
||||||
|
try:
|
||||||
|
response = urlopen(Request("/".join([BadIPsAction._badips]),
|
||||||
|
headers={'User-Agent': "Fail2Ban"}), timeout=timeout)
|
||||||
|
return True, ''
|
||||||
|
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.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
set
|
||||||
|
Set of categories.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
HTTPError
|
||||||
|
Any issues with badips.com request.
|
||||||
|
ValueError
|
||||||
|
If badips.com response didn't contain necessary information
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
response = urlopen(
|
||||||
|
self._Request("/".join([self._badips, "get", "categories"])), timeout=self.timeout)
|
||||||
|
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'))
|
||||||
|
if not 'categories' in response_json:
|
||||||
|
err = "badips.com response lacked categories specification. Response was: %s" \
|
||||||
|
% (response_json,)
|
||||||
|
self._logSys.error(err)
|
||||||
|
raise ValueError(err)
|
||||||
|
categories = response_json['categories']
|
||||||
|
categories_names = set(
|
||||||
|
value['Name'] for value in categories)
|
||||||
|
if incParents:
|
||||||
|
categories_names.update(set(
|
||||||
|
value['Parent'] for value in categories
|
||||||
|
if "Parent" in value))
|
||||||
|
return categories_names
|
||||||
|
|
||||||
|
def getList(self, category, score, age, key=None):
|
||||||
|
"""Get badips.com list of bad IPs.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
category : str
|
||||||
|
Valid badips.com category.
|
||||||
|
score : int
|
||||||
|
Minimum score for bad IPs.
|
||||||
|
age : str
|
||||||
|
Age of last report for bad IPs, per badips.com syntax.
|
||||||
|
key : str, optional
|
||||||
|
Key issued by badips.com to fetch IPs reported with the
|
||||||
|
associated key.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
set
|
||||||
|
Set of bad IPs.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
HTTPError
|
||||||
|
Any issues with badips.com request.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
url = "?".join([
|
||||||
|
"/".join([self._badips, "get", "list", category, str(score)]),
|
||||||
|
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: # pragma: no cover
|
||||||
|
self.logError(response, "Failed to fetch bad IP list")
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
return set(response.read().decode('utf-8').split())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def category(self):
|
||||||
|
"""badips.com category for reporting IPs.
|
||||||
|
"""
|
||||||
|
return self._category
|
||||||
|
|
||||||
|
@category.setter
|
||||||
|
def category(self, category):
|
||||||
|
if category not in self.getCategories():
|
||||||
|
self._logSys.error("Category name '%s' not valid. "
|
||||||
|
"see badips.com for list of valid categories",
|
||||||
|
category)
|
||||||
|
raise ValueError("Invalid category: %s" % category)
|
||||||
|
self._category = category
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bancategory(self):
|
||||||
|
"""badips.com bancategory for fetching IPs.
|
||||||
|
"""
|
||||||
|
return self._bancategory
|
||||||
|
|
||||||
|
@bancategory.setter
|
||||||
|
def bancategory(self, bancategory):
|
||||||
|
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)
|
||||||
|
raise ValueError("Invalid bancategory: %s" % bancategory)
|
||||||
|
self._bancategory = bancategory
|
||||||
|
|
||||||
|
@property
|
||||||
|
def score(self):
|
||||||
|
"""badips.com minimum score for fetching IPs.
|
||||||
|
"""
|
||||||
|
return self._score
|
||||||
|
|
||||||
|
@score.setter
|
||||||
|
def score(self, score):
|
||||||
|
score = int(score)
|
||||||
|
if 0 <= score <= 5:
|
||||||
|
self._score = score
|
||||||
|
else:
|
||||||
|
raise ValueError("Score must be 0-5")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def banaction(self):
|
||||||
|
"""Jail action to use for banning/unbanning.
|
||||||
|
"""
|
||||||
|
return self._banaction
|
||||||
|
|
||||||
|
@banaction.setter
|
||||||
|
def banaction(self, banaction):
|
||||||
|
if banaction is not None and banaction not in self._jail.actions:
|
||||||
|
self._logSys.error("Action name '%s' not in jail '%s'",
|
||||||
|
banaction, self._jail.name)
|
||||||
|
raise ValueError("Invalid banaction")
|
||||||
|
self._banaction = banaction
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updateperiod(self):
|
||||||
|
"""Period in seconds between banned bad IPs will be updated.
|
||||||
|
"""
|
||||||
|
return self._updateperiod
|
||||||
|
|
||||||
|
@updateperiod.setter
|
||||||
|
def updateperiod(self, updateperiod):
|
||||||
|
updateperiod = int(updateperiod)
|
||||||
|
if updateperiod > 0:
|
||||||
|
self._updateperiod = updateperiod
|
||||||
|
else:
|
||||||
|
raise ValueError("Update period must be integer greater than 0")
|
||||||
|
|
||||||
|
def _banIPs(self, ips):
|
||||||
|
for ip in ips:
|
||||||
|
try:
|
||||||
|
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",
|
||||||
|
ip, self._jail.name, self.banaction, e,
|
||||||
|
exc_info=self._logSys.getEffectiveLevel()<=logging.DEBUG)
|
||||||
|
else:
|
||||||
|
self._bannedips.add(ip)
|
||||||
|
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:
|
||||||
|
ai = Actions.ActionInfo(BanTicket(ip), self._jail)
|
||||||
|
self._jail.actions[self.banaction].unban(ai)
|
||||||
|
except Exception as e:
|
||||||
|
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.log(self.loglevel,
|
||||||
|
"Unbanned IP %s for jail '%s' with action '%s'",
|
||||||
|
ip, self._jail.name, self.banaction)
|
||||||
|
finally:
|
||||||
|
self._bannedips.remove(ip)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
"""If `banaction` set, blacklists bad IPs.
|
||||||
|
"""
|
||||||
|
if self.banaction is not None:
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""If `banaction` set, updates blacklisted IPs.
|
||||||
|
|
||||||
|
Queries badips.com for list of bad IPs, removing IPs from the
|
||||||
|
blacklist if no longer present, and adds new bad IPs to the
|
||||||
|
blacklist.
|
||||||
|
"""
|
||||||
|
if self.banaction is not None:
|
||||||
|
if self._timer:
|
||||||
|
self._timer.cancel()
|
||||||
|
self._timer = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
ips = self.getList(
|
||||||
|
self.bancategory, self.score, self.age, self.bankey)
|
||||||
|
# Remove old IPs no longer listed
|
||||||
|
s = self._bannedips - ips
|
||||||
|
m = len(s)
|
||||||
|
self._unbanIPs(s)
|
||||||
|
# Add new IPs which are now listed
|
||||||
|
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)
|
||||||
|
self._timer.start()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
"""If `banaction` set, clears blacklisted IPs.
|
||||||
|
"""
|
||||||
|
if self.banaction is not None:
|
||||||
|
if self._timer:
|
||||||
|
self._timer.cancel()
|
||||||
|
self._timer = None
|
||||||
|
self._unbanIPs(self._bannedips.copy())
|
||||||
|
|
||||||
|
def ban(self, aInfo):
|
||||||
|
"""Reports banned IP to badips.com.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
aInfo : dict
|
||||||
|
Dictionary which includes information in relation to
|
||||||
|
the ban.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
HTTPError
|
||||||
|
Any issues with badips.com request.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
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: # pragma: no cover
|
||||||
|
self.logError(response, "Failed to ban")
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
messages = json.loads(response.read().decode('utf-8'))
|
||||||
|
self._logSys.debug(
|
||||||
|
"Response from badips.com report: '%s'",
|
||||||
|
messages['suc'])
|
||||||
|
|
||||||
|
Action = BadIPsAction
|
||||||
84
fail2ban/action.d/blocklist_de.conf
Normal file
84
fail2ban/action.d/blocklist_de.conf
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Steven Hiscocks
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
# Action to report IP address to blocklist.de
|
||||||
|
# Blocklist.de must be signed up to at www.blocklist.de
|
||||||
|
# Once registered, one or more servers can be added.
|
||||||
|
# This action requires the server 'email address' and the associated apikey.
|
||||||
|
#
|
||||||
|
# From blocklist.de:
|
||||||
|
# www.blocklist.de is a free and voluntary service provided by a
|
||||||
|
# Fraud/Abuse-specialist, whose servers are often attacked on SSH-,
|
||||||
|
# Mail-Login-, FTP-, Webserver- and other services.
|
||||||
|
# The mission is to report all attacks to the abuse departments of the
|
||||||
|
# infected PCs/servers to ensure that the responsible provider can inform
|
||||||
|
# the customer about the infection and disable them
|
||||||
|
#
|
||||||
|
# IMPORTANT:
|
||||||
|
#
|
||||||
|
# Reporting an IP of abuse is a serious complaint. Make sure that it is
|
||||||
|
# serious. Fail2ban developers and network owners recommend you only use this
|
||||||
|
# action for:
|
||||||
|
# * The recidive where the IP has been banned multiple times
|
||||||
|
# * Where maxretry has been set quite high, beyond the normal user typing
|
||||||
|
# password incorrectly.
|
||||||
|
# * For filters that have a low likelihood of receiving human errors
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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 = curl --fail --data-urlencode "server=<email>" --data "apikey=<apikey>" --data "service=<service>" --data "ip=<ip>" --data-urlencode "logs=<matches><br>" --data 'format=text' --user-agent "<agent>" "https://www.blocklist.de/en/httpreports.html"
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: email
|
||||||
|
# Notes server email address, as per blocklist.de account
|
||||||
|
# Values: STRING Default: None
|
||||||
|
#
|
||||||
|
#email =
|
||||||
|
|
||||||
|
# Option: apikey
|
||||||
|
# Notes your user blocklist.de user account apikey
|
||||||
|
# Values: STRING Default: None
|
||||||
|
#
|
||||||
|
#apikey =
|
||||||
|
|
||||||
|
# Option: service
|
||||||
|
# Notes service name you are reporting on, typically aligns with filter name
|
||||||
|
# see http://www.blocklist.de/en/httpreports.html for full list
|
||||||
|
# Values: STRING Default: None
|
||||||
|
#
|
||||||
|
#service =
|
||||||
83
fail2ban/action.d/cloudflare.conf
Normal file
83
fail2ban/action.d/cloudflare.conf
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#
|
||||||
|
# Author: Mike Rushton
|
||||||
|
#
|
||||||
|
# IMPORTANT
|
||||||
|
#
|
||||||
|
# Please set jail.local's permission to 640 because it contains your CF API key.
|
||||||
|
#
|
||||||
|
# This action depends on curl (and optionally jq).
|
||||||
|
# Referenced from http://www.normyee.net/blog/2012/02/02/adding-cloudflare-support-to-fail2ban by NORM YEE
|
||||||
|
#
|
||||||
|
# To get your CloudFlare API Key: https://www.cloudflare.com/a/account/my-account
|
||||||
|
#
|
||||||
|
# CloudFlare API error codes: https://www.cloudflare.com/docs/host-api.html#s4.2
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# Option: actionban
|
||||||
|
# Notes.: command executed when banning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
# Tags: <ip> IP address
|
||||||
|
# <failures> number of failures
|
||||||
|
# <time> unix timestamp of the ban time
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
# API v1
|
||||||
|
#actionban = curl -s -o /dev/null https://www.cloudflare.com/api_json.html -d 'a=ban' -d 'tkn=<cftoken>' -d 'email=<cfuser>' -d 'key=<ip>'
|
||||||
|
# API v4
|
||||||
|
actionban = curl -s -o /dev/null -X POST <_cf_api_prms> \
|
||||||
|
-d '{"mode":"block","configuration":{"target":"ip","value":"<ip>"},"notes":"Fail2Ban <name>"}' \
|
||||||
|
<_cf_api_url>
|
||||||
|
|
||||||
|
# Option: actionunban
|
||||||
|
# Notes.: command executed when unbanning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
# Tags: <ip> IP address
|
||||||
|
# <failures> number of failures
|
||||||
|
# <time> unix timestamp of the ban time
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
# API v1
|
||||||
|
#actionunban = curl -s -o /dev/null https://www.cloudflare.com/api_json.html -d 'a=nul' -d 'tkn=<cftoken>' -d 'email=<cfuser>' -d 'key=<ip>'
|
||||||
|
# API v4
|
||||||
|
actionunban = id=$(curl -s -X GET <_cf_api_prms> \
|
||||||
|
"<_cf_api_url>?mode=block&configuration_target=ip&configuration_value=<ip>&page=1&per_page=1¬es=Fail2Ban%%20<name>" \
|
||||||
|
| { jq -r '.result[0].id' 2>/dev/null || tr -d '\n' | sed -nE 's/^.*"result"\s*:\s*\[\s*\{\s*"id"\s*:\s*"([^"]+)".*$/\1/p'; })
|
||||||
|
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found"; exit 0; fi;
|
||||||
|
curl -s -o /dev/null -X DELETE <_cf_api_prms> "<_cf_api_url>/$id"
|
||||||
|
|
||||||
|
_cf_api_url = https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules
|
||||||
|
_cf_api_prms = -H 'X-Auth-Email: <cfuser>' -H 'X-Auth-Key: <cftoken>' -H 'Content-Type: application/json'
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# If you like to use this action with mailing whois lines, you could use the composite action
|
||||||
|
# action_cf_mwl predefined in jail.conf, just define in your jail:
|
||||||
|
#
|
||||||
|
# action = %(action_cf_mwl)s
|
||||||
|
# # Your CF account e-mail
|
||||||
|
# cfemail =
|
||||||
|
# # Your CF API Key
|
||||||
|
# cfapikey =
|
||||||
|
|
||||||
|
cftoken =
|
||||||
|
|
||||||
|
cfuser =
|
||||||
207
fail2ban/action.d/dshield.conf
Normal file
207
fail2ban/action.d/dshield.conf
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Russell Odom <russ@gloomytrousers.co.uk>
|
||||||
|
# Submits attack reports to DShield (http://www.dshield.org/)
|
||||||
|
#
|
||||||
|
# You MUST configure at least:
|
||||||
|
# <port> (the port that's being attacked - use number not name).
|
||||||
|
#
|
||||||
|
# You SHOULD also provide:
|
||||||
|
# <myip> (your public IP address, if it's not the address of eth0)
|
||||||
|
# <userid> (your DShield userID, if you have one - recommended, but reports will
|
||||||
|
# be used anonymously if not)
|
||||||
|
# <protocol> (the protocol in use - defaults to tcp)
|
||||||
|
#
|
||||||
|
# Best practice is to provide <port> and <protocol> in jail.conf like this:
|
||||||
|
# action = dshield[port=1234,protocol=tcp]
|
||||||
|
#
|
||||||
|
# ...and create "dshield.local" with contents something like this:
|
||||||
|
# [Init]
|
||||||
|
# myip = 10.0.0.1
|
||||||
|
# userid = 12345
|
||||||
|
#
|
||||||
|
# Other useful configuration values are <mailargs> (you can use for specifying
|
||||||
|
# a different sender address for the report e-mails, which should match what is
|
||||||
|
# configured at DShield), and <lines>/<minreportinterval>/<maxbufferage> (to
|
||||||
|
# configure how often the buffer is flushed).
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = if [ -f <tmpfile>.buffer ]; then
|
||||||
|
cat <tmpfile>.buffer | <mailcmd> "FORMAT DSHIELD USERID <userid> TZ `date +%%z | sed 's/\([+-]..\)\(..\)/\1:\2/'` Fail2Ban" <mailargs> <dest>
|
||||||
|
date +%%s > <tmpfile>.lastsent
|
||||||
|
fi
|
||||||
|
rm -f <tmpfile>.buffer <tmpfile>.first
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# See http://www.dshield.org/specs.html for more on report format/notes
|
||||||
|
#
|
||||||
|
# Note: We are currently using <time> for the timestamp because no tag is
|
||||||
|
# available to indicate the timestamp of the log message(s) which triggered the
|
||||||
|
# ban. Therefore the timestamps we are using in the report, whilst often only a
|
||||||
|
# few seconds out, are incorrect. See
|
||||||
|
# http://sourceforge.net/tracker/index.php?func=detail&aid=2017795&group_id=121032&atid=689047
|
||||||
|
#
|
||||||
|
actionban = TZONE=`date +%%z | sed 's/\([+-]..\)\(..\)/\1:\2/'`
|
||||||
|
DATETIME="`perl -e '@t=localtime(<time>);printf "%%4d-%%02d-%%02d %%02d:%%02d:%%02d",1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0]'` $TZONE"
|
||||||
|
PROTOCOL=`awk '{IGNORECASE=1;if($1=="<protocol>"){print $2;exit}}' /etc/protocols`
|
||||||
|
if [ -z "$PROTOCOL" ]; then PROTOCOL=<protocol>; fi
|
||||||
|
printf %%b "$DATETIME\t<userid>\t<failures>\t<ip>\t<srcport>\t<myip>\t<port>\t$PROTOCOL\t<tcpflags>\n" >> <tmpfile>.buffer
|
||||||
|
NOW=`date +%%s`
|
||||||
|
if [ ! -f <tmpfile>.first ]; then
|
||||||
|
echo <time> | cut -d. -f1 > <tmpfile>.first
|
||||||
|
fi
|
||||||
|
if [ ! -f <tmpfile>.lastsent ]; then
|
||||||
|
echo 0 > <tmpfile>.lastsent
|
||||||
|
fi
|
||||||
|
LOGAGE=$(($NOW - `cat <tmpfile>.first`))
|
||||||
|
LASTREPORT=$(($NOW - `cat <tmpfile>.lastsent`))
|
||||||
|
LINES=$( wc -l <tmpfile>.buffer | awk '{ print $1 }' )
|
||||||
|
if [ $LINES -ge <lines> && $LASTREPORT -gt <minreportinterval> ] || [ $LOGAGE -gt <maxbufferage> ]; then
|
||||||
|
cat <tmpfile>.buffer | <mailcmd> "FORMAT DSHIELD USERID <userid> TZ $TZONE Fail2Ban" <mailargs> <dest>
|
||||||
|
rm -f <tmpfile>.buffer <tmpfile>.first
|
||||||
|
echo $NOW > <tmpfile>.lastsent
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 = if [ -f <tmpfile>.first ]; then
|
||||||
|
NOW=`date +%%s`
|
||||||
|
LOGAGE=$(($NOW - `cat <tmpfile>.first`))
|
||||||
|
if [ $LOGAGE -gt <maxbufferage> ]; then
|
||||||
|
cat <tmpfile>.buffer | <mailcmd> "FORMAT DSHIELD USERID <userid> TZ `date +%%z | sed 's/\([+-]..\)\(..\)/\1:\2/'` Fail2Ban" <mailargs> <dest>
|
||||||
|
rm -f <tmpfile>.buffer <tmpfile>.first
|
||||||
|
echo $NOW > <tmpfile>.lastsent
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
# Option: port
|
||||||
|
# Notes.: The target port for the attack (numerical). MUST be provided in the
|
||||||
|
# jail config, as it cannot be detected here.
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
port = ???
|
||||||
|
|
||||||
|
# Option: userid
|
||||||
|
# Notes.: Your DShield user ID. Should be provided either in the jail config or
|
||||||
|
# in a .local file.
|
||||||
|
# Register at https://secure.dshield.org/register.html
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
userid = 0
|
||||||
|
|
||||||
|
# Option: myip
|
||||||
|
# Notes.: The target IP for the attack (your public IP). Should be provided
|
||||||
|
# either in the jail config or in a .local file unless your PUBLIC IP
|
||||||
|
# is the first IP assigned to eth0
|
||||||
|
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
||||||
|
# which in most cases will be a private IP, and therefore incorrect
|
||||||
|
#
|
||||||
|
myip = `ip -4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
||||||
|
|
||||||
|
# Option: protocol
|
||||||
|
# Notes.: The protocol over which the attack is happening
|
||||||
|
# Values: [ tcp | udp | icmp | (any other protocol name from /etc/protocols) | NUM ] Default: tcp
|
||||||
|
#
|
||||||
|
protocol = tcp
|
||||||
|
|
||||||
|
# Option: lines
|
||||||
|
# Notes.: How many lines to buffer before making a report. Regardless of this,
|
||||||
|
# reports are sent a minimum of <minreportinterval> apart, or if the
|
||||||
|
# buffer contains an event over <maxbufferage> old, or on shutdown
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
lines = 50
|
||||||
|
|
||||||
|
# Option: minreportinterval
|
||||||
|
# Notes.: Minimum period (in seconds) that must elapse before we submit another
|
||||||
|
# batch of reports. DShield request a minimum of 1 hour (3600 secs)
|
||||||
|
# between reports.
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
minreportinterval = 3600
|
||||||
|
|
||||||
|
# Option: maxbufferage
|
||||||
|
# Notes.: Maximum age (in seconds) of the oldest report in the buffer before we
|
||||||
|
# submit the batch, even if we haven't reached <lines> yet. Note that
|
||||||
|
# this is only checked on each ban/unban, and that we always send
|
||||||
|
# anything in the buffer on shutdown. Must be greater than
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
maxbufferage = 21600
|
||||||
|
|
||||||
|
# Option: srcport
|
||||||
|
# Notes.: The source port of the attack. You're unlikely to have this info, so
|
||||||
|
# you can leave the default
|
||||||
|
# Values: [ NUM ]
|
||||||
|
#
|
||||||
|
srcport = ???
|
||||||
|
|
||||||
|
# Option: tcpflags
|
||||||
|
# Notes.: TCP flags on attack. You're unlikely to have this info, so you can
|
||||||
|
# leave empty
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
tcpflags =
|
||||||
|
|
||||||
|
# Option: mailcmd
|
||||||
|
# Notes.: Your system mail command. Is passed 2 args: subject and recipient
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
mailcmd = mail -s
|
||||||
|
|
||||||
|
# Option: mailargs
|
||||||
|
# Notes.: Additional arguments to mail command. e.g. for standard Unix mail:
|
||||||
|
# CC reports to another address:
|
||||||
|
# -c me@example.com
|
||||||
|
# Appear to come from a different address (the From address must match
|
||||||
|
# the one configured at DShield - the '--' indicates arguments to be
|
||||||
|
# passed to Sendmail):
|
||||||
|
# -- -f me@example.com
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
mailargs =
|
||||||
|
|
||||||
|
# Option: dest
|
||||||
|
# Notes.: Destination e-mail address for reports
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
dest = reports@dshield.org
|
||||||
|
|
||||||
|
# Option: tmpfile
|
||||||
|
# Notes.: Base name of temporary files used for buffering
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
tmpfile = /var/run/fail2ban/tmp-dshield
|
||||||
|
|
||||||
63
fail2ban/action.d/dummy.conf
Normal file
63
fail2ban/action.d/dummy.conf
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = if [ ! -z '<target>' ]; then touch <target>; fi;
|
||||||
|
printf %%b "<init>\n" <to_target>
|
||||||
|
echo "%(debug)s started"
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush (clear) all IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = printf %%b "-*\n" <to_target>
|
||||||
|
echo "%(debug)s clear all"
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = if [ ! -z '<target>' ]; then rm -f <target>; fi;
|
||||||
|
echo "%(debug)s stopped"
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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 = printf %%b "+<ip>\n" <to_target>
|
||||||
|
echo "%(debug)s banned <ip> (family: <family>)"
|
||||||
|
|
||||||
|
# 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 = printf %%b "-<ip>\n" <to_target>
|
||||||
|
echo "%(debug)s unbanned <ip> (family: <family>)"
|
||||||
|
|
||||||
|
|
||||||
|
debug = [<name>] <actname> <target> --
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
init = 123
|
||||||
|
|
||||||
|
target = /var/run/fail2ban/fail2ban.dummy
|
||||||
|
to_target = >> <target>
|
||||||
45
fail2ban/action.d/firewallcmd-allports.conf
Normal file
45
fail2ban/action.d/firewallcmd-allports.conf
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Donald Yandt
|
||||||
|
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
||||||
|
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart = firewall-cmd --direct --add-chain <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --add-rule <family> filter f2b-<name> 1000 -j RETURN
|
||||||
|
firewall-cmd --direct --add-rule <family> filter <chain> 0 -j f2b-<name>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -j f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-rules <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-chain <family> filter f2b-<name>
|
||||||
|
|
||||||
|
|
||||||
|
# Example actioncheck: firewall-cmd --direct --get-chains ipv4 filter | sed -e 's, ,\n,g' | grep -q '^f2b-recidive$'
|
||||||
|
|
||||||
|
actioncheck = firewall-cmd --direct --get-chains <family> filter | sed -e 's, ,\n,g' | grep -q '^f2b-<name>$'
|
||||||
|
|
||||||
|
actionban = firewall-cmd --direct --add-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
actionunban = firewall-cmd --direct --remove-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: Donald Yandt
|
||||||
|
# Uses "FirewallD" instead of the "iptables daemon".
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Output:
|
||||||
|
|
||||||
|
# actionstart:
|
||||||
|
# $ firewall-cmd --direct --add-chain ipv4 filter f2b-recidive
|
||||||
|
# success
|
||||||
|
# $ firewall-cmd --direct --add-rule ipv4 filter f2b-recidive 1000 -j RETURN
|
||||||
|
# success
|
||||||
|
# $ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT_direct 0 -j f2b-recidive
|
||||||
|
# success
|
||||||
|
|
||||||
76
fail2ban/action.d/firewallcmd-common.conf
Normal file
76
fail2ban/action.d/firewallcmd-common.conf
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Donald Yandt
|
||||||
|
#
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: name
|
||||||
|
# Notes Default name of the chain
|
||||||
|
# Values: STRING
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Option port
|
||||||
|
# Notes Can also use port numbers separated by a comma and in rich-rules comma and/or space.
|
||||||
|
# Value STRING Default: 1:65535
|
||||||
|
port = 1:65535
|
||||||
|
|
||||||
|
# Option: protocol
|
||||||
|
# Notes [ tcp | udp | icmp | all ]
|
||||||
|
# Values: STRING Default: tcp
|
||||||
|
protocol = tcp
|
||||||
|
|
||||||
|
# Option: family(ipv4)
|
||||||
|
# Notes specifies the socket address family type
|
||||||
|
# Values: STRING
|
||||||
|
family = ipv4
|
||||||
|
|
||||||
|
# Option: chain
|
||||||
|
# Notes specifies the firewalld chain to which the Fail2Ban rules should be
|
||||||
|
# added
|
||||||
|
# Values: STRING Default: INPUT_direct
|
||||||
|
chain = INPUT_direct
|
||||||
|
|
||||||
|
# Option: zone
|
||||||
|
# Notes use command firewall-cmd --get-active-zones to see a list of all active zones. See firewalld man pages for more information on zones
|
||||||
|
# Values: STRING Default: public
|
||||||
|
zone = public
|
||||||
|
|
||||||
|
# Option: service
|
||||||
|
# Notes use command firewall-cmd --get-services to see a list of services available
|
||||||
|
# Examples services: amanda-client amanda-k5-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps
|
||||||
|
# freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target kadmin kerberos
|
||||||
|
# kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s
|
||||||
|
# postgresql privoxy proxy-dhcp puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp squid ssh synergy
|
||||||
|
# telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server
|
||||||
|
# Values: STRING Default: ssh
|
||||||
|
service = ssh
|
||||||
|
|
||||||
|
# Option: rejecttype (ipv4)
|
||||||
|
# Notes See iptables/firewalld man pages for ipv4 reject types.
|
||||||
|
# Values: STRING
|
||||||
|
rejecttype = icmp-port-unreachable
|
||||||
|
|
||||||
|
# Option: blocktype (ipv4/ipv6)
|
||||||
|
# Notes See iptables/firewalld man pages for jump targets. Common values are REJECT,
|
||||||
|
# REJECT --reject-with icmp-port-unreachable, DROP
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = REJECT --reject-with <rejecttype>
|
||||||
|
|
||||||
|
# Option: rich-blocktype (ipv4/ipv6)
|
||||||
|
# Notes See firewalld man pages for jump targets. Common values are reject,
|
||||||
|
# reject type="icmp-port-unreachable", drop
|
||||||
|
# Values: STRING
|
||||||
|
rich-blocktype = reject type='<rejecttype>'
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
# Option: family(ipv6)
|
||||||
|
# Notes specifies the socket address family type
|
||||||
|
# Values: STRING
|
||||||
|
family = ipv6
|
||||||
|
|
||||||
|
# Option: rejecttype (ipv6)
|
||||||
|
# Note: See iptables/firewalld man pages for ipv6 reject types.
|
||||||
|
# Values: STRING
|
||||||
|
rejecttype = icmp6-port-unreachable
|
||||||
88
fail2ban/action.d/firewallcmd-ipset.conf
Normal file
88
fail2ban/action.d/firewallcmd-ipset.conf
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# Fail2Ban action file for firewall-cmd/ipset
|
||||||
|
#
|
||||||
|
# This requires:
|
||||||
|
# ipset (package: ipset)
|
||||||
|
# firewall-cmd (package: firewalld)
|
||||||
|
#
|
||||||
|
# This is for ipset protocol 6 (and hopefully later) (ipset v6.14).
|
||||||
|
# Use ipset -V to see the protocol and version.
|
||||||
|
#
|
||||||
|
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels.
|
||||||
|
#
|
||||||
|
# If you are running on an older kernel you make need to patch in external
|
||||||
|
# modules.
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart = ipset create <ipmset> hash:ip timeout <default-ipsettime> <familyopt>
|
||||||
|
firewall-cmd --direct --add-rule <family> filter <chain> 0 <actiontype> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
|
||||||
|
actionflush = ipset flush <ipmset>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 <actiontype> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
<actionflush>
|
||||||
|
ipset destroy <ipmset>
|
||||||
|
|
||||||
|
actionban = ipset add <ipmset> <ip> timeout <ipsettime> -exist
|
||||||
|
|
||||||
|
# actionprolong = %(actionban)s
|
||||||
|
|
||||||
|
actionunban = ipset del <ipmset> <ip> -exist
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: chain
|
||||||
|
# Notes specifies the iptables chain to which the fail2ban rules should be
|
||||||
|
# added
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
chain = INPUT_direct
|
||||||
|
|
||||||
|
# Option: default-ipsettime
|
||||||
|
# Notes: specifies default timeout in seconds (handled default ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (no timeout, managed by fail2ban by unban)
|
||||||
|
default-ipsettime = 0
|
||||||
|
|
||||||
|
# Option: ipsettime
|
||||||
|
# Notes: specifies ticket timeout (handled ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (managed by fail2ban by unban)
|
||||||
|
ipsettime = 0
|
||||||
|
|
||||||
|
# expresion to caclulate timeout from bantime, example:
|
||||||
|
# banaction = %(known/banaction)s[ipsettime='<timeout-bantime>']
|
||||||
|
timeout-bantime = $([ "<bantime>" -le 2147483 ] && echo "<bantime>" || echo 0)
|
||||||
|
|
||||||
|
# Option: actiontype
|
||||||
|
# Notes.: defines additions to the blocking rule
|
||||||
|
# Values: leave empty to block all attempts from the host
|
||||||
|
# Default: Value of the multiport
|
||||||
|
actiontype = <multiport>
|
||||||
|
|
||||||
|
# Option: allports
|
||||||
|
# Notes.: default addition to block all ports
|
||||||
|
# Usage.: use in jail config: banaction = firewallcmd-ipset[actiontype=<allports>]
|
||||||
|
# for all protocols: banaction = firewallcmd-ipset[actiontype=""]
|
||||||
|
allports = -p <protocol>
|
||||||
|
|
||||||
|
# Option: multiport
|
||||||
|
# Notes.: addition to block access only to specific ports
|
||||||
|
# Usage.: use in jail config: banaction = firewallcmd-ipset[actiontype=<multiport>]
|
||||||
|
multiport = -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)"
|
||||||
|
|
||||||
|
ipmset = f2b-<name>
|
||||||
|
familyopt =
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
ipmset = f2b-<name>6
|
||||||
|
familyopt = family inet6
|
||||||
|
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: Edgar Hoch and Daniel Black
|
||||||
|
# firewallcmd-new / iptables-ipset-proto6 combined for maximium goodness
|
||||||
26
fail2ban/action.d/firewallcmd-multiport.conf
Normal file
26
fail2ban/action.d/firewallcmd-multiport.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Donald Yandt
|
||||||
|
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart = firewall-cmd --direct --add-chain <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --add-rule <family> filter f2b-<name> 1000 -j RETURN
|
||||||
|
firewall-cmd --direct --add-rule <family> filter <chain> 0 -m conntrack --ctstate NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -m conntrack --ctstate NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-rules <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-chain <family> filter f2b-<name>
|
||||||
|
|
||||||
|
# Example actioncheck: firewall-cmd --direct --get-chains ipv4 filter | sed -e 's, ,\n,g' | grep -q '^f2b-apache-modsecurity$'
|
||||||
|
|
||||||
|
actioncheck = firewall-cmd --direct --get-chains <family> filter | sed -e 's, ,\n,g' | grep -q '^f2b-<name>$'
|
||||||
|
|
||||||
|
actionban = firewall-cmd --direct --add-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
actionunban = firewall-cmd --direct --remove-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
47
fail2ban/action.d/firewallcmd-new.conf
Normal file
47
fail2ban/action.d/firewallcmd-new.conf
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart = firewall-cmd --direct --add-chain <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --add-rule <family> filter f2b-<name> 1000 -j RETURN
|
||||||
|
firewall-cmd --direct --add-rule <family> filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-rules <family> filter f2b-<name>
|
||||||
|
firewall-cmd --direct --remove-chain <family> filter f2b-<name>
|
||||||
|
|
||||||
|
actioncheck = firewall-cmd --direct --get-chains <family> filter | sed -e 's, ,\n,g' | grep -q 'f2b-<name>$'
|
||||||
|
|
||||||
|
actionban = firewall-cmd --direct --add-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
actionunban = firewall-cmd --direct --remove-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: Edgar Hoch
|
||||||
|
# Copied from iptables-new.conf and modified for use with firewalld by Edgar Hoch.
|
||||||
|
# It uses "firewall-cmd" instead of "iptables".
|
||||||
|
#
|
||||||
|
# Output:
|
||||||
|
#
|
||||||
|
# $ firewall-cmd --direct --add-chain ipv4 filter fail2ban-name
|
||||||
|
# success
|
||||||
|
# $ firewall-cmd --direct --add-rule ipv4 filter fail2ban-name 1000 -j RETURN
|
||||||
|
# success
|
||||||
|
# $ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT_direct 0 -m state --state NEW -p tcp -m multiport --dports 22 -j fail2ban-name
|
||||||
|
# success
|
||||||
|
# $ firewall-cmd --direct --get-chains ipv4 filter
|
||||||
|
# fail2ban-name
|
||||||
|
# $ firewall-cmd --direct --get-chains ipv4 filter | od -h
|
||||||
|
# 0000000 6166 6c69 6232 6e61 6e2d 6d61 0a65
|
||||||
|
# $ firewall-cmd --direct --get-chains ipv4 filter | grep -Eq 'fail2ban-name( |$)' ; echo $?
|
||||||
|
# 0
|
||||||
|
# $ firewall-cmd -V
|
||||||
|
# 0.3.8
|
||||||
|
|
||||||
29
fail2ban/action.d/firewallcmd-rich-logging.conf
Normal file
29
fail2ban/action.d/firewallcmd-rich-logging.conf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Authors: Donald Yandt, Sergey G. Brester
|
||||||
|
#
|
||||||
|
# Because of the rich rule commands requires firewalld-0.3.1+
|
||||||
|
# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not
|
||||||
|
# by chain. So for an example all deny rules will be listed under <zone>_deny and all log rules under <zone>_log.
|
||||||
|
#
|
||||||
|
# Also this action logs banned access attempts so you can filter that and increase ban time for offenders.
|
||||||
|
#
|
||||||
|
# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/<zone>.xml that can be shared and parsed easliy
|
||||||
|
#
|
||||||
|
# This is an derivative of firewallcmd-rich-rules.conf, see there for details and other parameters.
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-rich-rules.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
rich-suffix = log prefix='f2b-<name>' level='<level>' limit value='<rate>/m' <rich-blocktype>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# log levels are "emerg", "alert", "crit", "error", "warning", "notice", "info" or "debug"
|
||||||
|
level = info
|
||||||
|
|
||||||
|
# log rate per minute
|
||||||
|
rate = 1
|
||||||
44
fail2ban/action.d/firewallcmd-rich-rules.conf
Normal file
44
fail2ban/action.d/firewallcmd-rich-rules.conf
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Donald Yandt
|
||||||
|
#
|
||||||
|
# Because of the rich rule commands requires firewalld-0.3.1+
|
||||||
|
# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not
|
||||||
|
# by chain. So for an example all deny rules will be listed under <zone>_deny.
|
||||||
|
#
|
||||||
|
# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/<zone>.xml that can be shared and parsed easliy
|
||||||
|
#
|
||||||
|
# Example commands to view rules:
|
||||||
|
# firewall-cmd [--zone=<zone>] --list-rich-rules
|
||||||
|
# firewall-cmd [--zone=<zone>] --list-all
|
||||||
|
# firewall-cmd [--zone=zone] --query-rich-rule='rule'
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = firewallcmd-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
actionstart =
|
||||||
|
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
#you can also use zones and/or service names.
|
||||||
|
#
|
||||||
|
# zone example:
|
||||||
|
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' port port='<port>' protocol='<protocol>' <rich-blocktype>"
|
||||||
|
#
|
||||||
|
# service name example:
|
||||||
|
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' service name='<service>' <rich-blocktype>"
|
||||||
|
#
|
||||||
|
# Because rich rules can only handle single or a range of ports we must split ports and execute the command for each port. Ports can be single and ranges separated by a comma or space for an example: http, https, 22-60, 18 smtp
|
||||||
|
|
||||||
|
fwcmd_rich_rule = rule family='<family>' source address='<ip>' port port='$p' protocol='<protocol>' %(rich-suffix)s
|
||||||
|
|
||||||
|
actionban = ports="$(echo '<port>' | sed s/:/-/g)"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="%(fwcmd_rich_rule)s"; done
|
||||||
|
|
||||||
|
actionunban = ports="$(echo '<port>' | sed s/:/-/g)"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="%(fwcmd_rich_rule)s"; done
|
||||||
|
|
||||||
|
rich-suffix = <rich-blocktype>
|
||||||
17
fail2ban/action.d/helpers-common.conf
Normal file
17
fail2ban/action.d/helpers-common.conf
Normal file
@@ -0,0 +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="<logpath>"; grep <grepopts> %(_grep_logs_args)s $logpath | <greplimit>
|
||||||
|
# options `-wF` used to match only whole words and fixed string (not as pattern)
|
||||||
|
_grep_logs_args = -wF "<ip>"
|
||||||
|
|
||||||
|
# Used for actions, that should not by executed if ticket was restored:
|
||||||
|
_bypass_if_restored = if [ '<restored>' = '1' ]; then exit 0; fi;
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
greplimit = tail -n <grepmax>
|
||||||
|
grepmax = 1000
|
||||||
|
grepopts = -m <grepmax>
|
||||||
55
fail2ban/action.d/iptables-allports.conf
Normal file
55
fail2ban/action.d/iptables-allports.conf
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
|
# made active on all ports from original iptables.conf
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = <iptables> -N f2b-<name>
|
||||||
|
<iptables> -A f2b-<name> -j <returntype>
|
||||||
|
<iptables> -I <chain> -p <protocol> -j f2b-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> -j f2b-<name>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \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 = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# 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 = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
92
fail2ban/action.d/iptables-common.conf
Normal file
92
fail2ban/action.d/iptables-common.conf
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
#
|
||||||
|
# This is a included configuration file and includes the definitions for the iptables
|
||||||
|
# used in all iptables based actions by default.
|
||||||
|
#
|
||||||
|
# The user can override the defaults in iptables-common.local
|
||||||
|
#
|
||||||
|
# Modified: Alexander Koeppe <format_c@online.de>, Serg G. Brester <serg.brester@sebres.de>
|
||||||
|
# made config file IPv6 capable (see new section Init?family=inet6)
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
after = iptables-blocktype.local
|
||||||
|
iptables-common.local
|
||||||
|
# iptables-blocktype.local is obsolete
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = <iptables> -F f2b-<name>
|
||||||
|
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: chain
|
||||||
|
# Notes specifies the iptables chain to which the Fail2Ban rules should be
|
||||||
|
# added
|
||||||
|
# Values: STRING Default: INPUT
|
||||||
|
chain = INPUT
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
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 | icmp | all ] Default: tcp
|
||||||
|
#
|
||||||
|
protocol = tcp
|
||||||
|
|
||||||
|
# Option: blocktype
|
||||||
|
# Note: This is what the action does with rules. This can be any jump target
|
||||||
|
# as per the iptables man page (section 8). Common values are DROP
|
||||||
|
# REJECT, REJECT --reject-with icmp-port-unreachable
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = REJECT --reject-with icmp-port-unreachable
|
||||||
|
|
||||||
|
# Option: returntype
|
||||||
|
# Note: This is the default rule on "actionstart". This should be RETURN
|
||||||
|
# in all (blocking) actions, except REJECT in allowing actions.
|
||||||
|
# Values: STRING
|
||||||
|
returntype = RETURN
|
||||||
|
|
||||||
|
# Option: lockingopt
|
||||||
|
# Notes.: Option was introduced to iptables to prevent multiple instances from
|
||||||
|
# running concurrently and causing irratic behavior. -w was introduced
|
||||||
|
# in iptables 1.4.20, so might be absent on older systems
|
||||||
|
# See https://github.com/fail2ban/fail2ban/issues/1122
|
||||||
|
# Values: STRING
|
||||||
|
lockingopt = -w
|
||||||
|
|
||||||
|
# Option: iptables
|
||||||
|
# Notes.: Actual command to be executed, including common to all calls options
|
||||||
|
# Values: STRING
|
||||||
|
iptables = iptables <lockingopt>
|
||||||
|
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
# Option: blocktype (ipv6)
|
||||||
|
# Note: This is what the action does with rules. This can be any jump target
|
||||||
|
# as per the iptables man page (section 8). Common values are DROP
|
||||||
|
# REJECT, REJECT --reject-with icmp6-port-unreachable
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = REJECT --reject-with icmp6-port-unreachable
|
||||||
|
|
||||||
|
# Option: iptables (ipv6)
|
||||||
|
# Notes.: Actual command to be executed, including common to all calls options
|
||||||
|
# Values: STRING
|
||||||
|
iptables = ip6tables <lockingopt>
|
||||||
|
|
||||||
65
fail2ban/action.d/iptables-ipset-proto4.conf
Normal file
65
fail2ban/action.d/iptables-ipset-proto4.conf
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
#
|
||||||
|
# This is for ipset protocol 4 (ipset v4.2). If you have a later version
|
||||||
|
# of ipset try to use the iptables-ipset-proto6.conf as it does some things
|
||||||
|
# nicer.
|
||||||
|
#
|
||||||
|
# This requires the program ipset which is normally in package called ipset.
|
||||||
|
#
|
||||||
|
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels.
|
||||||
|
#
|
||||||
|
# If you are running on an older kernel you make need to patch in external
|
||||||
|
# modules. Debian squeeze can do this with:
|
||||||
|
# apt-get install xtables-addons-source
|
||||||
|
# module-assistant auto-install xtables-addons
|
||||||
|
#
|
||||||
|
# Debian wheezy and above uses protocol 6
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = ipset --create f2b-<name> iphash
|
||||||
|
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -m set --match-set f2b-<name> src -j <blocktype>
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = ipset --flush f2b-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -m set --match-set f2b-<name> src -j <blocktype>
|
||||||
|
<actionflush>
|
||||||
|
ipset --destroy f2b-<name>
|
||||||
|
|
||||||
|
# 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 = ipset --test f2b-<name> <ip> || ipset --add f2b-<name> <ip>
|
||||||
|
|
||||||
|
# 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 = ipset --test f2b-<name> <ip> && ipset --del f2b-<name> <ip>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
87
fail2ban/action.d/iptables-ipset-proto6-allports.conf
Normal file
87
fail2ban/action.d/iptables-ipset-proto6-allports.conf
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
#
|
||||||
|
# This is for ipset protocol 6 (and hopefully later) (ipset v6.14).
|
||||||
|
# Use ipset -V to see the protocol and version. Version 4 should use
|
||||||
|
# iptables-ipset-proto4.conf.
|
||||||
|
#
|
||||||
|
# This requires the program ipset which is normally in package called ipset.
|
||||||
|
#
|
||||||
|
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels.
|
||||||
|
#
|
||||||
|
# If you are running on an older kernel you make need to patch in external
|
||||||
|
# modules which probably won't be protocol version 6.
|
||||||
|
#
|
||||||
|
# Modified: Alexander Koeppe <format_c@online.de>, Serg G. Brester <serg.brester@sebres.de>
|
||||||
|
# made config file IPv6 capable (see new section Init?family=inet6)
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = ipset create <ipmset> hash:ip timeout <default-ipsettime> <familyopt>
|
||||||
|
<iptables> -I <chain> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = ipset flush <ipmset>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
<actionflush>
|
||||||
|
ipset destroy <ipmset>
|
||||||
|
|
||||||
|
# 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 = ipset add <ipmset> <ip> timeout <ipsettime> -exist
|
||||||
|
|
||||||
|
# actionprolong = %(actionban)s
|
||||||
|
|
||||||
|
# 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 = ipset del <ipmset> <ip> -exist
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: default-ipsettime
|
||||||
|
# Notes: specifies default timeout in seconds (handled default ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (no timeout, managed by fail2ban by unban)
|
||||||
|
default-ipsettime = 0
|
||||||
|
|
||||||
|
# Option: ipsettime
|
||||||
|
# Notes: specifies ticket timeout (handled ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (managed by fail2ban by unban)
|
||||||
|
ipsettime = 0
|
||||||
|
|
||||||
|
# expresion to caclulate timeout from bantime, example:
|
||||||
|
# banaction = %(known/banaction)s[ipsettime='<timeout-bantime>']
|
||||||
|
timeout-bantime = $([ "<bantime>" -le 2147483 ] && echo "<bantime>" || echo 0)
|
||||||
|
|
||||||
|
ipmset = f2b-<name>
|
||||||
|
familyopt =
|
||||||
|
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
ipmset = f2b-<name>6
|
||||||
|
familyopt = family inet6
|
||||||
87
fail2ban/action.d/iptables-ipset-proto6.conf
Normal file
87
fail2ban/action.d/iptables-ipset-proto6.conf
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
#
|
||||||
|
# This is for ipset protocol 6 (and hopefully later) (ipset v6.14).
|
||||||
|
# Use ipset -V to see the protocol and version. Version 4 should use
|
||||||
|
# iptables-ipset-proto4.conf.
|
||||||
|
#
|
||||||
|
# This requires the program ipset which is normally in package called ipset.
|
||||||
|
#
|
||||||
|
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels.
|
||||||
|
#
|
||||||
|
# If you are running on an older kernel you make need to patch in external
|
||||||
|
# modules.
|
||||||
|
#
|
||||||
|
# Modified: Alexander Koeppe <format_c@online.de>, Serg G. Brester <serg.brester@sebres.de>
|
||||||
|
# made config file IPv6 capable (see new section Init?family=inet6)
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = ipset create <ipmset> hash:ip timeout <default-ipsettime> <familyopt>
|
||||||
|
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = ipset flush <ipmset>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
<actionflush>
|
||||||
|
ipset destroy <ipmset>
|
||||||
|
|
||||||
|
# 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 = ipset add <ipmset> <ip> timeout <ipsettime> -exist
|
||||||
|
|
||||||
|
# actionprolong = %(actionban)s
|
||||||
|
|
||||||
|
# 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 = ipset del <ipmset> <ip> -exist
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: default-ipsettime
|
||||||
|
# Notes: specifies default timeout in seconds (handled default ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (no timeout, managed by fail2ban by unban)
|
||||||
|
default-ipsettime = 0
|
||||||
|
|
||||||
|
# Option: ipsettime
|
||||||
|
# Notes: specifies ticket timeout (handled ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (managed by fail2ban by unban)
|
||||||
|
ipsettime = 0
|
||||||
|
|
||||||
|
# expresion to caclulate timeout from bantime, example:
|
||||||
|
# banaction = %(known/banaction)s[ipsettime='<timeout-bantime>']
|
||||||
|
timeout-bantime = $([ "<bantime>" -le 2147483 ] && echo "<bantime>" || echo 0)
|
||||||
|
|
||||||
|
ipmset = f2b-<name>
|
||||||
|
familyopt =
|
||||||
|
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
ipmset = f2b-<name>6
|
||||||
|
familyopt = family inet6
|
||||||
68
fail2ban/action.d/iptables-multiport-log.conf
Normal file
68
fail2ban/action.d/iptables-multiport-log.conf
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Guido Bozzetto
|
||||||
|
# Modified: Cyril Jaquier
|
||||||
|
#
|
||||||
|
# make "f2b-<name>" chain to match drop IP
|
||||||
|
# make "f2b-<name>-log" chain to log and drop
|
||||||
|
# insert a jump to f2b-<name> from -I <chain> if proto/port match
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = <iptables> -N f2b-<name>
|
||||||
|
<iptables> -A f2b-<name> -j <returntype>
|
||||||
|
<iptables> -I <chain> 1 -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
||||||
|
<iptables> -N f2b-<name>-log
|
||||||
|
<iptables> -I f2b-<name>-log -j LOG --log-prefix "$(expr f2b-<name> : '\(.\{1,23\}\)'):DROP " --log-level warning -m limit --limit 6/m --limit-burst 2
|
||||||
|
<iptables> -A f2b-<name>-log -j <blocktype>
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionflush = <iptables> -F f2b-<name>
|
||||||
|
<iptables> -F f2b-<name>-log
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
<iptables> -X f2b-<name>-log
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L f2b-<name>-log >/dev/null
|
||||||
|
|
||||||
|
# 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 = <iptables> -I f2b-<name> 1 -s <ip> -j f2b-<name>-log
|
||||||
|
|
||||||
|
# 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 = <iptables> -D f2b-<name> -s <ip> -j f2b-<name>-log
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
52
fail2ban/action.d/iptables-multiport.conf
Normal file
52
fail2ban/action.d/iptables-multiport.conf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified by Yaroslav Halchenko for multiport banning
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = <iptables> -N f2b-<name>
|
||||||
|
<iptables> -A f2b-<name> -j <returntype>
|
||||||
|
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \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 = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# 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 = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
54
fail2ban/action.d/iptables-new.conf
Normal file
54
fail2ban/action.d/iptables-new.conf
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Copied from iptables.conf and modified by Yaroslav Halchenko
|
||||||
|
# to fulfill the needs of bugreporter dbts#350746.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = <iptables> -N f2b-<name>
|
||||||
|
<iptables> -A f2b-<name> -j <returntype>
|
||||||
|
<iptables> -I <chain> -m state --state NEW -p <protocol> --dport <port> -j f2b-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -m state --state NEW -p <protocol> --dport <port> -j f2b-<name>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \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 = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# 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 = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
79
fail2ban/action.d/iptables-xt_recent-echo.conf
Normal file
79
fail2ban/action.d/iptables-xt_recent-echo.conf
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
|
||||||
|
#
|
||||||
|
# Modified: Alexander Koeppe <format_c@online.de>, Serg G. Brester <serg.brester@sebres.de>
|
||||||
|
# made config file IPv6 capable
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# Changing iptables rules requires root privileges. If fail2ban is
|
||||||
|
# configured to run as root, firewall setup can be performed by
|
||||||
|
# fail2ban automatically. However, if fail2ban is configured to run as
|
||||||
|
# a normal user, the configuration must be done by some other means
|
||||||
|
# (e.g. using static firewall configuration with the
|
||||||
|
# iptables-persistent package).
|
||||||
|
#
|
||||||
|
# Explanation of the rule below:
|
||||||
|
# Check if any packets coming from an IP on the <iptname>
|
||||||
|
# list have been seen in the last 3600 seconds. If yes, update the
|
||||||
|
# timestamp for this IP and drop the packet. If not, let the packet
|
||||||
|
# through.
|
||||||
|
#
|
||||||
|
# Fail2ban inserts blacklisted hosts into the <iptname> list
|
||||||
|
# and removes them from the list after some time, according to its
|
||||||
|
# own rules. The 3600 second timeout is independent and acts as a
|
||||||
|
# safeguard in case the fail2ban process dies unexpectedly. The
|
||||||
|
# shorter of the two timeouts actually matters.
|
||||||
|
actionstart = if [ `id -u` -eq 0 ];then <iptables> -I <chain> -m recent --update --seconds 3600 --name <iptname> -j <blocktype>;fi
|
||||||
|
|
||||||
|
# Option: actionflush
|
||||||
|
#
|
||||||
|
# [TODO] Flushing is currently not implemented for xt_recent
|
||||||
|
#
|
||||||
|
actionflush =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = echo / > /proc/net/xt_recent/<iptname>
|
||||||
|
if [ `id -u` -eq 0 ];then <iptables> -D <chain> -m recent --update --seconds 3600 --name <iptname> -j <blocktype>;fi
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = test -e /proc/net/xt_recent/<iptname>
|
||||||
|
|
||||||
|
# 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 = echo +<ip> > /proc/net/xt_recent/<iptname>
|
||||||
|
|
||||||
|
# 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 = echo -<ip> > /proc/net/xt_recent/<iptname>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
iptname = f2b-<name>
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
iptname = f2b-<name>6
|
||||||
52
fail2ban/action.d/iptables.conf
Normal file
52
fail2ban/action.d/iptables.conf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = <iptables> -N f2b-<name>
|
||||||
|
<iptables> -A f2b-<name> -j <returntype>
|
||||||
|
<iptables> -I <chain> -p <protocol> --dport <port> -j f2b-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <iptables> -D <chain> -p <protocol> --dport <port> -j f2b-<name>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \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 = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# 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 = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
28
fail2ban/action.d/mail-whois-common.conf
Normal file
28
fail2ban/action.d/mail-whois-common.conf
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Common settings for mail actions
|
||||||
|
#
|
||||||
|
# Users can override the defaults in mail-whois-common.local
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Load customizations if any available
|
||||||
|
after = mail-whois-common.local
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
#original character set of whois output will be sent to mail program
|
||||||
|
_whois = whois <ip> || echo "missing whois program"
|
||||||
|
|
||||||
|
# use heuristics to convert charset of whois output to a target
|
||||||
|
# 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)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
|
||||||
|
# or other *.local which include mail-whois-common.conf.
|
||||||
|
_whois_command = %(_whois)s
|
||||||
|
#_whois_command = %(_whois_convert_charset)s
|
||||||
|
|
||||||
|
[Init]
|
||||||
143
fail2ban/action.d/mynetwatchman.conf
Normal file
143
fail2ban/action.d/mynetwatchman.conf
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Russell Odom <russ@gloomytrousers.co.uk>
|
||||||
|
# Submits attack reports to myNetWatchman (http://www.mynetwatchman.com/)
|
||||||
|
#
|
||||||
|
# You MUST configure at least:
|
||||||
|
# <port> (the port that's being attacked - use number not name).
|
||||||
|
# <mnwlogin> (your mNW login).
|
||||||
|
# <mnwpass> (your mNW password).
|
||||||
|
#
|
||||||
|
# You SHOULD also provide:
|
||||||
|
# <myip> (your public IP address, if it's not the address of eth0)
|
||||||
|
# <protocol> (the protocol in use - defaults to tcp)
|
||||||
|
#
|
||||||
|
# Best practice is to provide <port> and <protocol> in jail.conf like this:
|
||||||
|
# action = mynetwatchman[port=1234,protocol=udp]
|
||||||
|
#
|
||||||
|
# ...and create "mynetwatchman.local" with contents something like this:
|
||||||
|
# [Init]
|
||||||
|
# mnwlogin = me@example.com
|
||||||
|
# mnwpass = SECRET
|
||||||
|
# myip = 10.0.0.1
|
||||||
|
#
|
||||||
|
# Another useful configuration value is <getcmd>, if you don't have wget
|
||||||
|
# installed (an example config for curl is given below)
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Note: We are currently using <time> for the timestamp because no tag is
|
||||||
|
# available to indicate the timestamp of the log message(s) which triggered the
|
||||||
|
# ban. Therefore the timestamps we are using in the report, whilst often only a
|
||||||
|
# few seconds out, are incorrect. See
|
||||||
|
# http://sourceforge.net/tracker/index.php?func=detail&aid=2017795&group_id=121032&atid=689047
|
||||||
|
#
|
||||||
|
actionban = MNWLOGIN=`perl -e '$s=shift;$s=~s/([\W])/"%%".uc(sprintf("%%2.2x",ord($1)))/eg;print $s' '<mnwlogin>'`
|
||||||
|
MNWPASS=`perl -e '$s=shift;$s=~s/([\W])/"%%".uc(sprintf("%%2.2x",ord($1)))/eg;print $s' '<mnwpass>'`
|
||||||
|
PROTOCOL=`awk '{IGNORECASE=1;if($1=="<protocol>"){print $2;exit}}' /etc/protocols`
|
||||||
|
if [ -z "$PROTOCOL" ]; then PROTOCOL=<protocol>; fi
|
||||||
|
DATETIME=`perl -e '@t=gmtime(<time>);printf "%%4d-%%02d-%%02d+%%02d:%%02d:%%02d",1900+$t[5],$t[4]+1,$t[3],$t[2],$t[1],$t[0]'`
|
||||||
|
<getcmd> "<mnwurl>?AT=2&AV=0&AgentEmail=$MNWLOGIN&AgentPassword=$MNWPASS&AttackerIP=<ip>&SrcPort=<srcport>&ProtocolID=$PROTOCOL&DestPort=<port>&AttackCount=<failures>&VictimIP=<myip>&AttackDateTime=$DATETIME" 2>&1 >> <tmpfile>.out && grep -q 'Attack Report Insert Successful' <tmpfile>.out && rm -f <tmpfile>.out
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
# Option: port
|
||||||
|
# Notes.: The target port for the attack (numerical). MUST be provided in
|
||||||
|
# the jail config, as it cannot be detected here.
|
||||||
|
# Values: [ NUM ] Default: ???
|
||||||
|
#
|
||||||
|
port = 0
|
||||||
|
|
||||||
|
# Option: mnwlogin
|
||||||
|
# Notes.: Your mNW login e-mail address. MUST be provided either in the jail
|
||||||
|
# config or in a .local file.
|
||||||
|
# Register at http://www.mynetwatchman.com/reg.asp
|
||||||
|
# Values: [ STRING ] Default: (empty)
|
||||||
|
#
|
||||||
|
mnwlogin =
|
||||||
|
|
||||||
|
# Option: mnwpass
|
||||||
|
# Notes.: The password corresponding to your mNW login e-mail address. MUST be
|
||||||
|
# provided either in the jail config or in a .local file.
|
||||||
|
# Values: [ STRING ] Default: (empty)
|
||||||
|
#
|
||||||
|
mnwpass =
|
||||||
|
|
||||||
|
# Option: myip
|
||||||
|
# Notes.: The target IP for the attack (your public IP). Should be overridden
|
||||||
|
# either in the jail config or in a .local file unless your PUBLIC IP
|
||||||
|
# is the first IP assigned to eth0
|
||||||
|
# Values: [ an IP address ] Default: Tries to find the IP address of eth0,
|
||||||
|
# which in most cases will be a private IP, and therefore incorrect
|
||||||
|
#
|
||||||
|
myip = `ip -4 addr show dev eth0 | grep inet | head -n 1 | sed -r 's/.*inet ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/'`
|
||||||
|
|
||||||
|
# Option: protocol
|
||||||
|
# Notes.: The protocol over which the attack is happening
|
||||||
|
# Values: [ tcp | udp | icmp | (any other protocol name from /etc/protocols) | NUM ] Default: tcp
|
||||||
|
#
|
||||||
|
protocol = tcp
|
||||||
|
|
||||||
|
# Option: agent
|
||||||
|
# Default: Fail2ban
|
||||||
|
agent = Fail2ban
|
||||||
|
|
||||||
|
# Option: getcmd
|
||||||
|
# Notes.: A command to fetch a URL. Should output page to STDOUT
|
||||||
|
# Values: CMD Default: wget
|
||||||
|
#
|
||||||
|
getcmd = wget --no-verbose --tries=3 --waitretry=10 --connect-timeout=10 --read-timeout=60 --retry-connrefused --output-document=- --user-agent=<agent>
|
||||||
|
# Alternative value:
|
||||||
|
# getcmd = curl --silent --show-error --retry 3 --connect-timeout 10 --max-time 60 --user-agent <agent>
|
||||||
|
|
||||||
|
# Option: srcport
|
||||||
|
# Notes.: The source port of the attack. You're unlikely to have this info, so
|
||||||
|
# you can leave the default
|
||||||
|
# Values: [ NUM ] Default: 0
|
||||||
|
#
|
||||||
|
srcport = 0
|
||||||
|
|
||||||
|
# Option: mnwurl
|
||||||
|
# Notes.: The report service URL on the mNW site
|
||||||
|
# Values: STRING Default: http://mynetwatchman.com/insertwebreport.asp
|
||||||
|
#
|
||||||
|
mnwurl = http://mynetwatchman.com/insertwebreport.asp
|
||||||
|
|
||||||
|
# Option: tmpfile
|
||||||
|
# Notes.: Base name of temporary files
|
||||||
|
# Values: [ STRING ] Default: /var/run/fail2ban/tmp-mynetwatchman
|
||||||
|
#
|
||||||
|
tmpfile = /var/run/fail2ban/tmp-mynetwatchman
|
||||||
33
fail2ban/action.d/netscaler.conf
Normal file
33
fail2ban/action.d/netscaler.conf
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Fail2ban Citrix Netscaler Action
|
||||||
|
# by Juliano Jeziorny
|
||||||
|
# juliano@jeziorny.eu
|
||||||
|
#
|
||||||
|
# The script will add offender IPs to a dataset on netscaler, the dataset can then be used to block the IPs at a cs/vserver or global level
|
||||||
|
# This dataset is then used to block IPs using responder policies on the netscaler.
|
||||||
|
#
|
||||||
|
# The script assumes using HTTPS with unsecure certificate to access the netscaler,
|
||||||
|
# if you have a valid certificate installed remove the -k from the curl lines, or if you want http change it accordingly (and remove the -k)
|
||||||
|
#
|
||||||
|
# This action depends on curl
|
||||||
|
#
|
||||||
|
# You need to populate the 3 options inside Init
|
||||||
|
#
|
||||||
|
# ns_host: IP or hostname of netslcaer appliance
|
||||||
|
# ns_auth: username:password, suggest base64 encoded for a little added security (echo -n "username:password" | base64)
|
||||||
|
# ns_dataset: Name of the netscaler dataset holding the IPs to be blocked.
|
||||||
|
#
|
||||||
|
# For further details on how to use it please check http://blog.ckzone.eu/2017/01/fail2ban-action-for-citrix-netscaler.html
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
ns_host =
|
||||||
|
ns_auth =
|
||||||
|
ns_dataset =
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
actionstart = curl -kH 'Authorization: Basic <ns_auth>' https://<ns_host>/nitro/v1/config
|
||||||
|
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
actionban = curl -k -H 'Authorization: Basic <ns_auth>' -X PUT -d '{"policydataset_value_binding":{"name":"<ns_dataset>","value":"<ip>"}}' https://<ns_host>/nitro/v1/config/
|
||||||
|
|
||||||
|
actionunban = curl -H 'Authorization: Basic <ns_auth>' -X DELETE -k "https://<ns_host>/nitro/v1/config/policydataset_value_binding/<ns_dataset>?args=value:<ip>"
|
||||||
17
fail2ban/action.d/nftables-allports.conf
Normal file
17
fail2ban/action.d/nftables-allports.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
|
# made active on all ports from original iptables.conf
|
||||||
|
# Modified: Alexander Belykh <albel727@ngs.ru>
|
||||||
|
# adapted for nftables
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by nftables[type=allports]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = nftables.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = allports
|
||||||
17
fail2ban/action.d/nftables-multiport.conf
Normal file
17
fail2ban/action.d/nftables-multiport.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
|
# made active on all ports from original iptables.conf
|
||||||
|
# Modified: Alexander Belykh <albel727@ngs.ru>
|
||||||
|
# adapted for nftables
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by nftables[type=multiport]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = nftables.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = multiport
|
||||||
203
fail2ban/action.d/nftables.conf
Normal file
203
fail2ban/action.d/nftables.conf
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
|
# made active on all ports from original iptables.conf
|
||||||
|
# Modified: Alexander Belykh <albel727@ngs.ru>
|
||||||
|
# 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 \{ <protocol> \}
|
||||||
|
rule_match-multiport = $proto dport \{ $(echo '<port>' | sed s/:/-/g) \}
|
||||||
|
match = <rule_match-<type>>
|
||||||
|
|
||||||
|
# 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 <addr_family> saddr @<addr_set> <blocktype>
|
||||||
|
|
||||||
|
# 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 '<protocol>' | sed 's/,/ /g'); do
|
||||||
|
_nft_for_proto-multiport-done = done
|
||||||
|
|
||||||
|
_nft_list = <nftables> -a list chain <table_family> <table> <chain>
|
||||||
|
_nft_get_handle_id = grep -oP '@<addr_set>\s+.*\s+\Khandle\s+(\d+)$'
|
||||||
|
|
||||||
|
_nft_add_set = <nftables> add set <table_family> <table> <addr_set> \{ type <addr_type>\; \}
|
||||||
|
<_nft_for_proto-<type>-iter>
|
||||||
|
<nftables> add rule <table_family> <table> <chain> %(rule_stat)s
|
||||||
|
<_nft_for_proto-<type>-done>
|
||||||
|
_nft_del_set = { %(_nft_list)s | %(_nft_get_handle_id)s; } | while read -r hdl; do
|
||||||
|
<nftables> delete rule <table_family> <table> <chain> $hdl; done
|
||||||
|
<nftables> delete set <table_family> <table> <addr_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 = { <nftables> list table <table_family> <table> | grep -qP '^\s+set\s+'; } || {
|
||||||
|
<nftables> delete table <table_family> <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 = <nftables> add table <table_family> <table>
|
||||||
|
<nftables> -- add chain <table_family> <table> <chain> \{ type <chain_type> hook <chain_hook> priority <chain_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 = { <nftables> flush set <table_family> <table> <addr_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 = <nftables> list chain <table_family> <table> <chain> | grep -q '@<addr_set>[ \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 = <nftables> add element <table_family> <table> <addr_set> \{ <ip> \}
|
||||||
|
|
||||||
|
# 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 = <nftables> delete element <table_family> <table> <addr_set> \{ <ip> \}
|
||||||
|
|
||||||
|
[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-<name>
|
||||||
|
|
||||||
|
# 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-<name>
|
||||||
110
fail2ban/action.d/nginx-block-map.conf
Normal file
110
fail2ban/action.d/nginx-block-map.conf
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
# Fail2Ban configuration file for black-listing via nginx
|
||||||
|
#
|
||||||
|
# Author: Serg G. Brester (aka sebres)
|
||||||
|
#
|
||||||
|
# To use 'nginx-block-map' action you should define some special blocks in your nginx configuration,
|
||||||
|
# and use it hereafter in your locations (to notify fail2ban by failure, resp. nginx by ban).
|
||||||
|
#
|
||||||
|
# Example (argument "token_id" resp. cookie "session_id" used here as unique identifier for user):
|
||||||
|
#
|
||||||
|
# http {
|
||||||
|
# ...
|
||||||
|
# # maps to check user is blacklisted (banned in f2b):
|
||||||
|
# #map $arg_token_id $blck_lst_tok { include blacklisted-tokens.map; }
|
||||||
|
# map $cookie_session_id $blck_lst_ses { include blacklisted-sessions.map; }
|
||||||
|
# ...
|
||||||
|
# # special log-format to notify fail2ban about failures:
|
||||||
|
# log_format f2b_session_errors '$msec failure "$cookie_session_id" - $remote_addr - $remote_user '
|
||||||
|
# ;# '"$request" $status $bytes_sent '
|
||||||
|
# # '"$http_referer" "$http_user_agent"';
|
||||||
|
#
|
||||||
|
# # location checking blacklisted values:
|
||||||
|
# location ... {
|
||||||
|
# # check banned sessionid:
|
||||||
|
# if ($blck_lst_ses != "") {
|
||||||
|
# try_files "" @f2b-banned;
|
||||||
|
# }
|
||||||
|
# ...
|
||||||
|
# # notify fail2ban about a failure inside nginx:
|
||||||
|
# error_page 401 = @notify-f2b;
|
||||||
|
# ...
|
||||||
|
# }
|
||||||
|
# ...
|
||||||
|
# # location for return with "403 Forbidden" if banned:
|
||||||
|
# location @f2b-banned {
|
||||||
|
# default_type text/html;
|
||||||
|
# return 403 "<br/><center>
|
||||||
|
# <b style=\"color:red; font-size:18pt; border:2pt solid black; padding:5pt;\">
|
||||||
|
# You are banned!</b></center>";
|
||||||
|
# }
|
||||||
|
# ...
|
||||||
|
# # location to notify fail2ban about a failure inside nginx:
|
||||||
|
# location @notify-f2b {
|
||||||
|
# access_log /var/log/nginx/f2b-auth-errors.log f2b_session_errors;
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# ...
|
||||||
|
#
|
||||||
|
# Note that quote-character (and possibly other special characters) are not allowed currently as session-id.
|
||||||
|
# Thus please add any session-id validation rule in your locations (or in the corresponding backend-service),
|
||||||
|
# like in example below:
|
||||||
|
#
|
||||||
|
# location ... {
|
||||||
|
# if ($cookie_session_id !~ "^[\w\-]+$") {
|
||||||
|
# return 403 "Wrong session-id"
|
||||||
|
# }
|
||||||
|
# ...
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# The parameters for jail corresponding log-format (f2b_session_errors):
|
||||||
|
#
|
||||||
|
# [nginx-blck-lst]
|
||||||
|
# filter =
|
||||||
|
# datepattern = ^Epoch
|
||||||
|
# failregex = ^ failure "<F-ID>[^"]+</F-ID>" - <ADDR>
|
||||||
|
# usedns = no
|
||||||
|
#
|
||||||
|
# The same log-file can be used for IP-related jail (additionally to session-related, to ban very bad IPs):
|
||||||
|
#
|
||||||
|
# [nginx-blck-ip]
|
||||||
|
# maxretry = 100
|
||||||
|
# filter =
|
||||||
|
# datepattern = ^Epoch
|
||||||
|
# failregex = ^ failure "[^"]+" - <ADDR>
|
||||||
|
# usedns = no
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# path to configuration of nginx (used to target nginx-instance in multi-instance system,
|
||||||
|
# and as path for the blacklisted map):
|
||||||
|
srv_cfg_path = /etc/nginx/
|
||||||
|
|
||||||
|
# cmd-line arguments to supply to test/reload nginx:
|
||||||
|
#srv_cmd = nginx -c %(srv_cfg_path)s/nginx.conf
|
||||||
|
srv_cmd = nginx
|
||||||
|
|
||||||
|
# first test configuration is correct, hereafter send reload signal:
|
||||||
|
blck_lst_reload = %(srv_cmd)s -qt; if [ $? -eq 0 ]; then
|
||||||
|
%(srv_cmd)s -s reload; if [ $? -ne 0 ]; then echo 'reload failed.'; fi;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# map-file for nginx, can be redefined using `action = nginx-block-map[blck_lst_file="/path/file.map"]`:
|
||||||
|
blck_lst_file = %(srv_cfg_path)s/blacklisted-sessions.map
|
||||||
|
|
||||||
|
# Action definition:
|
||||||
|
|
||||||
|
actionstart_on_demand = false
|
||||||
|
actionstart = touch '%(blck_lst_file)s'
|
||||||
|
|
||||||
|
actionflush = truncate -s 0 '%(blck_lst_file)s'; %(blck_lst_reload)s
|
||||||
|
|
||||||
|
actionstop = %(actionflush)s
|
||||||
|
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
_echo_blck_row = printf '\%%s 1;\n' "<fid>"
|
||||||
|
|
||||||
|
actionban = %(_echo_blck_row)s >> '%(blck_lst_file)s'; %(blck_lst_reload)s
|
||||||
|
|
||||||
|
actionunban = id=$(%(_echo_blck_row)s | sed -e 's/[]\/$*.^|[]/\\&/g'); sed -i "/^$id$/d" %(blck_lst_file)s; %(blck_lst_reload)s
|
||||||
61
fail2ban/action.d/npf.conf
Normal file
61
fail2ban/action.d/npf.conf
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# NetBSD npf ban/unban
|
||||||
|
#
|
||||||
|
# Author: Nils Ratusznik <nils@NetBSD.org>
|
||||||
|
# Based on pf.conf action file
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# we don't enable NPF automatically, as it will be enabled elsewhere
|
||||||
|
actionstart =
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
# we don't disable NPF automatically either
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionban
|
||||||
|
# Notes.: command executed when banning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
# Tags: <ip> IP address
|
||||||
|
# <failures> number of failures
|
||||||
|
# <time> unix timestamp of the ban time
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionban = /sbin/npfctl table <tablename> add <ip>
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionunban
|
||||||
|
# Notes.: command executed when unbanning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
# Tags: <ip> IP address
|
||||||
|
# <failures> number of failures
|
||||||
|
# <time> unix timestamp of the ban time
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
# note -r option used to remove matching rule
|
||||||
|
actionunban = /sbin/npfctl table <tablename> rem <ip>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
# Option: tablename
|
||||||
|
# Notes.: The pf table name.
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
tablename = fail2ban
|
||||||
114
fail2ban/action.d/nsupdate.conf
Normal file
114
fail2ban/action.d/nsupdate.conf
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Andrew St. Jean
|
||||||
|
#
|
||||||
|
# Use nsupdate to perform dynamic DNS updates on a BIND zone file.
|
||||||
|
# One may want to do this to update a local RBL with banned IP addresses.
|
||||||
|
#
|
||||||
|
# Options
|
||||||
|
#
|
||||||
|
# domain DNS domain that will appear in nsupdate add and delete
|
||||||
|
# commands.
|
||||||
|
#
|
||||||
|
# ttl The time to live (TTL) in seconds of the TXT resource
|
||||||
|
# record.
|
||||||
|
#
|
||||||
|
# rdata Data portion of the TXT resource record.
|
||||||
|
#
|
||||||
|
# nsupdatecmd Full path to the nsupdate command.
|
||||||
|
#
|
||||||
|
# keyfile Full path to TSIG key file used for authentication between
|
||||||
|
# nsupdate and BIND.
|
||||||
|
#
|
||||||
|
# Create an nsupdate.local to set at least the <domain> and <keyfile>
|
||||||
|
# options as they don't have default values.
|
||||||
|
#
|
||||||
|
# The ban and unban commands assume nsupdate will authenticate to the BIND
|
||||||
|
# server using a TSIG key. The full path to the key file must be specified
|
||||||
|
# in the <keyfile> parameter. Use this command to generate your TSIG key.
|
||||||
|
#
|
||||||
|
# dnssec-keygen -a HMAC-MD5 -b 256 -n HOST <key_name>
|
||||||
|
#
|
||||||
|
# Replace <key_name> with some meaningful name.
|
||||||
|
#
|
||||||
|
# This command will generate two files. Specify the .private file in the
|
||||||
|
# <keyfile> option. Note that the .key file must also be present in the same
|
||||||
|
# directory for nsupdate to use the key.
|
||||||
|
#
|
||||||
|
# Don't forget to add the key and appropriate allow-update or update-policy
|
||||||
|
# option to your named.conf file.
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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 = echo <ip> | awk -F. '{print "prereq nxrrset "$4"."$3"."$2"."$1".<domain> TXT"; print "update add "$4"."$3"."$2"."$1".<domain> <ttl> IN TXT \"<rdata>\""; print "send"}' | <nsupdatecmd> -k <keyfile>
|
||||||
|
|
||||||
|
# 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 = echo <ip> | awk -F. '{print "update delete "$4"."$3"."$2"."$1".<domain>"; print "send"}' | <nsupdatecmd> -k <keyfile>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: domain
|
||||||
|
# Notes.: DNS domain that nsupdate will update.
|
||||||
|
# Values: STRING
|
||||||
|
#
|
||||||
|
domain =
|
||||||
|
|
||||||
|
# Option: ttl
|
||||||
|
# Notes.: time to live (TTL) in seconds of TXT resource record
|
||||||
|
# added by nsupdate.
|
||||||
|
# Values: NUM
|
||||||
|
#
|
||||||
|
ttl = 60
|
||||||
|
|
||||||
|
# Option: rdata
|
||||||
|
# Notes.: data portion of the TXT resource record added by nsupdate.
|
||||||
|
# Values: STRING
|
||||||
|
#
|
||||||
|
rdata = Your IP has been banned
|
||||||
|
|
||||||
|
# Option: nsupdatecmd
|
||||||
|
# Notes.: specifies the full path to the nsupdate program that dynamically
|
||||||
|
# updates BIND zone files.
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
nsupdatecmd = /usr/bin/nsupdate
|
||||||
|
|
||||||
|
# Option: keyfile
|
||||||
|
# Notes.: specifies the full path to the file containing the
|
||||||
|
# TSIG key for communicating with BIND.
|
||||||
|
# Values: STRING
|
||||||
|
#
|
||||||
|
keyfile =
|
||||||
|
|
||||||
29
fail2ban/action.d/route.conf
Normal file
29
fail2ban/action.d/route.conf
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Michael Gebetsroither
|
||||||
|
#
|
||||||
|
# This is for blocking whole hosts through blackhole routes.
|
||||||
|
#
|
||||||
|
# PRO:
|
||||||
|
# - Works on all kernel versions and as no compatibility problems (back to debian lenny and WAY further).
|
||||||
|
# - It's FAST for very large numbers of blocked ips.
|
||||||
|
# - It's FAST because it Blocks traffic before it enters common iptables chains used for filtering.
|
||||||
|
# - It's per host, ideal as action against ssh password bruteforcing to block further attack attempts.
|
||||||
|
# - No additional software required beside iproute/iproute2
|
||||||
|
#
|
||||||
|
# CON:
|
||||||
|
# - Blocking is per IP and NOT per service, but ideal as action against ssh password bruteforcing hosts
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
actionban = ip route add <blocktype> <ip>
|
||||||
|
actionunban = ip route del <blocktype> <ip>
|
||||||
|
actioncheck =
|
||||||
|
actionstart =
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: blocktype
|
||||||
|
# Note: Type can be blackhole, unreachable and prohibit. Unreachable and prohibit correspond to the ICMP reject messages.
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = unreachable
|
||||||
99
fail2ban/action.d/sendmail-buffered.conf
Normal file
99
fail2ban/action.d/sendmail-buffered.conf
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: started on <fq-hostname>
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Output will be buffered until <lines> lines are available.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = if [ -f <tmpfile> ]; then
|
||||||
|
printf %%b "Subject: [Fail2Ban] <name>: summary from <fq-hostname>
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
These hosts have been banned by Fail2Ban.\n
|
||||||
|
`cat <tmpfile>`
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
rm <tmpfile>
|
||||||
|
fi
|
||||||
|
printf %%b "Subject: [Fail2Ban] <name>: stopped on <fq-hostname>
|
||||||
|
From: Fail2Ban <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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 = printf %%b "`date`: <ip> (<failures> failures)\n" >> <tmpfile>
|
||||||
|
LINE=$( wc -l <tmpfile> | awk '{ print $1 }' )
|
||||||
|
if [ $LINE -ge <lines> ]; then
|
||||||
|
printf %%b "Subject: [Fail2Ban] <name>: summary from <fq-hostname>
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
These hosts have been banned by Fail2Ban.\n
|
||||||
|
`cat <tmpfile>`
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
rm <tmpfile>
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Default number of lines that are buffered
|
||||||
|
#
|
||||||
|
lines = 5
|
||||||
|
|
||||||
|
# Default temporary file
|
||||||
|
#
|
||||||
|
tmpfile = /var/run/fail2ban/tmp-mail.txt
|
||||||
|
|
||||||
77
fail2ban/action.d/sendmail-common.conf
Normal file
77
fail2ban/action.d/sendmail-common.conf
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Common settings for sendmail actions
|
||||||
|
#
|
||||||
|
# Users can override the defaults in sendmail-common.local
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
after = sendmail-common.local
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: started on <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = printf %%b "Subject: [Fail2Ban] <name>: stopped on <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Your system mail command
|
||||||
|
#
|
||||||
|
mailcmd = /usr/sbin/sendmail -f "<sender>" "<dest>"
|
||||||
|
|
||||||
|
# Recipient mail address
|
||||||
|
#
|
||||||
|
dest = root
|
||||||
|
|
||||||
|
# Sender mail address
|
||||||
|
#
|
||||||
|
sender = fail2ban
|
||||||
|
|
||||||
|
# Sender display name
|
||||||
|
#
|
||||||
|
sendername = Fail2Ban
|
||||||
59
fail2ban/action.d/sendmail-geoip-lines.conf
Normal file
59
fail2ban/action.d/sendmail-geoip-lines.conf
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Viktor Szépe
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
helpers-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# Option: actionban
|
||||||
|
# Notes.: Command executed when banning an IP. Take care that the
|
||||||
|
# command is executed with Fail2Ban user rights.
|
||||||
|
# You need to install geoiplookup and the GeoLite or GeoIP databases.
|
||||||
|
# (geoip-bin and geoip-database in Debian)
|
||||||
|
# The host command comes from bind9-host package.
|
||||||
|
# Tags: See jail.conf(5) man page
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionban = ( printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n
|
||||||
|
http://bgp.he.net/ip/<ip>
|
||||||
|
http://www.projecthoneypot.org/ip_<ip>
|
||||||
|
http://whois.domaintools.com/<ip>\n\n
|
||||||
|
Country:`geoiplookup -f /usr/share/GeoIP/GeoIP.dat "<ip>" | cut -d':' -f2-`
|
||||||
|
AS:`geoiplookup -f /usr/share/GeoIP/GeoIPASNum.dat "<ip>" | cut -d':' -f2-`
|
||||||
|
hostname: <ip-host>\n\n
|
||||||
|
Lines containing failures of <ip> (max <grepmax>)\n";
|
||||||
|
%(_grep_logs)s;
|
||||||
|
printf %%b "\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" ) | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Path to the log files which contain relevant lines for the abuser IP
|
||||||
|
#
|
||||||
|
logpath = /dev/null
|
||||||
|
|
||||||
|
# Number of log lines to include in the email
|
||||||
|
#
|
||||||
|
#grepmax = 1000
|
||||||
|
#grepopts = -m <grepmax>
|
||||||
41
fail2ban/action.d/sendmail-whois-ipjailmatches.conf
Normal file
41
fail2ban/action.d/sendmail-whois-ipjailmatches.conf
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
mail-whois-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n
|
||||||
|
`%(_whois_command)s`\n\n
|
||||||
|
Matches for <name> with <ipjailfailures> failures IP:<ip>\n
|
||||||
|
<ipjailmatches>\n\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
41
fail2ban/action.d/sendmail-whois-ipmatches.conf
Normal file
41
fail2ban/action.d/sendmail-whois-ipmatches.conf
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
mail-whois-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n
|
||||||
|
`%(_whois_command)s`\n\n
|
||||||
|
Matches with <ipfailures> failures IP:<ip>\n
|
||||||
|
<ipmatches>\n\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
52
fail2ban/action.d/sendmail-whois-lines.conf
Normal file
52
fail2ban/action.d/sendmail-whois-lines.conf
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
mail-whois-common.conf
|
||||||
|
helpers-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = ( printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n"
|
||||||
|
%(_whois_command)s;
|
||||||
|
printf %%b "\nLines containing failures of <ip> (max <grepmax>)\n";
|
||||||
|
%(_grep_logs)s;
|
||||||
|
printf %%b "\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" ) | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Path to the log files which contain relevant lines for the abuser IP
|
||||||
|
#
|
||||||
|
logpath = /dev/null
|
||||||
|
|
||||||
|
# Number of log lines to include in the email
|
||||||
|
#
|
||||||
|
#grepmax = 1000
|
||||||
|
#grepopts = -m <grepmax>
|
||||||
41
fail2ban/action.d/sendmail-whois-matches.conf
Normal file
41
fail2ban/action.d/sendmail-whois-matches.conf
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
mail-whois-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n
|
||||||
|
`%(_whois_command)s`\n\n
|
||||||
|
Matches:\n
|
||||||
|
<matches>\n\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
40
fail2ban/action.d/sendmail-whois.conf
Normal file
40
fail2ban/action.d/sendmail-whois.conf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
mail-whois-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n\n
|
||||||
|
Here is more information about <ip> :\n
|
||||||
|
`%(_whois_command)s`\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
37
fail2ban/action.d/sendmail.conf
Normal file
37
fail2ban/action.d/sendmail.conf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = sendmail-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
# 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 = printf %%b "Subject: [Fail2Ban] <name>: banned <ip> from <fq-hostname>
|
||||||
|
Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
From: <sendername> <<sender>>
|
||||||
|
To: <dest>\n
|
||||||
|
Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
93
fail2ban/action.d/shorewall-ipset-proto6.conf
Normal file
93
fail2ban/action.d/shorewall-ipset-proto6.conf
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Eduardo Diaz
|
||||||
|
#
|
||||||
|
# This is for ipset protocol 6 (and hopefully later) (ipset v6.14).
|
||||||
|
# for shorewall
|
||||||
|
#
|
||||||
|
# Use this setting in jail.conf to modify use this action instead of a
|
||||||
|
# default one
|
||||||
|
#
|
||||||
|
# banaction = shorewall-ipset-proto6
|
||||||
|
#
|
||||||
|
# This requires the program ipset which is normally in package called ipset.
|
||||||
|
#
|
||||||
|
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0
|
||||||
|
# kernels, and you need Shorewall >= 4.5.5 to use this action.
|
||||||
|
#
|
||||||
|
# The default Shorewall configuration is with "BLACKLISTNEWONLY=Yes" (see
|
||||||
|
# file /etc/shorewall/shorewall.conf). This means that when Fail2ban adds a
|
||||||
|
# new shorewall rule to ban an IP address, that rule will affect only new
|
||||||
|
# connections. So if the attacker 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".
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Enable shorewall to use a blacklist using iptables creating a file
|
||||||
|
# /etc/shorewall/blrules and adding "DROP net:+f2b-ssh all" and
|
||||||
|
# similar lines for every jail. To enable restoring you ipset you
|
||||||
|
# must set SAVE_IPSETS=Yes in shorewall.conf . You can read more
|
||||||
|
# about ipsets handling in Shorewall at http://shorewall.net/ipsets.html
|
||||||
|
#
|
||||||
|
# To force creation of the ipset in the case that somebody deletes the
|
||||||
|
# ipset create a file /etc/shorewall/initdone and add one line for
|
||||||
|
# every ipset (this files are in Perl) and add 1 at the end of the file.
|
||||||
|
# The example:
|
||||||
|
# system("/usr/sbin/ipset -quiet -exist create f2b-ssh hash:ip timeout 600 ");
|
||||||
|
# 1;
|
||||||
|
#
|
||||||
|
# To destroy the ipset in shorewall you must add to the file /etc/shorewall/stopped
|
||||||
|
# # One line of every ipset
|
||||||
|
# system("/usr/sbin/ipset -quiet destroy f2b-ssh ");
|
||||||
|
# 1; # This must go to the end of the file if not shorewall compilation fails
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 = if ! ipset -quiet -name list f2b-<name> >/dev/null;
|
||||||
|
then ipset -quiet -exist create f2b-<name> hash:ip timeout <default-ipsettime>;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = ipset flush f2b-<name>
|
||||||
|
|
||||||
|
# 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 = ipset add f2b-<name> <ip> timeout <ipsettime> -exist
|
||||||
|
|
||||||
|
# actionprolong = %(actionban)s
|
||||||
|
|
||||||
|
# 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 = ipset del f2b-<name> <ip> -exist
|
||||||
|
|
||||||
|
# Option: default-ipsettime
|
||||||
|
# Notes: specifies default timeout in seconds (handled default ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (no timeout, managed by fail2ban by unban)
|
||||||
|
default-ipsettime = 0
|
||||||
|
|
||||||
|
# Option: ipsettime
|
||||||
|
# Notes: specifies ticket timeout (handled ipset timeout only)
|
||||||
|
# Values: [ NUM ] Default: 0 (managed by fail2ban by unban)
|
||||||
|
ipsettime = 0
|
||||||
|
|
||||||
|
# expresion to caclulate timeout from bantime, example:
|
||||||
|
# banaction = %(known/banaction)s[ipsettime='<timeout-bantime>']
|
||||||
|
timeout-bantime = $([ "<bantime>" -le 2147483 ] && echo "<bantime>" || echo 0)
|
||||||
230
fail2ban/action.d/smtp.py
Normal file
230
fail2ban/action.d/smtp.py
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*-
|
||||||
|
# vi: set ft=python sts=4 ts=4 sw=4 noet :
|
||||||
|
|
||||||
|
# This file is part of Fail2Ban.
|
||||||
|
#
|
||||||
|
# Fail2Ban is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Fail2Ban is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Fail2Ban; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import smtplib
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
from email.utils import formatdate, formataddr
|
||||||
|
|
||||||
|
from fail2ban.server.actions import ActionBase, CallingMap
|
||||||
|
|
||||||
|
messages = {}
|
||||||
|
messages['start'] = \
|
||||||
|
"""Hi,
|
||||||
|
|
||||||
|
The jail %(jailname)s has been started successfully.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
Fail2Ban"""
|
||||||
|
|
||||||
|
messages['stop'] = \
|
||||||
|
"""Hi,
|
||||||
|
|
||||||
|
The jail %(jailname)s has been stopped.
|
||||||
|
|
||||||
|
Regards,
|
||||||
|
Fail2Ban"""
|
||||||
|
|
||||||
|
messages['ban'] = {}
|
||||||
|
messages['ban']['head'] = \
|
||||||
|
"""Hi,
|
||||||
|
|
||||||
|
The IP %(ip)s has just been banned for %(bantime)i seconds
|
||||||
|
by Fail2Ban after %(failures)i attempts against %(jailname)s.
|
||||||
|
"""
|
||||||
|
messages['ban']['tail'] = \
|
||||||
|
"""
|
||||||
|
Regards,
|
||||||
|
Fail2Ban"""
|
||||||
|
messages['ban']['matches'] = \
|
||||||
|
"""
|
||||||
|
Matches for this ban:
|
||||||
|
%(matches)s
|
||||||
|
"""
|
||||||
|
messages['ban']['ipmatches'] = \
|
||||||
|
"""
|
||||||
|
Matches for %(ip)s:
|
||||||
|
%(ipmatches)s
|
||||||
|
"""
|
||||||
|
messages['ban']['ipjailmatches'] = \
|
||||||
|
"""
|
||||||
|
Matches for %(ip)s for jail %(jailname)s:
|
||||||
|
%(ipjailmatches)s
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class SMTPAction(ActionBase):
|
||||||
|
"""Fail2Ban action which sends emails to inform on jail starting,
|
||||||
|
stopping and bans.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, jail, name, host="localhost", user=None, password=None,
|
||||||
|
sendername="Fail2Ban", sender="fail2ban", dest="root", matches=None):
|
||||||
|
"""Initialise action.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
jail : Jail
|
||||||
|
The jail which the action belongs to.
|
||||||
|
name : str
|
||||||
|
Named assigned to the action.
|
||||||
|
host : str, optional
|
||||||
|
SMTP host, of host:port format. Default host "localhost" and
|
||||||
|
port "25"
|
||||||
|
user : str, optional
|
||||||
|
Username used for authentication with SMTP server.
|
||||||
|
password : str, optional
|
||||||
|
Password used for authentication with SMTP server.
|
||||||
|
sendername : str, optional
|
||||||
|
Name to use for from address in email. Default "Fail2Ban".
|
||||||
|
sender : str, optional
|
||||||
|
Email address to use for from address in email.
|
||||||
|
Default "fail2ban".
|
||||||
|
dest : str, optional
|
||||||
|
Email addresses of intended recipient(s) in comma space ", "
|
||||||
|
delimited format. Default "root".
|
||||||
|
matches : str, optional
|
||||||
|
Type of matches to be included from ban in email. Can be one
|
||||||
|
of "matches", "ipmatches" or "ipjailmatches". Default None
|
||||||
|
(see man jail.conf.5).
|
||||||
|
"""
|
||||||
|
|
||||||
|
super(SMTPAction, self).__init__(jail, name)
|
||||||
|
|
||||||
|
self.host = host
|
||||||
|
#TODO: self.ssl = ssl
|
||||||
|
|
||||||
|
self.user = user
|
||||||
|
self.password =password
|
||||||
|
|
||||||
|
self.fromname = sendername
|
||||||
|
self.fromaddr = sender
|
||||||
|
self.toaddr = dest
|
||||||
|
|
||||||
|
self.matches = matches
|
||||||
|
|
||||||
|
self.message_values = CallingMap(
|
||||||
|
jailname = self._jail.name,
|
||||||
|
hostname = socket.gethostname,
|
||||||
|
bantime = lambda: self._jail.actions.getBanTime(),
|
||||||
|
)
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
self.norestored = 1
|
||||||
|
|
||||||
|
def _sendMessage(self, subject, text):
|
||||||
|
"""Sends message based on arguments and instance's properties.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
subject : str
|
||||||
|
Subject of the email.
|
||||||
|
text : str
|
||||||
|
Body of the email.
|
||||||
|
|
||||||
|
Raises
|
||||||
|
------
|
||||||
|
SMTPConnectionError
|
||||||
|
Error on connecting to host.
|
||||||
|
SMTPAuthenticationError
|
||||||
|
Error authenticating with SMTP server.
|
||||||
|
SMTPException
|
||||||
|
See Python `smtplib` for full list of other possible
|
||||||
|
exceptions.
|
||||||
|
"""
|
||||||
|
msg = MIMEText(text)
|
||||||
|
msg['Subject'] = subject
|
||||||
|
msg['From'] = formataddr((self.fromname, self.fromaddr))
|
||||||
|
msg['To'] = self.toaddr
|
||||||
|
msg['Date'] = formatdate()
|
||||||
|
|
||||||
|
smtp = smtplib.SMTP()
|
||||||
|
try:
|
||||||
|
self._logSys.debug("Connected to SMTP '%s', response: %i: %s",
|
||||||
|
self.host, *smtp.connect(self.host))
|
||||||
|
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: # pragma: no cover
|
||||||
|
self._logSys.error("Error connecting to host '%s'", self.host)
|
||||||
|
raise
|
||||||
|
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: # 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: # pragma: no cover
|
||||||
|
self._logSys.warning(
|
||||||
|
"Email to '%s' failed to following recipients: %r",
|
||||||
|
self.toaddr, failed_recipients)
|
||||||
|
self._logSys.debug("Email '%s' successfully sent", subject)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
self._logSys.debug("Disconnected from '%s', response %i: %s",
|
||||||
|
self.host, *smtp.quit())
|
||||||
|
except smtplib.SMTPServerDisconnected: # pragma: no cover
|
||||||
|
pass # Not connected
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
"""Sends email to recipients informing that the jail has started.
|
||||||
|
"""
|
||||||
|
self._sendMessage(
|
||||||
|
"[Fail2Ban] %(jailname)s: started on %(hostname)s" %
|
||||||
|
self.message_values,
|
||||||
|
messages['start'] % self.message_values)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
"""Sends email to recipients informing that the jail has stopped.
|
||||||
|
"""
|
||||||
|
self._sendMessage(
|
||||||
|
"[Fail2Ban] %(jailname)s: stopped on %(hostname)s" %
|
||||||
|
self.message_values,
|
||||||
|
messages['stop'] % self.message_values)
|
||||||
|
|
||||||
|
def ban(self, aInfo):
|
||||||
|
"""Sends email to recipients informing that ban has occurred.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
aInfo : dict
|
||||||
|
Dictionary which includes information in relation to
|
||||||
|
the ban.
|
||||||
|
"""
|
||||||
|
if aInfo.get('restored'):
|
||||||
|
return
|
||||||
|
aInfo.update(self.message_values)
|
||||||
|
message = "".join([
|
||||||
|
messages['ban']['head'],
|
||||||
|
messages['ban'].get(self.matches, ""),
|
||||||
|
messages['ban']['tail']
|
||||||
|
])
|
||||||
|
self._sendMessage(
|
||||||
|
"[Fail2Ban] %(jailname)s: banned %(ip)s from %(hostname)s" %
|
||||||
|
aInfo,
|
||||||
|
message % aInfo)
|
||||||
|
|
||||||
|
Action = SMTPAction
|
||||||
55
fail2ban/action.d/symbiosis-blacklist-allports.conf
Normal file
55
fail2ban/action.d/symbiosis-blacklist-allports.conf
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Fail2Ban configuration file for Bytemark Symbiosis firewall
|
||||||
|
#
|
||||||
|
# Author: Yaroslav Halchenko
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <iptables> -n -L <chain>
|
||||||
|
|
||||||
|
# Option: actionban
|
||||||
|
# Notes.: command executed when banning an IP.
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionban = echo 'all' >| /etc/symbiosis/firewall/blacklist.d/<ip>.auto
|
||||||
|
<iptables> -I <chain> 1 -s <ip> -j <blocktype>
|
||||||
|
|
||||||
|
# Option: actionunban
|
||||||
|
# Notes.: command executed when unbanning an IP.
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionunban = rm -f /etc/symbiosis/firewall/blacklist.d/<ip>.auto
|
||||||
|
<iptables> -D <chain> -s <ip> -j <blocktype> || :
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: chain
|
||||||
|
# Notes specifies the iptables chain to which the fail2ban rules should be
|
||||||
|
# added to. blacklist is a chain initiated by symbiosis firewall.
|
||||||
|
# Values: STRING Default: blacklist
|
||||||
|
chain = blacklist
|
||||||
|
|
||||||
|
# Option: blocktype
|
||||||
|
# Note: This is to match default symbiosis firewall type for blacklisted IPs
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = DROP
|
||||||
143
fail2ban/action.d/xarf-login-attack.conf
Normal file
143
fail2ban/action.d/xarf-login-attack.conf
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
# Fail2Ban action for sending xarf Login-Attack messages to IP owner
|
||||||
|
#
|
||||||
|
# IMPORTANT:
|
||||||
|
#
|
||||||
|
# Emailing a IP owner of abuse is a serious complain. Make sure that it is
|
||||||
|
# serious. Fail2ban developers and network owners recommend you only use this
|
||||||
|
# action for:
|
||||||
|
# * The recidive where the IP has been banned multiple times
|
||||||
|
# * Where maxretry has been set quite high, beyond the normal user typing
|
||||||
|
# password incorrectly.
|
||||||
|
# * For filters that have a low likelihood of receiving human errors
|
||||||
|
#
|
||||||
|
# DEPENDENCIES:
|
||||||
|
#
|
||||||
|
# This requires the dig command from bind-utils
|
||||||
|
#
|
||||||
|
# This uses the https://abusix.com/contactdb.html to lookup abuse contacts.
|
||||||
|
#
|
||||||
|
# XARF is a specification for sending a formatted response
|
||||||
|
# for non-messaging based abuse including:
|
||||||
|
#
|
||||||
|
# Login-Attack, Malware-Attack, Fraud (Phishing, etc.), Info DNSBL
|
||||||
|
#
|
||||||
|
# For details see:
|
||||||
|
# https://github.com/xarf/xarf-specification
|
||||||
|
# http://www.x-arf.org/schemata.html
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
|
# Based on complain written by Russell Odom <russ@gloomytrousers.co.uk>
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# bypass ban/unban for restored tickets
|
||||||
|
norestored = 1
|
||||||
|
|
||||||
|
actionstart =
|
||||||
|
|
||||||
|
actionstop =
|
||||||
|
|
||||||
|
actioncheck =
|
||||||
|
|
||||||
|
actionban = oifs=${IFS};
|
||||||
|
RESOLVER_ADDR="%(addr_resolver)s"
|
||||||
|
if [ "<debug>" -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=<ip>
|
||||||
|
FROM=<sender>
|
||||||
|
SERVICE=<service>
|
||||||
|
FAILURES=<failures>
|
||||||
|
REPORTID=<time>@<fq-hostname>
|
||||||
|
TLP=<tlp>
|
||||||
|
PORT=<port>
|
||||||
|
DATE=`LC_ALL=C date --date=@<time> +"%%a, %%d %%h %%Y %%T %%z"`
|
||||||
|
if [ ! -z "$ADDRESSES" ]; then
|
||||||
|
oifs=${IFS}; IFS=,; ADDRESSES=$(echo $ADDRESSES)
|
||||||
|
IFS=${oifs}
|
||||||
|
(printf -- %%b "<header>\n<message>\n<report>\n\n";
|
||||||
|
date '+Note: Local timezone is %%z (%%Z)';
|
||||||
|
printf -- %%b "\n<ipmatches>\n\n<footer>") | <mailcmd> <mailargs> $ADDRESSES
|
||||||
|
fi
|
||||||
|
|
||||||
|
actionunban =
|
||||||
|
|
||||||
|
# Server as resolver used in dig command
|
||||||
|
#
|
||||||
|
addr_resolver = <ip-rev>abuse-contacts.abusix.org
|
||||||
|
|
||||||
|
# Option: boundary
|
||||||
|
# Notes: This can be overwritten to be safe for possible predictions
|
||||||
|
boundary = bfbb0f920793ac03cb8634bde14d8a1e
|
||||||
|
|
||||||
|
_boundary = Abuse<time>-<boundary>
|
||||||
|
|
||||||
|
# Option: header
|
||||||
|
# Notes: This is really a fixed value
|
||||||
|
header = Subject: abuse report about $IP - $DATE\nAuto-Submitted: auto-generated\nX-XARF: PLAIN\nContent-Transfer-Encoding: 7bit\nContent-Type: multipart/mixed; charset=utf8;\n boundary=%(_boundary)s;\n\n--%(_boundary)s\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Type: text/plain; charset=utf-8;\n
|
||||||
|
|
||||||
|
# Option: footer
|
||||||
|
# Notes: This is really a fixed value and needs to match the report and header
|
||||||
|
# mime delimiters
|
||||||
|
footer = \n\n--%(_boundary)s--
|
||||||
|
|
||||||
|
# Option: report
|
||||||
|
# Notes: Intended to be fixed
|
||||||
|
report = --%(_boundary)s\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Type: text/plain; charset=utf-8; name=\"report.txt\";\n\n---\nReported-From: $FROM\nCategory: abuse\nReport-ID: $REPORTID\nReport-Type: login-attack\nService: $SERVICE\nVersion: 0.2\nUser-Agent: Fail2ban v0.9\nDate: $DATE\nSource-Type: ip-address\nSource: $IP\nPort: $PORT\nSchema-URL: http://www.x-arf.org/schema/abuse_login-attack_0.1.2.json\nAttachment: text/plain\nOccurances: $FAILURES\nTLP: $TLP\n\n\n--%(_boundary)s\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Type: text/plain; charset=utf8; name=\"logfile.log\";
|
||||||
|
|
||||||
|
# Option: Message
|
||||||
|
# Notes: This can be modified by the users
|
||||||
|
message = Dear Sir/Madam,\n\nWe have detected abuse from the IP address $IP, which according to abusix.com is on your network. We would appreciate if you would investigate and take action as appropriate.\n\nLog lines are given below, but please ask if you require any further information.\n\n(If you are not the correct person to contact about this please accept our apologies - your e-mail address was extracted from the whois record by an automated process.)\n\n This mail was generated by Fail2Ban in a X-ARF format! You can find more information about x-arf at http://www.x-arf.org/specification.html.\n\nThe recipient address of this report was provided by the Abuse Contact DB by abusix.com. abusix.com does not maintain the content of the database. All information which we pass out, derives from the RIR databases and is processed for ease of use. If you want to change or report non working abuse contacts please contact the appropriate RIR. If you have any further question, contact abusix.com directly via email (info@abusix.com). Information about the Abuse Contact Database can be found here: https://abusix.com/global-reporting/abuse-contact-db\nabusix.com is neither responsible nor liable for the content or accuracy of this message.\n
|
||||||
|
|
||||||
|
# Option: loglines
|
||||||
|
# Notes.: The number of log lines to search for the IP for the report
|
||||||
|
loglines = 9000
|
||||||
|
|
||||||
|
# Option: mailcmd
|
||||||
|
# Notes.: Your system mail command. It is passed the recipient
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
mailcmd = /usr/sbin/sendmail
|
||||||
|
|
||||||
|
# Option: mailargs
|
||||||
|
# Notes.: Additional arguments to mail command. e.g. for standard Unix mail:
|
||||||
|
# CC reports to another address:
|
||||||
|
# -c me@example.com
|
||||||
|
# Appear to come from a different address - the '--' indicates
|
||||||
|
# arguments to be passed to Sendmail:
|
||||||
|
# -- -f me@example.com
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
mailargs = -f <sender>
|
||||||
|
|
||||||
|
# Option: tlp
|
||||||
|
# Notes.: Traffic light protocol defining the sharing of this information.
|
||||||
|
# http://www.trusted-introducer.org/ISTLPv11.pdf
|
||||||
|
# green is share to those involved in network security but it is not
|
||||||
|
# to be released to the public.
|
||||||
|
tlp = green
|
||||||
|
|
||||||
|
# ALL of the following parameters should be set so the report contains
|
||||||
|
# meaningful information
|
||||||
|
|
||||||
|
# Option: service
|
||||||
|
# Notes.: This is the service type that was attacked. e.g. ssh, pop3
|
||||||
|
service = unspecified
|
||||||
|
|
||||||
|
# Option: logpath
|
||||||
|
# Notes: Path to the log files which contain relevant lines for the abuser IP
|
||||||
|
# Values: Filename(s) space separated and can contain wildcards (these are
|
||||||
|
# greped for the IP so make sure these aren't too long
|
||||||
|
logpath = /dev/null
|
||||||
|
|
||||||
|
# Option: sender
|
||||||
|
# Notes.: This is the sender that is included in the XARF report
|
||||||
|
sender = fail2ban@<fq-hostname>
|
||||||
|
|
||||||
|
# Option: port
|
||||||
|
# Notes.: This is the port number that received the login-attack
|
||||||
|
port = 0
|
||||||
|
|
||||||
86
fail2ban/fail2ban.conf
Normal file
86
fail2ban/fail2ban.conf
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# Fail2Ban main configuration file
|
||||||
|
#
|
||||||
|
# Comments: use '#' for comment lines and ';' (following a space) for inline comments
|
||||||
|
#
|
||||||
|
# Changes: in most of the cases you should not modify this
|
||||||
|
# file, but provide customizations in fail2ban.local file, e.g.:
|
||||||
|
#
|
||||||
|
# [DEFAULT]
|
||||||
|
# loglevel = DEBUG
|
||||||
|
#
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
# Option: loglevel
|
||||||
|
# Notes.: Set the log level output.
|
||||||
|
# CRITICAL
|
||||||
|
# ERROR
|
||||||
|
# WARNING
|
||||||
|
# NOTICE
|
||||||
|
# INFO
|
||||||
|
# DEBUG
|
||||||
|
# Values: [ LEVEL ] Default: INFO
|
||||||
|
#
|
||||||
|
loglevel = INFO
|
||||||
|
|
||||||
|
# Option: logtarget
|
||||||
|
# Notes.: Set the log target. This could be a file, SYSLOG, STDERR or STDOUT.
|
||||||
|
# Only one log target can be specified.
|
||||||
|
# If you change logtarget from the default value and you are
|
||||||
|
# using logrotate -- also adjust or disable rotation in the
|
||||||
|
# corresponding configuration file
|
||||||
|
# (e.g. /etc/logrotate.d/fail2ban on Debian systems)
|
||||||
|
# Values: [ STDOUT | STDERR | SYSLOG | SYSOUT | FILE ] Default: STDERR
|
||||||
|
#
|
||||||
|
logtarget = /var/log/fail2ban.log
|
||||||
|
|
||||||
|
# Option: syslogsocket
|
||||||
|
# Notes: Set the syslog socket file. Only used when logtarget is SYSLOG
|
||||||
|
# auto uses platform.system() to determine predefined paths
|
||||||
|
# Values: [ auto | FILE ] Default: auto
|
||||||
|
syslogsocket = auto
|
||||||
|
|
||||||
|
# Option: socket
|
||||||
|
# Notes.: Set the socket file. This is used to communicate with the daemon. Do
|
||||||
|
# not remove this file when Fail2ban runs. It will not be possible to
|
||||||
|
# communicate with the server afterwards.
|
||||||
|
# Values: [ FILE ] Default: /var/run/fail2ban/fail2ban.sock
|
||||||
|
#
|
||||||
|
socket = /var/run/fail2ban/fail2ban.sock
|
||||||
|
|
||||||
|
# Option: pidfile
|
||||||
|
# Notes.: Set the PID file. This is used to store the process ID of the
|
||||||
|
# fail2ban server.
|
||||||
|
# Values: [ FILE ] Default: /var/run/fail2ban/fail2ban.pid
|
||||||
|
#
|
||||||
|
pidfile = /var/run/fail2ban/fail2ban.pid
|
||||||
|
|
||||||
|
# Options: dbfile
|
||||||
|
# Notes.: Set the file for the fail2ban persistent data to be stored.
|
||||||
|
# A value of ":memory:" means database is only stored in memory
|
||||||
|
# and data is lost when fail2ban is stopped.
|
||||||
|
# A value of "None" disables the database.
|
||||||
|
# Values: [ None :memory: FILE ] Default: /var/lib/fail2ban/fail2ban.sqlite3
|
||||||
|
dbfile = /var/lib/fail2ban/fail2ban.sqlite3
|
||||||
|
|
||||||
|
# Options: dbpurgeage
|
||||||
|
# Notes.: Sets age at which bans should be purged from the database
|
||||||
|
# Values: [ SECONDS ] Default: 86400 (24hours)
|
||||||
|
dbpurgeage = 1d
|
||||||
|
|
||||||
|
# Options: dbmaxmatches
|
||||||
|
# Notes.: Number of matches stored in database per ticket (resolvable via
|
||||||
|
# tags <ipmatches>/<ipjailmatches> in actions)
|
||||||
|
# Values: [ INT ] Default: 10
|
||||||
|
dbmaxmatches = 10
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
|
||||||
|
[Thread]
|
||||||
|
|
||||||
|
# Options: stacksize
|
||||||
|
# Notes.: Specifies the stack size (in KiB) to be used for subsequently created threads,
|
||||||
|
# and must be 0 or a positive integer value of at least 32.
|
||||||
|
# Values: [ SIZE ] Default: 0 (use platform or configured default)
|
||||||
|
#stacksize = 0
|
||||||
20
fail2ban/filter.d/3proxy.conf
Normal file
20
fail2ban/filter.d/3proxy.conf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Fail2Ban filter for 3proxy
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
|
||||||
|
failregex = ^\s[+-]\d{4} \S+ \d{3}0[1-9] \S+ <HOST>:\d+ [\d.]+:\d+ \d+ \d+ \d+\s
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# http://www.3proxy.ru/howtoe.asp#ERRORS indicates that 01-09 are
|
||||||
|
# all authentication problems (%E field)
|
||||||
|
# Log format is: "L%d-%m-%Y %H:%M:%S %z %N.%p %E %U %C:%c %R:%r %O %I %h %T"
|
||||||
|
#
|
||||||
|
# Requested by ykimon in https://github.com/fail2ban/fail2ban/issues/246
|
||||||
|
# Author: Daniel Black
|
||||||
71
fail2ban/filter.d/apache-auth.conf
Normal file
71
fail2ban/filter.d/apache-auth.conf
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# Fail2Ban apache-auth filter
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# apache-common.local
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Mode for filter: normal (default) and aggressive (allows DDoS & brute force detection of mod_evasive)
|
||||||
|
mode = normal
|
||||||
|
|
||||||
|
# ignore messages of mod_evasive module:
|
||||||
|
apache-pref-ign-normal = (?!evasive)
|
||||||
|
# allow "denied by server configuration" from all modules:
|
||||||
|
apache-pref-ign-aggressive =
|
||||||
|
# mode related ignore prefix for common _apache_error_client substitution:
|
||||||
|
apache-pref-ignore = <apache-pref-ign-<mode>>
|
||||||
|
|
||||||
|
prefregex = ^%(_apache_error_client)s (?:AH\d+: )?<F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
# auth_type = ((?:Digest|Basic): )?
|
||||||
|
auth_type = ([A-Z]\w+: )?
|
||||||
|
|
||||||
|
failregex = ^client (?:denied by server configuration|used wrong authentication scheme)\b
|
||||||
|
^user (?!`)<F-USER>(?:\S*|.*?)</F-USER> (?:auth(?:oriz|entic)ation failure|not found|denied by provider)\b
|
||||||
|
^Authorization of user <F-USER>(?:\S*|.*?)</F-USER> to access .*? failed\b
|
||||||
|
^%(auth_type)suser <F-USER>(?:\S*|.*?)</F-USER>: password mismatch\b
|
||||||
|
^%(auth_type)suser `<F-USER>(?:[^']*|.*?)</F-USER>' in realm `.+' (auth(?:oriz|entic)ation failure|not found|denied by provider)\b
|
||||||
|
^%(auth_type)sinvalid nonce .* received - length is not\b
|
||||||
|
^%(auth_type)srealm mismatch - got `(?:[^']*|.*?)' but expected\b
|
||||||
|
^%(auth_type)sunknown algorithm `(?:[^']*|.*?)' received\b
|
||||||
|
^invalid qop `(?:[^']*|.*?)' received\b
|
||||||
|
^%(auth_type)sinvalid nonce .*? received - user attempted time travel\b
|
||||||
|
^(?:No h|H)ostname \S+ provided via SNI(?:, but no hostname provided| and hostname \S+ provided| for a name based virtual host)\b
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# This filter matches the authorization failures of Apache. It takes the log messages
|
||||||
|
# from the modules in aaa that return HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED or
|
||||||
|
# HTTP_FORBIDDEN and not AUTH_GENERAL_ERROR or HTTP_INTERNAL_SERVER_ERROR.
|
||||||
|
#
|
||||||
|
# An unauthorized response 401 is the first step for a browser to instigate authentication
|
||||||
|
# however apache doesn't log this as an error. Only subsequent errors are logged in the
|
||||||
|
# error log.
|
||||||
|
#
|
||||||
|
# Source:
|
||||||
|
#
|
||||||
|
# By searching the code in http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/*
|
||||||
|
# for ap_log_rerror(APLOG_MARK, APLOG_ERR and examining resulting return code should get
|
||||||
|
# all of these expressions. Lots of submodules like mod_authz_* return back to mod_authz_core
|
||||||
|
# to return the actual failure.
|
||||||
|
#
|
||||||
|
# Note that URI can contain spaces.
|
||||||
|
#
|
||||||
|
# See also: http://wiki.apache.org/httpd/ListOfErrors
|
||||||
|
# Expressions that don't have tests and aren't common.
|
||||||
|
# more be added with https://issues.apache.org/bugzilla/show_bug.cgi?id=55284
|
||||||
|
# ^user .*: nonce expired \([\d.]+ seconds old - max lifetime [\d.]+\) - sending new nonce\s*$
|
||||||
|
# ^user .*: one-time-nonce mismatch - sending new nonce\s*$
|
||||||
|
# ^realm mismatch - got `(?:[^']*|.*?)' but no realm specified\s*$
|
||||||
|
#
|
||||||
|
# Because url/referer are foreign input, short form of regex used if long enough to idetify failure.
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Major edits by Daniel Black and Ben Rubson.
|
||||||
|
# Rewritten for v.0.10 by Sergey Brester (sebres).
|
||||||
24
fail2ban/filter.d/apache-badbots.conf
Normal file
24
fail2ban/filter.d/apache-badbots.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Regexp to catch known spambots and software alike. Please verify
|
||||||
|
# that it is your intent to block IPs which were driven by
|
||||||
|
# above mentioned bots.
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
badbotscustom = EmailCollector|WebEMailExtrac|TrackBack/1\.02|sogou music spider|(?:Mozilla/\d+\.\d+ )?Jorgee
|
||||||
|
badbots = Atomic_Email_Hunter/4\.0|atSpider/1\.0|autoemailspider|bwh3_user_agent|China Local Browse 2\.6|ContactBot/0\.2|ContentSmartz|DataCha0s/2\.0|DBrowse 1\.4b|DBrowse 1\.4d|Demo Bot DOT 16b|Demo Bot Z 16b|DSurf15a 01|DSurf15a 71|DSurf15a 81|DSurf15a VA|EBrowse 1\.4b|Educate Search VxB|EmailSiphon|EmailSpider|EmailWolf 1\.00|ESurf15a 15|ExtractorPro|Franklin Locator 1\.8|FSurf15a 01|Full Web Bot 0416B|Full Web Bot 0516B|Full Web Bot 2816B|Guestbook Auto Submitter|Industry Program 1\.0\.x|ISC Systems iRc Search 2\.1|IUPUI Research Bot v 1\.9a|LARBIN-EXPERIMENTAL \(efp@gmx\.net\)|LetsCrawl\.com/1\.0 \+http\://letscrawl\.com/|Lincoln State Web Browser|LMQueueBot/0\.2|LWP\:\:Simple/5\.803|Mac Finder 1\.0\.xx|MFC Foundation Class Library 4\.0|Microsoft URL Control - 6\.00\.8xxx|Missauga Locate 1\.0\.0|Missigua Locator 1\.9|Missouri College Browse|Mizzu Labs 2\.2|Mo College 1\.9|MVAClient|Mozilla/2\.0 \(compatible; NEWT ActiveX; Win32\)|Mozilla/3\.0 \(compatible; Indy Library\)|Mozilla/3\.0 \(compatible; scan4mail \(advanced version\) http\://www\.peterspages\.net/?scan4mail\)|Mozilla/4\.0 \(compatible; Advanced Email Extractor v2\.xx\)|Mozilla/4\.0 \(compatible; Iplexx Spider/1\.0 http\://www\.iplexx\.at\)|Mozilla/4\.0 \(compatible; MSIE 5\.0; Windows NT; DigExt; DTS Agent|Mozilla/4\.0 efp@gmx\.net|Mozilla/5\.0 \(Version\: xxxx Type\:xx\)|NameOfAgent \(CMS Spider\)|NASA Search 1\.0|Nsauditor/1\.x|PBrowse 1\.4b|PEval 1\.4b|Poirot|Port Huron Labs|Production Bot 0116B|Production Bot 2016B|Production Bot DOT 3016B|Program Shareware 1\.0\.2|PSurf15a 11|PSurf15a 51|PSurf15a VA|psycheclone|RSurf15a 41|RSurf15a 51|RSurf15a 81|searchbot admin@google\.com|ShablastBot 1\.0|snap\.com beta crawler v0|Snapbot/1\.0|Snapbot/1\.0 \(Snap Shots, \+http\://www\.snap\.com\)|sogou develop spider|Sogou Orion spider/3\.0\(\+http\://www\.sogou\.com/docs/help/webmasters\.htm#07\)|sogou spider|Sogou web spider/3\.0\(\+http\://www\.sogou\.com/docs/help/webmasters\.htm#07\)|sohu agent|SSurf15a 11 |TSurf15a 11|Under the Rainbow 2\.2|User-Agent\: Mozilla/4\.0 \(compatible; MSIE 6\.0; Windows NT 5\.1\)|VadixBot|WebVulnCrawl\.unknown/1\.0 libwww-perl/5\.803|Wells Search II|WEP Search 00
|
||||||
|
|
||||||
|
failregex = ^<HOST> -.*"(GET|POST|HEAD).*HTTP.*"(?:%(badbots)s|%(badbotscustom)s)"$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^[^\[]*\[({DATE})
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# List of bad bots fetched from http://www.user-agents.org
|
||||||
|
# Generated on Thu Nov 7 14:23:35 PST 2013 by files/gen_badbots.
|
||||||
|
#
|
||||||
|
# Author: Yaroslav Halchenko
|
||||||
39
fail2ban/filter.d/apache-botsearch.conf
Normal file
39
fail2ban/filter.d/apache-botsearch.conf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Fail2Ban filter to match web requests for selected URLs that don't exist
|
||||||
|
#
|
||||||
|
# This filter is aimed at blocking specific URLs that don't exist. This
|
||||||
|
# could be a set of URLs places in a Disallow: directive in robots.txt or
|
||||||
|
# just some web services that don't exist caused bots are searching for
|
||||||
|
# exploitable content. This filter is designed to have a low false positive
|
||||||
|
# rate due.
|
||||||
|
#
|
||||||
|
# An alternative to this is the apache-noscript filter which blocks all
|
||||||
|
# types of scripts that don't exist.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# This is normally a predefined list of exploitable or valuable web services
|
||||||
|
# that are hidden or aren't actually installed.
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# overwrite with apache-common.local if _apache_error_client is incorrect.
|
||||||
|
# Load regexes for filtering from botsearch-common.conf
|
||||||
|
before = apache-common.conf
|
||||||
|
botsearch-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
prefregex = ^%(_apache_error_client)s (?:AH\d+: )?<F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^(?:File does not exist|script not found or unable to stat): <webroot><block>(, referer: \S+)?\s*$
|
||||||
|
^script '<webroot><block>' not found or unable to stat(, referer: \S+)?\s*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Webroot represents the webroot on which all other files are based
|
||||||
|
webroot = /var/www/
|
||||||
|
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
44
fail2ban/filter.d/apache-common.conf
Normal file
44
fail2ban/filter.d/apache-common.conf
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Generic configuration items (to be used as interpolations) in other
|
||||||
|
# apache filters.
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = common.conf
|
||||||
|
# Load customizations if any available
|
||||||
|
after = apache-common.local
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
# Apache logging mode:
|
||||||
|
# all - universal prefix (logfile, syslog)
|
||||||
|
# logfile - logfile only
|
||||||
|
# syslog - syslog only
|
||||||
|
# Use `filter = apache-auth[logging=syslog]` to get more precise regex if apache logs into syslog (ErrorLog syslog).
|
||||||
|
# Use `filter = apache-auth[logging=all]` to get universal regex matches both logging variants.
|
||||||
|
logging = logfile
|
||||||
|
|
||||||
|
# Apache logging prefixes (date-pattern prefix, server, process etc.):
|
||||||
|
apache-prefix-syslog = %(__prefix_line)s
|
||||||
|
apache-prefix-logfile = \[\]\s
|
||||||
|
apache-prefix-all = (?:%(apache-prefix-logfile)s|%(apache-prefix-syslog)s)?
|
||||||
|
|
||||||
|
# Setting for __prefix_line (only `logging=syslog`):
|
||||||
|
_daemon = (?:apache\d*|httpd(?:/\w+)?)
|
||||||
|
|
||||||
|
apache-prefix = <apache-prefix-<logging>>
|
||||||
|
|
||||||
|
apache-pref-ignore =
|
||||||
|
|
||||||
|
_apache_error_client = <apache-prefix>\[(:?error|<apache-pref-ignore>\S+:\S+)\]( \[pid \d+(:\S+ \d+)?\])? \[client <HOST>(:\d{1,5})?\]
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}
|
||||||
|
|
||||||
|
# Common prefix for [error] apache messages which also would include <HOST>
|
||||||
|
# Depending on the version it could be
|
||||||
|
# 2.2: [Sat Jun 01 11:23:08 2013] [error] [client 1.2.3.4]
|
||||||
|
# 2.4: [Thu Jun 27 11:55:44.569531 2013] [core:info] [pid 4101:tid 2992634688] [client 1.2.3.4:46652]
|
||||||
|
# 2.4 (perfork): [Mon Dec 23 07:49:01.981912 2013] [:error] [pid 3790] [client 204.232.202.107:46301] script '/var/www/timthumb.php' not found or unable to
|
||||||
|
#
|
||||||
|
# Reference: https://github.com/fail2ban/fail2ban/issues/268
|
||||||
|
#
|
||||||
|
# Author: Yaroslav Halchenko
|
||||||
16
fail2ban/filter.d/apache-fakegooglebot.conf
Normal file
16
fail2ban/filter.d/apache-fakegooglebot.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Fail2Ban filter for fake Googlebot User Agents
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^<HOST> .*Googlebot.*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^[^\[]*\[({DATE})
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Author: Lee Clemens
|
||||||
|
# Thanks: Johannes B. Ullrich, Ph.D.
|
||||||
|
# Reference: https://isc.sans.edu/forums/diary/When+Google+isnt+Google/15968/
|
||||||
19
fail2ban/filter.d/apache-modsecurity.conf
Normal file
19
fail2ban/filter.d/apache-modsecurity.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Fail2Ban apache-modsec filter
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# apache-common.local
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
|
||||||
|
failregex = ^%(_apache_error_client)s(?: \[client [^\]]+\])? ModSecurity:\s+(?:\[(?:\w+ \"[^\"]*\"|[^\]]*)\]\s*)*Access denied with code [45]\d\d
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# https://github.com/SpiderLabs/ModSecurity/wiki/ModSecurity-2-Data-Formats
|
||||||
|
# Author: Daniel Black
|
||||||
|
# Sergey G. Brester aka sebres (review, optimization)
|
||||||
20
fail2ban/filter.d/apache-nohome.conf
Normal file
20
fail2ban/filter.d/apache-nohome.conf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Fail2Ban filter to web requests for home directories on Apache servers
|
||||||
|
#
|
||||||
|
# Regex to match failures to find a home directory on a server, which
|
||||||
|
# became popular last days. Most often attacker just uses IP instead of
|
||||||
|
# domain name -- so expect to see them in generic error.log if you have
|
||||||
|
# per-domain log files.
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# overwrite with apache-common.local if _apache_error_client is incorrect.
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
|
||||||
|
failregex = ^%(_apache_error_client)s (AH00128: )?File does not exist: .*/~.*
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
37
fail2ban/filter.d/apache-noscript.conf
Normal file
37
fail2ban/filter.d/apache-noscript.conf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Fail2Ban filter to block web requests for scripts (on non scripted websites)
|
||||||
|
#
|
||||||
|
# This matches many types of scripts that don't exist. This could generate a
|
||||||
|
# lot of false positive matches in cases like wikis and forums where users
|
||||||
|
# no affiliated with the website can insert links to missing files/scripts into
|
||||||
|
# pages and cause non-malicious browsers of the site to trigger against this
|
||||||
|
# filter.
|
||||||
|
#
|
||||||
|
# If you'd like to match specific URLs that don't exist see the
|
||||||
|
# apache-botsearch filter.
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# overwrite with apache-common.local if _apache_error_client is incorrect.
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
script = /\S*(?:php(?:[45]|[.-]cgi)?|\.asp|\.exe|\.pl|\bcgi-bin/)
|
||||||
|
|
||||||
|
prefregex = ^%(_apache_error_client)s (?:AH0(?:01(?:28|30)|1(?:264|071)|2811): )?(?:(?:[Ff]ile|script|[Gg]ot) )<F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^(?:does not exist|not found or unable to stat): <script>\b
|
||||||
|
^'<script>\S*' not found or unable to stat
|
||||||
|
^error '[Pp]rimary script unknown(?:\\n)?'
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# https://wiki.apache.org/httpd/ListOfErrors for apache error IDs
|
||||||
|
#
|
||||||
|
# Second regex, script '/\S*(\.php|\.asp|\.exe|\.pl)\S*' not found or unable to stat\s*$ is in httpd-2.2
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
40
fail2ban/filter.d/apache-overflows.conf
Normal file
40
fail2ban/filter.d/apache-overflows.conf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Fail2Ban filter to block web requests on a long or suspicious nature
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# overwrite with apache-common.local if _apache_error_client is incorrect.
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^%(_apache_error_client)s (?:(?:AH0013[456]: )?Invalid (method|URI) in request\b|(?:AH00565: )?request failed: URI too long \(longer than \d+\)|request failed: erroneous characters after protocol string:|(?:AH00566: )?request failed: invalid characters in URI\b)
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# [sebres] Because this apache-log could contain very long URLs (and/or referrer),
|
||||||
|
# the parsing of it anchored way may be very vulnerable (at least as regards
|
||||||
|
# the system resources, see gh-1790). Thus rewritten without end-anchor ($).
|
||||||
|
#
|
||||||
|
# fgrep -r 'URI too long' httpd-2.*
|
||||||
|
# httpd-2.2.25/server/protocol.c: "request failed: URI too long (longer than %d)", r->server->limit_req_line);
|
||||||
|
# httpd-2.4.4/server/protocol.c: "request failed: URI too long (longer than %d)",
|
||||||
|
#
|
||||||
|
# fgrep -r 'in request' ../httpd-2.* | fgrep Invalid
|
||||||
|
# httpd-2.2.25/server/core.c: "Invalid URI in request %s", r->the_request);
|
||||||
|
# httpd-2.2.25/server/core.c: "Invalid method in request %s", r->the_request);
|
||||||
|
# httpd-2.2.25/docs/manual/rewrite/flags.html.fr:avertissements 'Invalid URI in request'.
|
||||||
|
# httpd-2.4.4/server/core.c: "Invalid URI in request %s", r->the_request);
|
||||||
|
# httpd-2.4.4/server/core.c: "Invalid method in request %s - possible attempt to establish SSL connection on non-SSL port", r->the_request);
|
||||||
|
# httpd-2.4.4/server/core.c: "Invalid method in request %s", r->the_request);
|
||||||
|
#
|
||||||
|
# fgrep -r 'invalid characters in URI' httpd-2.*
|
||||||
|
# httpd-2.4.4/server/protocol.c: "request failed: invalid characters in URI");
|
||||||
|
#
|
||||||
|
# http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?r1=739382&r2=739620&pathrev=739620
|
||||||
|
# ...possible attempt to establish SSL connection on non-SSL port
|
||||||
|
#
|
||||||
|
# https://wiki.apache.org/httpd/ListOfErrors
|
||||||
|
# Author: Tim Connors
|
||||||
19
fail2ban/filter.d/apache-pass.conf
Normal file
19
fail2ban/filter.d/apache-pass.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Fail2Ban Apache pass filter
|
||||||
|
# This filter is for access.log, NOT for error.log
|
||||||
|
#
|
||||||
|
# The knocking request must have a referer.
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^<HOST> - \w+ \[\] "GET <knocking_url> HTTP/1\.[01]" 200 \d+ ".*" "[^-].*"$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^[^\[]*\[({DATE})
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
knocking_url = /knocking/
|
||||||
|
|
||||||
|
# Author: Viktor Szépe
|
||||||
28
fail2ban/filter.d/apache-shellshock.conf
Normal file
28
fail2ban/filter.d/apache-shellshock.conf
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Fail2Ban filter to block web requests containing custom headers attempting to exploit the shellshock bug
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# overwrite with apache-common.local if _apache_error_client is incorrect.
|
||||||
|
before = apache-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
prefregex = ^%(_apache_error_client)s (AH01215: )?/bin/([bd]a)?sh: <F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^warning: HTTP_[^:]+: ignoring function definition attempt(, referer: \S+)?\s*$
|
||||||
|
^error importing function definition for `HTTP_[^']+'(, referer: \S+)?\s*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# https://wiki.apache.org/httpd/ListOfErrors for apache error IDs
|
||||||
|
#
|
||||||
|
# example log lines:
|
||||||
|
# [Thu Sep 25 09:27:18.813902 2014] [cgi:error] [pid 16860] [client 89.207.132.76:59635] AH01215: /bin/bash: warning: HTTP_TEST: ignoring function definition attempt
|
||||||
|
# [Thu Sep 25 09:29:56.141832 2014] [cgi:error] [pid 16864] [client 162.247.73.206:41273] AH01215: /bin/bash: error importing function definition for `HTTP_TEST'
|
||||||
|
#
|
||||||
|
# Author: Eugene Hopkinson (e.hopkinson@gmail.com)
|
||||||
46
fail2ban/filter.d/assp.conf
Normal file
46
fail2ban/filter.d/assp.conf
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Fail2Ban filter for Anti-Spam SMTP Proxy Server (ASSP)
|
||||||
|
# Filter works in theory for both ASSP V1 and V2. Recommended ASSP is V2.5.1 or later.
|
||||||
|
# Support for ASSP V1 ended in 2014 so if you are still running ASSP V1 an immediate upgrade is recommended.
|
||||||
|
#
|
||||||
|
# Homepage: http://sourceforge.net/projects/assp/
|
||||||
|
# ProjectSite: http://sourceforge.net/projects/assp/?source=directory
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
# Note: First three failregex matches below are for ASSP V1 with the remaining being designed for V2. Deleting the V1 regex is recommended but I left it in for compatibility reasons.
|
||||||
|
|
||||||
|
__assp_actions = (?:dropping|refusing)
|
||||||
|
|
||||||
|
failregex = ^(:? \[SSL-out\])? <HOST> max sender authentication errors \(\d{,3}\) exceeded -- %(__assp_actions)s connection - after reply: \d{3} \d{1}\.\d{1}.\d{1} Error: authentication failed: \w+;$
|
||||||
|
^(?: \[SSL-out\])? <HOST> SSL negotiation with client failed: SSL accept attempt failed with unknown error.*:unknown protocol;$
|
||||||
|
^ Blocking <HOST> - too much AUTH errors \(\d{,3}\);$
|
||||||
|
^\s*(?:[\w\-]+\s+)*(?:\[\S+\]\s+)*<HOST> (?:\<\S+@\S+\.\S+\> )*(?:to: \S+@\S+\.\S+ )*relay attempt blocked for(?: \(parsing\))?: \S+$
|
||||||
|
^\s*(?:[\w\-]+\s+)*(?:\[\S+\]\s+)*<HOST> \[SMTP Error\] 535 5\.7\.8 Error: authentication failed:\s+(?:\S+|Connection lost to authentication server|Invalid authentication mechanism|Invalid base64 data in continued response)?$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}%%b-%%d-%%Exy %%H:%%M:%%S
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# V1 Examples matches:
|
||||||
|
# Apr-27-13 02:33:09 Blocking 217.194.197.97 - too much AUTH errors (41);
|
||||||
|
# Dec-29-12 17:10:31 [SSL-out] 200.247.87.82 SSL negotiation with client failed: SSL accept attempt failed with unknown errorerror:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol;
|
||||||
|
# Dec-30-12 04:01:47 [SSL-out] 81.82.232.66 max sender authentication errors (5) exceeded
|
||||||
|
#
|
||||||
|
# V2 Examples matches:
|
||||||
|
# Jul-29-16 16:49:52 m1-25391-06124 [Worker_1] [TLS-out] [RelayAttempt] 0.0.0.0 <user@example.com> to: user@example.org relay attempt blocked for: someone@example.org
|
||||||
|
# Jul-30-16 16:59:42 [Worker_1] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
|
||||||
|
# Jul-30-16 00:15:36 m1-52131-09651 [Worker_1] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
|
||||||
|
# Jul-31-16 06:45:59 [Worker_1] [TLS-in] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed:
|
||||||
|
# Jan-05-16 08:38:49 m1-01129-09140 [Worker_1] [TLS-in] [TLS-out] [RelayAttempt] 0.0.0.0 <user@example.com> relay attempt blocked for (parsing): <user2@example>
|
||||||
|
# Jun-12-16 16:43:37 m1-64217-12013 [Worker_1] [TLS-in] [TLS-out] [RelayAttempt] 0.0.0.0 <user@example.com> to: user2@example.com relay attempt blocked for (parsing): <a.notheruser69@example.c>
|
||||||
|
# Jan-22-16 22:25:51 [Worker_1] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: Invalid authentication mechanism
|
||||||
|
# Mar-19-16 13:42:20 [Worker_1] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: Invalid base64 data in continued response
|
||||||
|
# Jul-18-16 16:54:21 [Worker_2] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: Connection lost to authentication server
|
||||||
|
# Jul-18-16 17:14:23 m1-76453-02949 [Worker_1] [TLS-out] 0.0.0.0 [SMTP Error] 535 5.7.8 Error: authentication failed: Connection lost to authentication server
|
||||||
|
|
||||||
|
#
|
||||||
|
# Author: Enrico Labedzki (enrico.labedzki@deiwos.de)
|
||||||
|
# V2 Filters: Robert Hardy (rhardy@webcon.ca)
|
||||||
55
fail2ban/filter.d/asterisk.conf
Normal file
55
fail2ban/filter.d/asterisk.conf
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Fail2Ban filter for asterisk authentication failures
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = asterisk
|
||||||
|
|
||||||
|
__pid_re = (?:\s*\[\d+\])
|
||||||
|
|
||||||
|
iso8601 = \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[+-]\d{4}
|
||||||
|
|
||||||
|
# All Asterisk log messages begin like this:
|
||||||
|
log_prefix= (?:NOTICE|SECURITY|WARNING)%(__pid_re)s:?(?:\[C-[\da-f]*\])?:? [^:]+:\d*(?:(?: in)? [^:]+:)?
|
||||||
|
|
||||||
|
prefregex = ^%(__prefix_line)s%(log_prefix)s <F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^Registration from '[^']*' failed for '<HOST>(:\d+)?' - (?:Wrong password|Username/auth name mismatch|No matching peer found|Not a local domain|Device does not match ACL|Peer is not supposed to register|ACL error \(permit/deny\)|Not a local domain)$
|
||||||
|
^Call from '[^']*' \(<HOST>:\d+\) to extension '[^']*' rejected because extension not found in context
|
||||||
|
^(?:Host )?<HOST> (?:failed (?:to authenticate\b|MD5 authentication\b)|tried to authenticate with nonexistent user\b)
|
||||||
|
^No registration for peer '[^']*' \(from <HOST>\)$
|
||||||
|
^hacking attempt detected '<HOST>'$
|
||||||
|
^SecurityEvent="(?:FailedACL|InvalidAccountID|ChallengeResponseFailed|InvalidPassword)"(?:(?:,(?!RemoteAddress=)\w+="[^"]*")*|.*?),RemoteAddress="IPV[46]/[^/"]+/<HOST>/\d+"(?:,(?!RemoteAddress=)\w+="[^"]*")*$
|
||||||
|
^"Rejecting unknown SIP connection from <HOST>(?::\d+)?"$
|
||||||
|
^Request (?:'[^']*' )?from '(?:[^']*|.*?)' failed for '<HOST>(?::\d+)?'\s\(callid: [^\)]*\) - (?:No matching endpoint found|Not match Endpoint(?: Contact)? ACL|(?:Failed|Error) to authenticate)\s*$
|
||||||
|
|
||||||
|
# FreePBX (todo: make optional in v.0.10):
|
||||||
|
# ^(%(__prefix_line)s|\[\]\s*WARNING%(__pid_re)s:?(?:\[C-[\da-f]*\])? )[^:]+: Friendly Scanner from <HOST>$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}
|
||||||
|
|
||||||
|
# Author: Xavier Devlamynck / Daniel Black
|
||||||
|
#
|
||||||
|
# General log format - main/logger.c:ast_log
|
||||||
|
# Address format - ast_sockaddr_stringify
|
||||||
|
#
|
||||||
|
# First regex: channels/chan_sip.c
|
||||||
|
#
|
||||||
|
# main/logger.c:ast_log_vsyslog - "in {functionname}:" only occurs in syslog
|
||||||
|
|
||||||
|
journalmatch = _SYSTEMD_UNIT=asterisk.service
|
||||||
|
|
||||||
|
|
||||||
|
[lt_journal]
|
||||||
|
|
||||||
|
# asterisk can log timestamp if logs into systemd-journal (optional part matching this timestamp, gh-2383):
|
||||||
|
__extra_timestamp = (?:\[[^\]]+\]\s+)?
|
||||||
|
__prefix_line = %(known/__prefix_line)s%(__extra_timestamp)s
|
||||||
13
fail2ban/filter.d/bitwarden.conf
Normal file
13
fail2ban/filter.d/bitwarden.conf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Fail2Ban filter for Bitwarden
|
||||||
|
# Detecting failed login attempts
|
||||||
|
# Logged in bwdata/logs/identity/Identity/log.txt
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
_daemon = Bitwarden-Identity
|
||||||
|
failregex = ^%(__prefix_line)s\s*\[(?:W(?:RN|arning)|Bit\.Core\.[^\]]+)\]\s+Failed login attempt(?:, 2FA invalid)?\. <ADDR>$
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# __prefix_line can result to an empty string, so it can support syslog and non-syslog at once.
|
||||||
19
fail2ban/filter.d/botsearch-common.conf
Normal file
19
fail2ban/filter.d/botsearch-common.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Generic configuration file for -botsearch filters
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Block is the actual non-found directories to block
|
||||||
|
block = \/?(<webmail>|<phpmyadmin>|<wordpress>|cgi-bin|mysqladmin)[^,]*
|
||||||
|
|
||||||
|
# These are just convenient definitions that assist the blocking of stuff that
|
||||||
|
# isn't installed
|
||||||
|
webmail = roundcube|(ext)?mail|horde|(v-?)?webmail
|
||||||
|
|
||||||
|
phpmyadmin = (typo3/|xampp/|admin/|)(pma|(php)?[Mm]y[Aa]dmin)
|
||||||
|
|
||||||
|
wordpress = wp-(login|signup|admin)\.php
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# Taken from apache-botsearch filter
|
||||||
|
#
|
||||||
|
# Author: Frantisek Sumsal
|
||||||
9
fail2ban/filter.d/centreon.conf
Normal file
9
fail2ban/filter.d/centreon.conf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Fail2Ban filter for Centreon Web
|
||||||
|
# Detecting unauthorized access to the Centreon Web portal
|
||||||
|
# typically logged in /var/log/centreon/login.log
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
datepattern = ^%%Y-%%m-%%d %%H:%%M:%%S
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
failregex = ^(?:\|-?\d+){3}\|\[[^\]]*\] \[<HOST>\] Authentication failed for '<F-USER>[^']+</F-USER>'
|
||||||
89
fail2ban/filter.d/common.conf
Normal file
89
fail2ban/filter.d/common.conf
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# Generic configuration items (to be used as interpolations) in other
|
||||||
|
# filters or actions configurations
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Load customizations if any available
|
||||||
|
after = common.local
|
||||||
|
|
||||||
|
|
||||||
|
[DEFAULT]
|
||||||
|
|
||||||
|
# Type of log-file resp. log-format (file, short, journal, rfc542):
|
||||||
|
logtype = file
|
||||||
|
|
||||||
|
# Daemon definition is to be specialized (if needed) in .conf file
|
||||||
|
_daemon = \S*
|
||||||
|
|
||||||
|
#
|
||||||
|
# Shortcuts for easier comprehension of the failregex
|
||||||
|
#
|
||||||
|
# PID.
|
||||||
|
# EXAMPLES: [123]
|
||||||
|
__pid_re = (?:\[\d+\])
|
||||||
|
|
||||||
|
# Daemon name (with optional source_file:line or whatever)
|
||||||
|
# EXAMPLES: pam_rhosts_auth, [sshd], pop(pam_unix)
|
||||||
|
__daemon_re = [\[\(]?<_daemon>(?:\(\S+\))?[\]\)]?:?
|
||||||
|
|
||||||
|
# extra daemon info
|
||||||
|
# EXAMPLE: [ID 800047 auth.info]
|
||||||
|
__daemon_extra_re = \[ID \d+ \S+\]
|
||||||
|
|
||||||
|
# Combinations of daemon name and PID
|
||||||
|
# EXAMPLES: sshd[31607], pop(pam_unix)[4920]
|
||||||
|
__daemon_combs_re = (?:<__pid_re>?:\s+<__daemon_re>|<__daemon_re><__pid_re>?:?)
|
||||||
|
|
||||||
|
# Some messages have a kernel prefix with a timestamp
|
||||||
|
# EXAMPLES: kernel: [769570.846956]
|
||||||
|
__kernel_prefix = kernel:\s?\[ *\d+\.\d+\]:?
|
||||||
|
|
||||||
|
__hostname = \S+
|
||||||
|
|
||||||
|
# A MD5 hex
|
||||||
|
# EXAMPLES: 07:06:27:55:b0:e3:0c:3c:5a:28:2d:7c:7e:4c:77:5f
|
||||||
|
__md5hex = (?:[\da-f]{2}:){15}[\da-f]{2}
|
||||||
|
|
||||||
|
# bsdverbose is where syslogd is started with -v or -vv and results in <4.3> or
|
||||||
|
# <auth.info> appearing before the host as per testcases/files/logs/bsd/*.
|
||||||
|
__bsd_syslog_verbose = <[^.]+\.[^.]+>
|
||||||
|
|
||||||
|
__vserver = @vserver_\S+
|
||||||
|
|
||||||
|
__date_ambit = (?:\[\])
|
||||||
|
|
||||||
|
# Common line prefixes (beginnings) which could be used in filters
|
||||||
|
#
|
||||||
|
# [bsdverbose]? [hostname] [vserver tag] daemon_id spaces
|
||||||
|
#
|
||||||
|
# This can be optional (for instance if we match named native log files)
|
||||||
|
__prefix_line = <lt_<logtype>/__prefix_line>
|
||||||
|
|
||||||
|
# PAM authentication mechanism check for failures, e.g.: pam_unix, pam_sss,
|
||||||
|
# pam_ldap
|
||||||
|
__pam_auth = pam_unix
|
||||||
|
|
||||||
|
# standardly all formats using prefix have line-begin anchored date:
|
||||||
|
datepattern = <lt_<logtype>/datepattern>
|
||||||
|
|
||||||
|
[lt_file]
|
||||||
|
# Common line prefixes for logtype "file":
|
||||||
|
__prefix_line = <__date_ambit>?\s*(?:<__bsd_syslog_verbose>\s+)?(?:<__hostname>\s+)?(?:<__kernel_prefix>\s+)?(?:<__vserver>\s+)?(?:<__daemon_combs_re>\s+)?(?:<__daemon_extra_re>\s+)?
|
||||||
|
datepattern = {^LN-BEG}
|
||||||
|
|
||||||
|
[lt_short]
|
||||||
|
# Common (short) line prefix for logtype "journal" (corresponds output of formatJournalEntry):
|
||||||
|
__prefix_line = \s*(?:<__hostname>\s+)?(?:<_daemon><__pid_re>?:?\s+)?(?:<__kernel_prefix>\s+)?
|
||||||
|
datepattern = %(lt_file/datepattern)s
|
||||||
|
[lt_journal]
|
||||||
|
__prefix_line = %(lt_short/__prefix_line)s
|
||||||
|
datepattern = %(lt_short/datepattern)s
|
||||||
|
|
||||||
|
[lt_rfc5424]
|
||||||
|
# RFC 5424 log-format, see gh-2309:
|
||||||
|
#__prefix_line = \s*<__hostname> <__daemon_re> \d+ \S+ \S+\s+
|
||||||
|
__prefix_line = \s*<__hostname> <__daemon_re> \d+ \S+ (?:[^\[\]\s]+|(?:\[(?:[^\]"]*|"[^"]*")*\])+)\s+
|
||||||
|
datepattern = ^<\d+>\d+\s+{DATE}
|
||||||
|
|
||||||
|
# Author: Yaroslav Halchenko, Sergey G. Brester (aka sebres)
|
||||||
15
fail2ban/filter.d/counter-strike.conf
Normal file
15
fail2ban/filter.d/counter-strike.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Fail2Ban filter for failure attempts in Counter Strike-1.6
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^: Bad Rcon: "rcon \d+ "\S+" sv_contact ".*?"" from "<HOST>:\d+"$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^L %%d/%%m/%%Y - %%H:%%M:%%S
|
||||||
|
|
||||||
|
|
||||||
|
# Author: Daniel Black
|
||||||
|
|
||||||
21
fail2ban/filter.d/courier-auth.conf
Normal file
21
fail2ban/filter.d/courier-auth.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Fail2Ban filter for courier authentication failures
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = (?:courier)?(?:imapd?|pop3d?)(?:login)?(?:-ssl)?
|
||||||
|
|
||||||
|
failregex = ^%(__prefix_line)sLOGIN FAILED, (?:user|method)=.*, ip=\[<HOST>\]$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}
|
||||||
|
|
||||||
|
# Author: Christoph Haas
|
||||||
|
# Modified by: Cyril Jaquier
|
||||||
22
fail2ban/filter.d/courier-smtp.conf
Normal file
22
fail2ban/filter.d/courier-smtp.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Fail2Ban filter to block relay attempts though a Courier smtp server
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = courieresmtpd
|
||||||
|
|
||||||
|
prefregex = ^%(__prefix_line)serror,relay=<HOST>,(?:port=\d+,)?<F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^[^:]*: 550 User (<.*> )?unknown\.?$
|
||||||
|
^msg="535 Authentication failed\.",cmd:( AUTH \S+)?( [0-9a-zA-Z\+/=]+)?(?: \S+)$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Cyril Jaquier
|
||||||
20
fail2ban/filter.d/cyrus-imap.conf
Normal file
20
fail2ban/filter.d/cyrus-imap.conf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Fail2Ban filter for authentication failures on Cyrus imap server
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = (?:cyrus/)?(?:imap(d|s)?|pop3(d|s)?)
|
||||||
|
|
||||||
|
failregex = ^%(__prefix_line)sbadlogin: [^\[]*\[<HOST>\] \S+ .*?\[?SASL\(-13\): (authentication failure|user not found): .*\]?$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Jan Wagner <waja@cyconet.org>
|
||||||
22
fail2ban/filter.d/directadmin.conf
Normal file
22
fail2ban/filter.d/directadmin.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Fail2Ban configuration file for Directadmin
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^: \'<HOST>\' \d{1,3} failed login attempt(s)?. \s*
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^%%Y:%%m:%%d-%%H:%%M:%%S
|
||||||
|
|
||||||
|
#
|
||||||
|
# Requires Directadmin v1.45.3 or higher. http://www.directadmin.com/features.php?id=1590
|
||||||
|
#
|
||||||
|
# Author: Cyril Roos
|
||||||
|
|
||||||
50
fail2ban/filter.d/domino-smtp.conf
Normal file
50
fail2ban/filter.d/domino-smtp.conf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Fail2Ban configuration file for IBM Domino SMTP Server TASK to detect failed login attempts
|
||||||
|
#
|
||||||
|
# Author: Christian Brandlehner
|
||||||
|
#
|
||||||
|
# $Revision: 003 $
|
||||||
|
#
|
||||||
|
# Configuration:
|
||||||
|
# Set the following Domino Server parameters in notes.ini:
|
||||||
|
# console_log_enabled=1
|
||||||
|
# log_sessions=2
|
||||||
|
# You also have to use a date and time format supported by fail2ban. Recommended notes.ini configuration is:
|
||||||
|
# DateOrder=DMY
|
||||||
|
# DateSeparator=-
|
||||||
|
# ClockType=24_Hour
|
||||||
|
# TimeSeparator=:
|
||||||
|
#
|
||||||
|
# Depending on your locale you might have to tweak the date and time format so fail2ban can read the log
|
||||||
|
|
||||||
|
#[INCLUDES]
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
#before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
# Option: failregex
|
||||||
|
# Notes.: regex to match the password failure messages in the logfile. The
|
||||||
|
# host must be matched by a group named "host". The tag "<HOST>" can
|
||||||
|
# be used for standard IP/hostname matching and is only an alias for
|
||||||
|
# (?:::f{4,6}:)?(?P<host>\S+)
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
# Sample log entries (used different time formats and an extra sample with process info in front of date)
|
||||||
|
# 01-23-2009 19:54:51 SMTP Server: Authentication failed for user postmaster ; connecting host 1.2.3.4
|
||||||
|
# [28325:00010-3735542592] 22-06-2014 09:56:12 smtp: postmaster [1.2.3.4] authentication failure using internet password
|
||||||
|
# 08-09-2014 06:14:27 smtp: postmaster [1.2.3.4] authentication failure using internet password
|
||||||
|
# 08-09-2014 06:14:27 SMTP Server: Authentication failed for user postmaster ; connecting host 1.2.3.4
|
||||||
|
|
||||||
|
__prefix = (?:\[[^\]]+\])?\s*
|
||||||
|
__opt_data = (?::|\s+\[[^\]]+\])
|
||||||
|
failregex = ^%(__prefix)sSMTP Server%(__opt_data)s Authentication failed for user .*? \; connecting host \[?<HOST>\]?$
|
||||||
|
^%(__prefix)ssmtp: (?:[^\[]+ )*\[?<HOST>\]? authentication failure using internet password\s*$
|
||||||
|
^%(__prefix)sSMTP Server%(__opt_data)s Connection from \[?<HOST>\]? rejected for policy reasons\.
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes.: regex to ignore. If this regex matches, the line is ignored.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
47
fail2ban/filter.d/dovecot.conf
Normal file
47
fail2ban/filter.d/dovecot.conf
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Fail2Ban filter Dovecot authentication and pop3/imap server
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_auth_worker = (?:dovecot: )?auth(?:-worker)?
|
||||||
|
_daemon = (?:dovecot(?:-auth)?|auth)
|
||||||
|
|
||||||
|
prefregex = ^%(__prefix_line)s(?:%(_auth_worker)s(?:\([^\)]+\))?: )?(?:%(__pam_auth)s(?:\(dovecot:auth\))?: |(?:pop3|imap|managesieve|submission)-login: )?(?:Info: )?<F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^authentication failure; logname=<F-ALT_USER1>\S*</F-ALT_USER1> uid=\S* euid=\S* tty=dovecot ruser=<F-USER>\S*</F-USER> rhost=<HOST>(?:\s+user=<F-ALT_USER>\S*</F-ALT_USER>)?\s*$
|
||||||
|
^(?:Aborted login|Disconnected|Remote closed connection|Client has quit the connection)(?::(?: [^ \(]+)+)? \((?:auth failed, \d+ attempts(?: in \d+ secs)?|tried to use (?:disabled|disallowed) \S+ auth|proxy dest auth failed)\):(?: user=<<F-USER>[^>]*</F-USER>>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
|
||||||
|
^pam\(\S+,<HOST>(?:,\S*)?\): pam_authenticate\(\) failed: (?:User not known to the underlying authentication module: \d+ Time\(s\)|Authentication failure \(password mismatch\?\)|Permission denied)\s*$
|
||||||
|
^[a-z\-]{3,15}\(\S*,<HOST>(?:,\S*)?\): (?:unknown user|invalid credentials|Password mismatch)
|
||||||
|
<mdre-<mode>>
|
||||||
|
|
||||||
|
mdre-aggressive = ^(?:Aborted login|Disconnected|Remote closed connection|Client has quit the connection)(?::(?: [^ \(]+)+)? \((?:no auth attempts|disconnected before auth was ready,|client didn't finish \S+ auth,)(?: (?:in|waited) \d+ secs)?\):(?: user=<[^>]*>,)?(?: method=\S+,)? rip=<HOST>(?:[^>]*(?:, session=<\S+>)?)\s*$
|
||||||
|
|
||||||
|
mdre-normal =
|
||||||
|
|
||||||
|
# Parameter `mode` - `normal` or `aggressive`.
|
||||||
|
# Aggressive mode can be used to match log-entries like:
|
||||||
|
# 'no auth attempts', 'disconnected before auth was ready', 'client didn't finish SASL auth'.
|
||||||
|
# Note it may produce lots of false positives on misconfigured MTAs.
|
||||||
|
# Ex.:
|
||||||
|
# filter = dovecot[mode=aggressive]
|
||||||
|
mode = normal
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
journalmatch = _SYSTEMD_UNIT=dovecot.service
|
||||||
|
|
||||||
|
datepattern = {^LN-BEG}TAI64N
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# * the first regex is essentially a copy of pam-generic.conf
|
||||||
|
# * Probably doesn't do dovecot sql/ldap backends properly (resolved in edit 21/03/2016)
|
||||||
|
#
|
||||||
|
# Author: Martin Waschbuesch
|
||||||
|
# Daniel Black (rewrote with begin and end anchors)
|
||||||
|
# Martin O'Neal (added LDAP authentication failure regex)
|
||||||
|
# Sergey G. Brester aka sebres (reviewed, optimized, IPv6-compatibility)
|
||||||
50
fail2ban/filter.d/dropbear.conf
Normal file
50
fail2ban/filter.d/dropbear.conf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Fail2Ban filter for dropbear
|
||||||
|
#
|
||||||
|
# NOTE: The regex below is ONLY intended to work with a patched
|
||||||
|
# version of Dropbear as described here:
|
||||||
|
# http://www.unchartedbackwaters.co.uk/pyblosxom/static/patches
|
||||||
|
# ^%(__prefix_line)sexit before auth from <HOST>.*\s*$
|
||||||
|
#
|
||||||
|
# The standard Dropbear output doesn't provide enough information to
|
||||||
|
# ban all types of attack. The Dropbear patch adds IP address
|
||||||
|
# information to the 'exit before auth' message which is always
|
||||||
|
# produced for any form of non-successful login. It is that message
|
||||||
|
# which this file matches.
|
||||||
|
#
|
||||||
|
# More information: http://bugs.debian.org/546913
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = dropbear
|
||||||
|
|
||||||
|
prefregex = ^%(__prefix_line)s<F-CONTENT>(?:[Ll]ogin|[Bb]ad|[Ee]xit).+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^[Ll]ogin attempt for nonexistent user ('.*' )?from <HOST>:\d+$
|
||||||
|
^[Bb]ad (PAM )?password attempt for .+ from <HOST>(:\d+)?$
|
||||||
|
^[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from <HOST>:\d+\s*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# The first two regexs here match the unmodified dropbear messages. It isn't
|
||||||
|
# possible to match the source of the 'exit before auth' messages from dropbear
|
||||||
|
# as they don't include the "from <HOST>" bit.
|
||||||
|
#
|
||||||
|
# The second last failregex line we need to match with the modified dropbear.
|
||||||
|
#
|
||||||
|
# For the second regex the following apply:
|
||||||
|
#
|
||||||
|
# http://www.netmite.com/android/mydroid/external/dropbear/svr-authpam.c
|
||||||
|
# http://svn.dd-wrt.com/changeset/16642#file64
|
||||||
|
#
|
||||||
|
# http://svn.dd-wrt.com/changeset/16642/src/router/dropbear/svr-authpasswd.c
|
||||||
|
#
|
||||||
|
# Author: Francis Russell
|
||||||
|
# Zak B. Elep
|
||||||
26
fail2ban/filter.d/drupal-auth.conf
Normal file
26
fail2ban/filter.d/drupal-auth.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Fail2Ban filter to block repeated failed login attempts to Drupal site(s)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Drupal must be setup to use Syslog, which defaults to the following format:
|
||||||
|
#
|
||||||
|
# !base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^%(__prefix_line)s(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})(\/[\w\.-]+)*\|\d{10}\|user\|<HOST>\|.+\|.+\|\d\|.*\|Login attempt failed for .+\.$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# https://www.drupal.org/documentation/modules/syslog
|
||||||
|
#
|
||||||
|
# Author: Lee Clemens
|
||||||
40
fail2ban/filter.d/ejabberd-auth.conf
Normal file
40
fail2ban/filter.d/ejabberd-auth.conf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Steven Hiscocks
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes.: regex to match the password failures messages in the logfile. The
|
||||||
|
# host must be matched by a group named "host". The tag "<HOST>" can
|
||||||
|
# be used for standard IP/hostname matching and is only an alias for
|
||||||
|
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
|
||||||
|
# Multiline regexs should use tag "<SKIPLINES>" to separate lines.
|
||||||
|
# This allows lines between the matching lines to continue to be
|
||||||
|
# searched for other failures. This tag can be used multiple times.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
failregex = ^=INFO REPORT==== ===\nI\(<0\.\d+\.0>:ejabberd_c2s:\d+\) : \([^)]+\) Failed authentication for \S+ from (?:IP )?<HOST>(?: \({{(?:\d+,){3}\d+},\d+}\))?$
|
||||||
|
^(?:\.\d+)? \[info\] <0\.\d+\.\d>@ejabberd_c2s:\w+:\d+ \([^\)]+\) Failed (?:c2s \w+ )?authentication for \S+ from (?:IP )?(?:::FFFF:)?<HOST>(?:: |$)
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes.: regex to ignore. If this regex matches, the line is ignored.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# "maxlines" is number of log lines to buffer for multi-line regex searches
|
||||||
|
maxlines = 2
|
||||||
|
|
||||||
|
# Option: journalmatch
|
||||||
|
# Notes.: systemd journalctl style match filter for journal based backend
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
journalmatch =
|
||||||
|
|
||||||
|
#datepattern = ^(?:=[^=]+={3,} )?({DATE})
|
||||||
|
# explicit time format using prefix =...==== and no date in second string begins with I(...)...
|
||||||
|
datepattern = ^(?:=[^=]+={3,} )?(%%ExY(?P<_sep>[-/.])%%m(?P=_sep)%%d[T ]%%H:%%M:%%S(?:[.,]%%f)?(?:\s*%%z)?)
|
||||||
|
^I\(()**
|
||||||
20
fail2ban/filter.d/exim-common.conf
Normal file
20
fail2ban/filter.d/exim-common.conf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Fail2Ban filter file for common exim expressions
|
||||||
|
#
|
||||||
|
# This is to be used by other exim filters
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Load customizations if any available
|
||||||
|
after = exim-common.local
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
host_info_pre = (?:H=([\w.-]+ )?(?:\(\S+\) )?)?
|
||||||
|
host_info_suf = (?::\d+)?(?: I=\[\S+\](:\d+)?)?(?: U=\S+)?(?: P=e?smtp)?(?: F=(?:<>|[^@]+@\S+))?\s
|
||||||
|
host_info = %(host_info_pre)s\[<HOST>\]%(host_info_suf)s
|
||||||
|
pid = (?: \[\d+\])?
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# From exim source code: ./src/receive.c:add_host_info_for_log
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
50
fail2ban/filter.d/exim-spam.conf
Normal file
50
fail2ban/filter.d/exim-spam.conf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Fail2Ban filter for exim the spam rejection messages
|
||||||
|
#
|
||||||
|
# Honeypot traps are very useful for fighting spam. You just activate an email
|
||||||
|
# address on your domain that you do not intend to use at all, and that normal
|
||||||
|
# people do not risk to try for contacting you. It may be something that
|
||||||
|
# spammers often test. You can also hide the address on a web page to be picked
|
||||||
|
# by spam spiders. Or simply parse your mail logs for an invalid address
|
||||||
|
# already being frequently targeted by spammers. Enable the address and
|
||||||
|
# redirect it to the blackhole. In Exim's alias file, you would add the
|
||||||
|
# following line (assuming the address is honeypot@yourdomain.com):
|
||||||
|
#
|
||||||
|
# honeypot: :blackhole:
|
||||||
|
#
|
||||||
|
# For the SA: Action: silently tossed message... to be logged exim's SAdevnull option needs to be used.
|
||||||
|
#
|
||||||
|
# To this filter use the jail.local should contain in the right jail:
|
||||||
|
#
|
||||||
|
# filter = exim-spam[honeypot=honeypot@yourdomain.com]
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# exim-common.local
|
||||||
|
before = exim-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^%(pid)s \S+ F=(<>|\S+@\S+) %(host_info)srejected by local_scan\(\): .{0,256}$
|
||||||
|
^%(pid)s %(host_info)sF=(<>|[^@]+@\S+) rejected RCPT [^@]+@\S+: .*dnsbl.*\s*$
|
||||||
|
^%(pid)s \S+ %(host_info)sF=(<>|[^@]+@\S+) rejected after DATA: This message contains a virus \(\S+\)\.\s*$
|
||||||
|
^%(pid)s \S+ SA: Action: flagged as Spam but accepted: score=\d+\.\d+ required=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=\S+ \[<HOST>\]\) for <honeypot>$
|
||||||
|
^%(pid)s \S+ SA: Action: silently tossed message: score=\d+\.\d+ required=\d+\.\d+ trigger=\d+\.\d+ \(scanned in \d+/\d+ secs \| Message-Id: \S+\)\. From \S+ \(host=(\S+ )?\[<HOST>\]\) for \S+$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: honeypot
|
||||||
|
# Notes.: honeypot is an email address that isn't published anywhere that a
|
||||||
|
# legitimate email sender would send email too.
|
||||||
|
# Values: email address
|
||||||
|
|
||||||
|
honeypot = trap@example.com
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# The %(host_info) defination contains a <HOST> match
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Daniel Black (rewrote with strong regexs)
|
||||||
54
fail2ban/filter.d/exim.conf
Normal file
54
fail2ban/filter.d/exim.conf
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# Fail2Ban filter for exim
|
||||||
|
#
|
||||||
|
# This includes the rejection messages of exim. For spam and filter
|
||||||
|
# related bans use the exim-spam.conf
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# exim-common.local
|
||||||
|
before = exim-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Fre-filter via "prefregex" is currently inactive because of too different failure syntax in exim-log (testing needed):
|
||||||
|
#prefregex = ^%(pid)s <F-CONTENT>\b(?:\w+ authenticator failed|([\w\-]+ )?SMTP (?:(?:call|connection) from|protocol(?: synchronization)? error)|no MAIL in|(?:%(host_info_pre)s\[[^\]]+\]%(host_info_suf)s(?:sender verify fail|rejected RCPT|dropped|AUTH command))).+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^%(pid)s %(host_info)ssender verify fail for <\S+>: (?:Unknown user|Unrouteable address|all relevant MX records point to non-existent hosts)\s*$
|
||||||
|
^%(pid)s \w+ authenticator failed for (?:[^\[\( ]* )?(?:\(\S*\) )?\[<HOST>\](?::\d+)?(?: I=\[\S+\](:\d+)?)?: 535 Incorrect authentication data( \(set_id=.*\)|: \d+ Time\(s\))?\s*$
|
||||||
|
^%(pid)s %(host_info)srejected RCPT [^@]+@\S+: (?:relay not permitted|Sender verify failed|Unknown user|Unrouteable address)\s*$
|
||||||
|
^%(pid)s SMTP protocol synchronization error \([^)]*\): rejected (?:connection from|"\S+") %(host_info)s(?:next )?input=".*"\s*$
|
||||||
|
^%(pid)s SMTP call from (?:[^\[\( ]* )?%(host_info)sdropped: too many (?:nonmail commands|syntax or protocol errors) \(last (?:command )?was "[^"]*"\)\s*$
|
||||||
|
^%(pid)s SMTP protocol error in "[^"]+(?:"+[^"]*(?="))*?" %(host_info)sAUTH command used when not advertised\s*$
|
||||||
|
^%(pid)s no MAIL in SMTP connection from (?:[^\[\( ]* )?(?:\(\S*\) )?%(host_info)sD=\d\S*s(?: C=\S*)?\s*$
|
||||||
|
^%(pid)s (?:[\w\-]+ )?SMTP connection from (?:[^\[\( ]* )?(?:\(\S*\) )?%(host_info)sclosed by DROP in ACL\s*$
|
||||||
|
<mdre-<mode>>
|
||||||
|
|
||||||
|
mdre-aggressive = ^%(pid)s no host name found for IP address <HOST>$
|
||||||
|
^%(pid)s no IP address found for host \S+ \(during SMTP connection from \[<HOST>\]\)$
|
||||||
|
|
||||||
|
mdre-normal =
|
||||||
|
|
||||||
|
# Parameter `mode` - `normal` or `aggressive`.
|
||||||
|
# Aggressive mode can be used to match flood and ddos-similar log-entries like:
|
||||||
|
# 'no host found for IP', 'no IP found for host'.
|
||||||
|
# Note this is not an authentication failures, so it may produce lots of false
|
||||||
|
# positives on misconfigured MTAs.
|
||||||
|
# Ex.:
|
||||||
|
# filter = exim[mode=aggressive]
|
||||||
|
mode = normal
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# The %(host_info) defination contains a <HOST> match
|
||||||
|
#
|
||||||
|
# SMTP protocol synchronization error \([^)]*\) <- This needs to be non-greedy
|
||||||
|
# to void capture beyond ")" to avoid a DoS Injection vulnerabilty as input= is
|
||||||
|
# user injectable data.
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Daniel Black (rewrote with strong regexs)
|
||||||
|
# Martin O'Neal (added additional regexs to detect authentication failures, protocol errors, and drops)
|
||||||
58
fail2ban/filter.d/freeswitch.conf
Normal file
58
fail2ban/filter.d/freeswitch.conf
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Enable "log-auth-failures" on each Sofia profile to monitor
|
||||||
|
# <param name="log-auth-failures" value="true"/>
|
||||||
|
# -- this requires a high enough loglevel on your logs to save these messages.
|
||||||
|
#
|
||||||
|
# In the fail2ban jail.local file for this filter set ignoreip to the internal
|
||||||
|
# IP addresses on your LAN.
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = freeswitch
|
||||||
|
|
||||||
|
# Parameter "mode": normal, ddos or extra (default, combines all)
|
||||||
|
# Usage example (for jail.local):
|
||||||
|
# [freeswitch]
|
||||||
|
# mode = normal
|
||||||
|
# # or with rewrite filter parameters of jail:
|
||||||
|
# [freeswitch-ddos]
|
||||||
|
# filter = freeswitch[mode=ddos]
|
||||||
|
#
|
||||||
|
mode = extra
|
||||||
|
|
||||||
|
# Prefix contains common prefix line (server, daemon, etc.) and 2 datetimes if used systemd backend
|
||||||
|
_pref_line = ^%(__prefix_line)s(?:(?:\d+-)?\d+-\d+ \d+:\d+:\d+\.\d+)?
|
||||||
|
|
||||||
|
prefregex = ^%(_pref_line)s \[WARN(?:ING)?\](?: \[SOFIA\])? \[?sofia_reg\.c:\d+\]? <F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
cmnfailre = ^Can't find user \[[^@]+@[^\]]+\] from <HOST>$
|
||||||
|
|
||||||
|
mdre-normal = %(cmnfailre)s
|
||||||
|
^SIP auth failure \((REGISTER|INVITE)\) on sofia profile \'[^']+\' for \[[^\]]*\] from ip <HOST>$
|
||||||
|
|
||||||
|
mdre-ddos = ^SIP auth (?:failure|challenge) \((REGISTER|INVITE)\) on sofia profile \'[^']+\' for \[[^\]]*\] from ip <HOST>$
|
||||||
|
|
||||||
|
mdre-extra = %(cmnfailre)s
|
||||||
|
<mdre-ddos>
|
||||||
|
|
||||||
|
failregex = <mdre-<mode>>
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^(?:%%Y-)?%%m-%%d[ T]%%H:%%M:%%S(?:\.%%f)?
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
# Author: Rupa SChomaker, soapee01, Daniel Black, Sergey Brester aka sebres
|
||||||
|
# https://freeswitch.org/confluence/display/FREESWITCH/Fail2Ban
|
||||||
|
# Thanks to Jim on mailing list of samples and guidance
|
||||||
|
#
|
||||||
|
# No need to match the following. Its a duplicate of the SIP auth regex.
|
||||||
|
# ^\.\d+ \[DEBUG\] sofia\.c:\d+ IP <HOST> Rejected by acl "\S+"\. Falling back to Digest auth\.$
|
||||||
40
fail2ban/filter.d/froxlor-auth.conf
Normal file
40
fail2ban/filter.d/froxlor-auth.conf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Fail2Ban configuration file to block repeated failed login attempts to Frolor installation(s)
|
||||||
|
#
|
||||||
|
# Froxlor needs to log to Syslog User (e.g. /var/log/user.log) with one of the following messages
|
||||||
|
# <syslog prefix> Froxlor: [Login Action <HOST>] Unknown user '<USER>' tried to login.
|
||||||
|
# <syslog prefix> Froxlor: [Login Action <HOST>] User '<USER>' tried to login with wrong password.
|
||||||
|
#
|
||||||
|
# Author: Joern Muehlencord
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = Froxlor
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes.: regex to match the password failures messages in the logfile. The
|
||||||
|
# host must be matched by a group named "host". The tag "<HOST>" can
|
||||||
|
# be used for standard IP/hostname matching and is only an alias for
|
||||||
|
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
prefregex = ^%(__prefix_line)s\[Login Action <HOST>\] <F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^Unknown user \S* tried to login.$
|
||||||
|
^User \S* tried to login with wrong password.$
|
||||||
|
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes.: regex to ignore. If this regex matches, the line is ignored.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
6
fail2ban/filter.d/gitlab.conf
Normal file
6
fail2ban/filter.d/gitlab.conf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Fail2Ban filter for Gitlab
|
||||||
|
# Detecting unauthorized access to the Gitlab Web portal
|
||||||
|
# typically logged in /var/log/gitlab/gitlab-rails/application.log
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
failregex = ^: Failed Login: username=<F-USER>.+</F-USER> ip=<HOST>$
|
||||||
9
fail2ban/filter.d/grafana.conf
Normal file
9
fail2ban/filter.d/grafana.conf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Fail2Ban filter for Grafana
|
||||||
|
# Detecting unauthorized access
|
||||||
|
# Typically logged in /var/log/grafana/grafana.log
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
datepattern = ^t=%%Y-%%m-%%dT%%H:%%M:%%S%%z
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
failregex = ^(?: lvl=err?or)? msg="Invalid username or password"(?: uname=(?:"<F-ALT_USER>[^"]+</F-ALT_USER>"|<F-USER>\S+</F-USER>)| error="<F-ERROR>[^"]+</F-ERROR>"| \S+=(?:\S*|"[^"]+"))* remote_addr=<ADDR>$
|
||||||
14
fail2ban/filter.d/groupoffice.conf
Normal file
14
fail2ban/filter.d/groupoffice.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Fail2Ban filter for Group-Office
|
||||||
|
#
|
||||||
|
# Enable logging with:
|
||||||
|
# $config['info_log']='/home/groupoffice/log/info.log';
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^\[\]LOGIN FAILED for user: "\S+" from IP: <HOST>$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Daniel Black
|
||||||
|
|
||||||
18
fail2ban/filter.d/gssftpd.conf
Normal file
18
fail2ban/filter.d/gssftpd.conf
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Fail2Ban filter file for gssftp
|
||||||
|
#
|
||||||
|
# Note: gssftp is part of the krb5-appl-servers in Fedora
|
||||||
|
#
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = ftpd
|
||||||
|
|
||||||
|
failregex = ^%(__prefix_line)srepeated login failures from <HOST> \(\S+\)$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Kevin Zembower
|
||||||
|
# Edited: Daniel Black - syslog based daemon
|
||||||
51
fail2ban/filter.d/guacamole.conf
Normal file
51
fail2ban/filter.d/guacamole.conf
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Fail2Ban configuration file for guacamole
|
||||||
|
#
|
||||||
|
# Author: Steven Hiscocks
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
logging = catalina
|
||||||
|
failregex = <L_<logging>/failregex>
|
||||||
|
maxlines = <L_<logging>/maxlines>
|
||||||
|
datepattern = <L_<logging>/datepattern>
|
||||||
|
|
||||||
|
[L_catalina]
|
||||||
|
|
||||||
|
failregex = ^.*\nWARNING: Authentication attempt from <HOST> for user "[^"]*" failed\.$
|
||||||
|
|
||||||
|
maxlines = 2
|
||||||
|
|
||||||
|
datepattern = ^%%b %%d, %%ExY %%I:%%M:%%S %%p
|
||||||
|
^WARNING:()**
|
||||||
|
{^LN-BEG}
|
||||||
|
|
||||||
|
[L_webapp]
|
||||||
|
|
||||||
|
failregex = ^ \[\S+\] WARN \S+ - Authentication attempt from <HOST> for user "<F-USER>[^"]+</F-USER>" failed.
|
||||||
|
|
||||||
|
maxlines = 1
|
||||||
|
|
||||||
|
datepattern = ^%%H:%%M:%%S.%%f
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# failregex is based on the default pattern given in Guacamole documentation :
|
||||||
|
# https://guacamole.apache.org/doc/gug/configuring-guacamole.html#webapp-logging
|
||||||
|
#
|
||||||
|
# The following logback.xml Guacamole configuration file can then be used accordingly :
|
||||||
|
# <configuration>
|
||||||
|
# <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
# <file>/var/log/guacamole.log</file>
|
||||||
|
# <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
# <fileNamePattern>/var/log/guacamole.%d.log.gz</fileNamePattern>
|
||||||
|
# <maxHistory>32</maxHistory>
|
||||||
|
# </rollingPolicy>
|
||||||
|
# <encoder>
|
||||||
|
# <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
# </encoder>
|
||||||
|
# </appender>
|
||||||
|
# <root level="info">
|
||||||
|
# <appender-ref ref="FILE" />
|
||||||
|
# </root>
|
||||||
|
# </configuration>
|
||||||
37
fail2ban/filter.d/haproxy-http-auth.conf
Normal file
37
fail2ban/filter.d/haproxy-http-auth.conf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Fail2Ban filter configuration file to match failed login attempts to
|
||||||
|
# HAProxy HTTP Authentication protected servers.
|
||||||
|
#
|
||||||
|
# PLEASE NOTE - When a user first hits the HTTP Auth a 401 is returned by the server
|
||||||
|
# which prompts their browser to ask for login details.
|
||||||
|
# This initial 401 is logged by HAProxy.
|
||||||
|
# In other words, even successful logins will have at least 1 fail regex match.
|
||||||
|
# Please keep this in mind when setting findtime and maxretry for jails.
|
||||||
|
#
|
||||||
|
# Author: Jordan Moeser
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = haproxy
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes.: regex to match the password failures messages in the logfile. The
|
||||||
|
# host must be matched by a group named "host". The tag "<HOST>" can
|
||||||
|
# be used for standard IP/hostname matching and is only an alias for
|
||||||
|
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
failregex = ^%(__prefix_line)s<HOST>(?::\d+)?\s+.*<NOSRV> -1/-1/-1/-1/\+*\d* 401
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes.: regex to ignore. If this regex matches, the line is ignored.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
ignoreregex =
|
||||||
16
fail2ban/filter.d/horde.conf
Normal file
16
fail2ban/filter.d/horde.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# fail2ban filter configuration for horde
|
||||||
|
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
|
||||||
|
failregex = ^ HORDE \[error\] \[(horde|imp)\] FAILED LOGIN for \S+ \[<HOST>\](\(forwarded for \[\S+\]\))? to (Horde|{[^}]+}) \[(pid \d+ )?on line \d+ of \S+\]$
|
||||||
|
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
# https://github.com/horde/horde/blob/master/imp/lib/Auth.php#L132
|
||||||
|
# https://github.com/horde/horde/blob/master/horde/login.php
|
||||||
|
#
|
||||||
|
# Author: Daniel Black
|
||||||
38
fail2ban/filter.d/ignorecommands/apache-fakegooglebot
Executable file
38
fail2ban/filter.d/ignorecommands/apache-fakegooglebot
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/fail2ban-python
|
||||||
|
# Inspired by https://isc.sans.edu/forums/diary/When+Google+isnt+Google/15968/
|
||||||
|
#
|
||||||
|
# Written in Python to reuse built-in Python batteries and not depend on
|
||||||
|
# presence of host and cut commands
|
||||||
|
#
|
||||||
|
import sys
|
||||||
|
from fail2ban.server.ipdns import DNSUtils, IPAddr
|
||||||
|
|
||||||
|
def process_args(argv):
|
||||||
|
if len(argv) != 2:
|
||||||
|
raise ValueError("Please provide a single IP as an argument. Got: %s\n"
|
||||||
|
% (argv[1:]))
|
||||||
|
ip = argv[1]
|
||||||
|
|
||||||
|
if not IPAddr(ip).isValid:
|
||||||
|
raise ValueError("Argument must be a single valid IP. Got: %s\n"
|
||||||
|
% ip)
|
||||||
|
return ip
|
||||||
|
|
||||||
|
google_ips = None
|
||||||
|
|
||||||
|
def is_googlebot(ip):
|
||||||
|
import re
|
||||||
|
|
||||||
|
host = DNSUtils.ipToName(ip)
|
||||||
|
if not host or not re.match(r'.*\.google(bot)?\.com$', host):
|
||||||
|
return False
|
||||||
|
host_ips = DNSUtils.dnsToIp(host)
|
||||||
|
return (ip in host_ips)
|
||||||
|
|
||||||
|
if __name__ == '__main__': # pragma: no cover
|
||||||
|
try:
|
||||||
|
ret = is_googlebot(process_args(sys.argv))
|
||||||
|
except ValueError as e:
|
||||||
|
sys.stderr.write(str(e))
|
||||||
|
sys.exit(2)
|
||||||
|
sys.exit(0 if ret else 1)
|
||||||
24
fail2ban/filter.d/kerio.conf
Normal file
24
fail2ban/filter.d/kerio.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Fail2ban filter for kerio
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^ SMTP Spam attack detected from <HOST>,
|
||||||
|
^ IP address <HOST> found in DNS blacklist
|
||||||
|
^ Relay attempt from IP address <HOST>
|
||||||
|
^ Attempt to deliver to unknown recipient \S+, from \S+, IP address <HOST>$
|
||||||
|
^ Failed SMTP login from <HOST>
|
||||||
|
^ SMTP: User \S+ doesn't exist. Attempt from IP address <HOST>
|
||||||
|
^ Client with IP address <HOST> has no reverse DNS entry, connection rejected before SMTP greeting$
|
||||||
|
^ Administration login into Web Administration from <HOST> failed: IP address not allowed$
|
||||||
|
^ Message from IP address <HOST>, sender \S+ rejected: sender domain does not exist$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^\[%%d/%%b/%%Y %%H:%%M:%%S\]
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: A.P. Lawrence
|
||||||
|
# Updated by: M. Bischoff <https://github.com/herrbischoff>
|
||||||
|
#
|
||||||
|
# Based off: http://aplawrence.com/Kerio/fail2ban.html
|
||||||
10
fail2ban/filter.d/lighttpd-auth.conf
Normal file
10
fail2ban/filter.d/lighttpd-auth.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Fail2Ban filter to match wrong passwords as notified by lighttpd's auth Module
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
failregex = ^: \((?:http|mod)_auth\.c\.\d+\) (?:password doesn\'t match .* username: .*|digest: auth failed for .*: wrong password|get_password failed), IP: <HOST>\s*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# Author: Francois Boulogne <fboulogne@april.org>
|
||||||
49
fail2ban/filter.d/mongodb-auth.conf
Normal file
49
fail2ban/filter.d/mongodb-auth.conf
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Fail2Ban filter for unsuccesfull MongoDB authentication attempts
|
||||||
|
#
|
||||||
|
# Logfile /var/log/mongodb/mongodb.log
|
||||||
|
#
|
||||||
|
# add setting in /etc/mongodb.conf
|
||||||
|
# logpath=/var/log/mongodb/mongodb.log
|
||||||
|
#
|
||||||
|
# and use of the authentication
|
||||||
|
# auth = true
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
#failregex = ^\s+\[initandlisten\] connection accepted from <HOST>:\d+ \#(?P<__connid>\d+) \(1 connection now open\)<SKIPLINES>\s+\[conn(?P=__connid)\] Failed to authenticate\s+
|
||||||
|
failregex = ^\s+\[conn(?P<__connid>\d+)\] Failed to authenticate [^\n]+<SKIPLINES>\s+\[conn(?P=__connid)\] end connection <HOST>
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
maxlines = 10
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Regarding the multiline regex:
|
||||||
|
#
|
||||||
|
# There can be a nunber of non-related lines between the first and second part
|
||||||
|
# of this regex maxlines of 10 is quite generious.
|
||||||
|
#
|
||||||
|
# Note the capture __connid, includes the connection ID, used in second part of regex.
|
||||||
|
#
|
||||||
|
# The first regex is commented out (but will match also), because it is better to use
|
||||||
|
# the host from "end connection" line (uncommented above):
|
||||||
|
# - it has the same prefix, searching begins directly with failure message
|
||||||
|
# (so faster, because ignores success connections at all)
|
||||||
|
# - it is not so vulnerable in case of possible race condition
|
||||||
|
#
|
||||||
|
# Log example:
|
||||||
|
# 2016-10-20T09:54:27.108+0200 [initandlisten] connection accepted from 127.0.0.1:53276 #1 (1 connection now open)
|
||||||
|
# 2016-10-20T09:54:27.109+0200 [conn1] authenticate db: test { authenticate: 1, nonce: "xxx", user: "root", key: "xxx" }
|
||||||
|
# 2016-10-20T09:54:27.110+0200 [conn1] Failed to authenticate root@test with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user root@test
|
||||||
|
# 2016-11-09T09:54:27.894+0100 [conn1] end connection 127.0.0.1:53276 (0 connections now open)
|
||||||
|
# 2016-11-09T11:55:58.890+0100 [initandlisten] connection accepted from 127.0.0.1:54266 #1510 (1 connection now open)
|
||||||
|
# 2016-11-09T11:55:58.892+0100 [conn1510] authenticate db: admin { authenticate: 1, nonce: "xxx", user: "root", key: "xxx" }
|
||||||
|
# 2016-11-09T11:55:58.892+0100 [conn1510] Failed to authenticate root@admin with mechanism MONGODB-CR: AuthenticationFailed key mismatch
|
||||||
|
# 2016-11-09T11:55:58.894+0100 [conn1510] end connection 127.0.0.1:54266 (0 connections now open)
|
||||||
|
#
|
||||||
|
# Authors: Alexander Finkhäuser
|
||||||
|
# Sergey G. Brester (sebres)
|
||||||
|
|
||||||
25
fail2ban/filter.d/monit.conf
Normal file
25
fail2ban/filter.d/monit.conf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Fail2Ban filter for monit.conf, looks for failed access attempts
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
# [DEFAULT]
|
||||||
|
# logtype = short
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = monit
|
||||||
|
|
||||||
|
_prefix = Warning|HttpRequest
|
||||||
|
|
||||||
|
# Regexp for previous (accessing monit httpd) and new (access denied) versions
|
||||||
|
failregex = ^%(__prefix_line)s(?:error\s*:\s+)?(?:%(_prefix)s):\s+(?:access denied\s+--\s+)?[Cc]lient '?<HOST>'?(?:\s+supplied|\s*:)\s+(?:unknown user '<F-ALT_USER>[^']+</F-ALT_USER>'|wrong password for user '<F-USER>[^']*</F-USER>'|empty password)
|
||||||
|
|
||||||
|
# Ignore login with empty user (first connect, no user specified)
|
||||||
|
# ignoreregex = %(__prefix_line)s\w+: access denied -- client <HOST>: (?:unknown user '')
|
||||||
|
ignoreregex =
|
||||||
34
fail2ban/filter.d/murmur.conf
Normal file
34
fail2ban/filter.d/murmur.conf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Fail2Ban filter for murmur/mumble-server
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = murmurd
|
||||||
|
|
||||||
|
# N.B. If you allow users to have usernames that include the '>' character you
|
||||||
|
# should change this to match the regex assigned to the 'username'
|
||||||
|
# variable in your server config file (murmur.ini / mumble-server.ini).
|
||||||
|
_usernameregex = [^>]+
|
||||||
|
|
||||||
|
# Prefix for systemd-journal (with second date-pattern as optional match):
|
||||||
|
#
|
||||||
|
__prefix_journal = (?:\S+\s+%(_daemon)s\[\d+\]:(?:\s+\<W\>[\d\-]+ [\d:]+.\d+)?)
|
||||||
|
|
||||||
|
__prefix_line = %(__prefix_journal)s?
|
||||||
|
|
||||||
|
_prefix = %(__prefix_line)s\s+\d+ => <\d+:%(_usernameregex)s\(-1\)> Rejected connection from <HOST>:\d+:
|
||||||
|
|
||||||
|
prefregex = ^%(_prefix)s <F-CONTENT>.+</F-CONTENT>$
|
||||||
|
|
||||||
|
failregex = ^Invalid server password$
|
||||||
|
^Wrong certificate or password for existing user$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
datepattern = ^<W>{DATE}
|
||||||
|
|
||||||
|
journalmatch = _SYSTEMD_UNIT=murmurd.service + _COMM=murmurd
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Author: Ross Brown
|
||||||
32
fail2ban/filter.d/mysqld-auth.conf
Normal file
32
fail2ban/filter.d/mysqld-auth.conf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Fail2Ban filter for unsuccesful MySQL authentication attempts
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# To log wrong MySQL access attempts add to /etc/my.cnf in [mysqld]:
|
||||||
|
# log-error=/var/log/mysqld.log
|
||||||
|
# log-warnings = 2
|
||||||
|
#
|
||||||
|
# If using mysql syslog [mysql_safe] has syslog in /etc/my.cnf
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
# Read common prefixes. If any customizations available -- read them from
|
||||||
|
# common.local
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_daemon = mysqld
|
||||||
|
|
||||||
|
failregex = ^%(__prefix_line)s(?:(?:\d{6}|\d{4}-\d{2}-\d{2})[ T]\s?\d{1,2}:\d{2}:\d{2} )?(?:\d+ )?\[\w+\] (?:\[[^\]]+\] )*Access denied for user '<F-USER>[^']+</F-USER>'@'<HOST>' (to database '[^']*'|\(using password: (YES|NO)\))*\s*$
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Technically __prefix_line can equate to an empty string hence it can support
|
||||||
|
# syslog and non-syslog at once.
|
||||||
|
# Example:
|
||||||
|
# 130322 11:26:54 [Warning] Access denied for user 'root'@'127.0.0.1' (using password: YES)
|
||||||
|
#
|
||||||
|
# Authors: Artur Penttinen
|
||||||
|
# Yaroslav O. Halchenko
|
||||||
17
fail2ban/filter.d/nagios.conf
Normal file
17
fail2ban/filter.d/nagios.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Fail2Ban filter for Nagios Remote Plugin Executor (nrpe2)
|
||||||
|
# Detecting unauthorized access to the nrpe2 daemon
|
||||||
|
# typically logged in /var/log/messages syslog
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
# Read syslog common prefixes
|
||||||
|
before = common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
_daemon = nrpe
|
||||||
|
failregex = ^%(__prefix_line)sHost <HOST> is not allowed to talk to us!\s*$
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
#
|
||||||
|
# Author: Ivo Truxa - 2014/02/03
|
||||||
50
fail2ban/filter.d/named-refused.conf
Normal file
50
fail2ban/filter.d/named-refused.conf
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Fail2Ban filter file for named (bind9).
|
||||||
|
#
|
||||||
|
|
||||||
|
# This filter blocks attacks against named (bind9) however it requires special
|
||||||
|
# configuration on bind.
|
||||||
|
#
|
||||||
|
# By default, logging is off with bind9 installation.
|
||||||
|
#
|
||||||
|
# You will need something like this in your named.conf to provide proper logging.
|
||||||
|
#
|
||||||
|
# logging {
|
||||||
|
# channel security_file {
|
||||||
|
# file "/var/log/named/security.log" versions 3 size 30m;
|
||||||
|
# severity dynamic;
|
||||||
|
# print-time yes;
|
||||||
|
# };
|
||||||
|
# category security {
|
||||||
|
# security_file;
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Daemon name
|
||||||
|
_daemon=named
|
||||||
|
|
||||||
|
# Shortcuts for easier comprehension of the failregex
|
||||||
|
|
||||||
|
__pid_re=(?:\[\d+\])
|
||||||
|
__daemon_re=\(?%(_daemon)s(?:\(\S+\))?\)?:?
|
||||||
|
__daemon_combs_re=(?:%(__pid_re)s?:\s+%(__daemon_re)s|%(__daemon_re)s%(__pid_re)s?:)
|
||||||
|
|
||||||
|
# hostname daemon_id spaces
|
||||||
|
# this can be optional (for instance if we match named native log files)
|
||||||
|
__line_prefix=(?:\s\S+ %(__daemon_combs_re)s\s+)?
|
||||||
|
|
||||||
|
prefregex = ^%(__line_prefix)s(?: error:)?\s*client(?: @\S*)? <HOST>#\S+(?: \([\S.]+\))?: <F-CONTENT>.+</F-CONTENT>\s(?:denied|\(NOTAUTH\))\s*$
|
||||||
|
|
||||||
|
failregex = ^(?:view (?:internal|external): )?query(?: \(cache\))?
|
||||||
|
^zone transfer
|
||||||
|
^bad zone transfer request: '\S+/IN': non-authoritative zone
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
|
|
||||||
|
# DEV Notes:
|
||||||
|
# Trying to generalize the
|
||||||
|
# structure which is general to capture general patterns in log
|
||||||
|
# lines to cover different configurations/distributions
|
||||||
|
#
|
||||||
|
# Author: Yaroslav Halchenko
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user