mirror of
https://git.anonymousland.org/anonymousland/infrastructure.git
synced 2024-10-01 08:25:45 -04:00
Add njalla nginx files and organize into folders (#5)
Co-authored-by: NebulaOnion <nebulaonion@tutanota.com> Reviewed-on: https://git.anonymousland.org/anonymousland/infrastructure/pulls/5
This commit is contained in:
parent
c8d934eba8
commit
8d6fb20c2c
1
njallavps/swag/.donoteditthisfile.conf
Normal file
1
njallavps/swag/.donoteditthisfile.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
ORIGURL="anonymousland.org" ORIGSUBDOMAINS="element, forum, status, hydrogen, cinny, git, drone, site, schild, ots, www, paste, mastodon, lemmy" ORIGONLY_SUBDOMAINS="false" ORIGEXTRA_DOMAINS="" ORIGVALIDATION="http" ORIGDNSPLUGIN="" ORIGPROPAGATION="" ORIGSTAGING="" ORIGCERTPROVIDER="" ORIGEMAIL="admin@anonymousland.org"
|
1
njallavps/swag/.migrations
Normal file
1
njallavps/swag/.migrations
Normal file
@ -0,0 +1 @@
|
|||||||
|
01-nginx-site-confs-default
|
9
njallavps/swag/crontabs/root
Normal file
9
njallavps/swag/crontabs/root
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# do daily/weekly/monthly maintenance
|
||||||
|
# min hour day month weekday command
|
||||||
|
*/15 * * * * run-parts /etc/periodic/15min
|
||||||
|
0 * * * * run-parts /etc/periodic/hourly
|
||||||
|
0 2 * * * run-parts /etc/periodic/daily
|
||||||
|
0 3 * * 6 run-parts /etc/periodic/weekly
|
||||||
|
0 5 1 * * run-parts /etc/periodic/monthly
|
||||||
|
# renew letsencrypt certs
|
||||||
|
8 2 * * * /app/le-renew.sh >> /config/log/letsencrypt/letsencrypt.log 2>&1
|
9
njallavps/swag/dns-conf/acmedns-registration.json
Normal file
9
njallavps/swag/dns-conf/acmedns-registration.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"yourdomain.com": {
|
||||||
|
"username":"yourusername",
|
||||||
|
"password":"yourpassword",
|
||||||
|
"fulldomain":"<guid>.acme.yourdomain.com",
|
||||||
|
"subdomain":"<guid>",
|
||||||
|
"allowfrom":[]
|
||||||
|
}
|
||||||
|
}
|
5
njallavps/swag/dns-conf/acmedns.ini
Normal file
5
njallavps/swag/dns-conf/acmedns.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# See https://pypi.org/project/certbot-dns-acmedns/
|
||||||
|
# https://github.com/joohoi/acme-dns
|
||||||
|
#
|
||||||
|
dns_acmedns_api_url = http://your-acme-dns-server.example.com/
|
||||||
|
dns_acmedns_registration_file = /config/dns-conf/acmedns-registration.json
|
6
njallavps/swag/dns-conf/aliyun.ini
Normal file
6
njallavps/swag/dns-conf/aliyun.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Obtain Aliyun RAM AccessKey
|
||||||
|
# https://ram.console.aliyun.com/
|
||||||
|
# And ensure your RAM account has AliyunDNSFullAccess permission.
|
||||||
|
|
||||||
|
dns_aliyun_access_key = 12345678
|
||||||
|
dns_aliyun_access_key_secret = 1234567890abcdef1234567890abcdef
|
26
njallavps/swag/dns-conf/azure.ini
Normal file
26
njallavps/swag/dns-conf/azure.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Instructions: https://certbot-dns-azure.readthedocs.io/en/latest/
|
||||||
|
# Replace with your values
|
||||||
|
# dns_azure_environment can be one of the following: AzurePublicCloud, AzureUSGovernmentCloud, AzureChinaCloud, AzureGermanCloud
|
||||||
|
# Service Principal with Client Secret
|
||||||
|
dns_azure_sp_client_id = 912ce44a-0156-4669-ae22-c16a17d34ca5
|
||||||
|
dns_azure_sp_client_secret = E-xqXU83Y-jzTI6xe9fs2YC~mck3ZzUih9
|
||||||
|
dns_azure_tenant_id = ed1090f3-ab18-4b12-816c-599af8a88cf7
|
||||||
|
dns_azure_environment = "AzurePublicCloud"
|
||||||
|
dns_azure_zone1 = example.com:/subscriptions/c135abce-d87d-48df-936c-15596c6968a5/resourceGroups/dns1
|
||||||
|
|
||||||
|
|
||||||
|
# Service Prinicipal with Certificate
|
||||||
|
#dns_azure_sp_client_id = 912ce44a-0156-4669-ae22-c16a17d34ca5
|
||||||
|
#dns_azure_sp_certificate_path = /path/to/certificate.pem
|
||||||
|
#dns_azure_tenant_id = ed1090f3-ab18-4b12-816c-599af8a88cf7
|
||||||
|
#dns_azure_environment = "AzurePublicCloud"
|
||||||
|
#dns_azure_zone1 = example.com:/subscriptions/c135abce-d87d-48df-936c-15596c6968a5/resourceGroups/dns1
|
||||||
|
|
||||||
|
# Azure Managed Identity
|
||||||
|
#dns_azure_msi_client_id = 912ce44a-0156-4669-ae22-c16a17d34ca5
|
||||||
|
#dns_azure_zone1 = example.com:/subscriptions/c135abce-d87d-48df-936c-15596c6968a5/resourceGroups/dns1
|
||||||
|
|
||||||
|
# System Assigned Azure Managed Identity
|
||||||
|
#dns_azure_msi_system_assigned = true
|
||||||
|
#dns_azure_environment = "AzurePublicCloud"
|
||||||
|
#dns_azure_zone1 = example.com:/subscriptions/c135abce-d87d-48df-936c-15596c6968a5/resourceGroups/dns1
|
9
njallavps/swag/dns-conf/cloudflare.ini
Normal file
9
njallavps/swag/dns-conf/cloudflare.ini
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-cloudflare/certbot_dns_cloudflare/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
|
||||||
|
# With global api key:
|
||||||
|
dns_cloudflare_email = cloudflare@example.com
|
||||||
|
dns_cloudflare_api_key = 0123456789abcdef0123456789abcdef01234567
|
||||||
|
|
||||||
|
# With token (comment out both lines above and uncomment below):
|
||||||
|
#dns_cloudflare_api_token = 0123456789abcdef0123456789abcdef01234567
|
4
njallavps/swag/dns-conf/cloudxns.ini
Normal file
4
njallavps/swag/dns-conf/cloudxns.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-cloudxns/certbot_dns_cloudxns/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
dns_cloudxns_api_key = 1234567890abcdef1234567890abcdef
|
||||||
|
dns_cloudxns_secret_key = 1122334455667788
|
6
njallavps/swag/dns-conf/cpanel.ini
Normal file
6
njallavps/swag/dns-conf/cpanel.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Instructions: https://github.com/badjware/certbot-dns-cpanel#credentials
|
||||||
|
# Replace with your values
|
||||||
|
# include the scheme and the port number (usually 2083 for https)
|
||||||
|
cpanel_url = https://cpanel.example.com:2083
|
||||||
|
cpanel_username = username
|
||||||
|
cpanel_password = 1234567890abcdef
|
4
njallavps/swag/dns-conf/desec.ini
Normal file
4
njallavps/swag/dns-conf/desec.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://pypi.org/project/certbot-dns-desec/
|
||||||
|
# Replace with your Desec V1 API Token
|
||||||
|
dns_desec_token=YOUR_TOKEN_HERE
|
||||||
|
dns_desec_endpoint=https://desec.io/api/v1/
|
3
njallavps/swag/dns-conf/digitalocean.ini
Normal file
3
njallavps/swag/dns-conf/digitalocean.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-digitalocean/certbot_dns_digitalocean/__init__.py#L21
|
||||||
|
# Replace with your value
|
||||||
|
dns_digitalocean_token = 0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff
|
21
njallavps/swag/dns-conf/directadmin.ini
Normal file
21
njallavps/swag/dns-conf/directadmin.ini
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Instructions: https://github.com/cybercinch/certbot-dns-directadmin/blob/master/certbot_dns_directadmin/__init__.py
|
||||||
|
|
||||||
|
# It is recommended to create a login key in the DirectAdmin control panel to be used as value for directadmin_password.
|
||||||
|
# Instructions on how to create such key can be found at https://help.directadmin.com/item.php?id=523.
|
||||||
|
#
|
||||||
|
# Make sure to grant the following permissions:
|
||||||
|
# - CMD_API_LOGIN_TEST
|
||||||
|
# - CMD_API_DNS_CONTROL
|
||||||
|
# - CMD_API_SHOW_DOMAINS
|
||||||
|
#
|
||||||
|
# Username and password can also be used in case your DirectAdmin instance has no support for login keys.
|
||||||
|
|
||||||
|
# The DirectAdmin Server url
|
||||||
|
# include the scheme and the port number (Normally 2222)
|
||||||
|
dns_directadmin_url = https://my.directadminserver.com:2222
|
||||||
|
|
||||||
|
# The DirectAdmin username
|
||||||
|
dns_directadmin_username = username
|
||||||
|
|
||||||
|
# The DirectAdmin password
|
||||||
|
dns_directadmin_password = aSuperStrongPassword
|
3
njallavps/swag/dns-conf/dnsimple.ini
Normal file
3
njallavps/swag/dns-conf/dnsimple.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-dnsimple/certbot_dns_dnsimple/__init__.py#L20
|
||||||
|
# Replace with your value
|
||||||
|
dns_dnsimple_token = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
4
njallavps/swag/dns-conf/dnsmadeeasy.ini
Normal file
4
njallavps/swag/dns-conf/dnsmadeeasy.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-dnsmadeeasy/certbot_dns_dnsmadeeasy/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
dns_dnsmadeeasy_api_key = 1c1a3c91-4770-4ce7-96f4-54c0eb0e457a
|
||||||
|
dns_dnsmadeeasy_secret_key = c9b5625f-9834-4ff8-baba-4ed5f32cae55
|
5
njallavps/swag/dns-conf/dnspod.ini
Normal file
5
njallavps/swag/dns-conf/dnspod.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Instructions: https://github.com/SkyLothar/certbot-dns-dnspod#create-a-credentials-file
|
||||||
|
# Obtain your own DNSPod API token at DNSPod console: https://console.dnspod.cn/account/token/token
|
||||||
|
# Replace with your own email, id and token
|
||||||
|
dns_dnspod_email = "me@example.com"
|
||||||
|
dns_dnspod_api_token = "12345,1234567890abcdef1234567890abcdef"
|
3
njallavps/swag/dns-conf/do.ini
Normal file
3
njallavps/swag/dns-conf/do.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/georgeto/certbot-dns-do/blob/master/certbot_dns_do/__init__.py#L32
|
||||||
|
# Replace with your values
|
||||||
|
dns_do_api_token = YOUR_DO_LETSENCRYPT_API_KEY
|
4
njallavps/swag/dns-conf/domeneshop.ini
Normal file
4
njallavps/swag/dns-conf/domeneshop.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/domeneshop/certbot-dns-domeneshop#credentials
|
||||||
|
# Replace with your values
|
||||||
|
dns_domeneshop_client_token=1234567890abcdef
|
||||||
|
dns_domeneshop_client_secret=1234567890abcdefghijklmnopqrstuvxyz1234567890abcdefghijklmnopqrs
|
3
njallavps/swag/dns-conf/duckdns.ini
Normal file
3
njallavps/swag/dns-conf/duckdns.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/infinityofspace/certbot_dns_duckdns#credentials-file-or-cli-parameters
|
||||||
|
# Replace with your API token from your duckdns account.
|
||||||
|
dns_duckdns_token=<your-duckdns-token>
|
3
njallavps/swag/dns-conf/dynu.ini
Normal file
3
njallavps/swag/dns-conf/dynu.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/bikram990/certbot-dns-dynu#configuration
|
||||||
|
# Replace with your API token from your dynu account.
|
||||||
|
dns_dynu_auth_token = AbCbASsd!@34
|
3
njallavps/swag/dns-conf/gandi.ini
Normal file
3
njallavps/swag/dns-conf/gandi.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/obynio/certbot-plugin-gandi#usage
|
||||||
|
# Replace with your value
|
||||||
|
dns_gandi_api_key=APIKEY
|
4
njallavps/swag/dns-conf/gehirn.ini
Normal file
4
njallavps/swag/dns-conf/gehirn.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://certbot-dns-gehirn.readthedocs.io/en/stable/
|
||||||
|
# Replace with your values
|
||||||
|
dns_gehirn_api_token = 00000000-0000-0000-0000-000000000000
|
||||||
|
dns_gehirn_api_secret = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
4
njallavps/swag/dns-conf/godaddy.ini
Normal file
4
njallavps/swag/dns-conf/godaddy.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/miigotu/certbot-dns-godaddy
|
||||||
|
# Replace with your values
|
||||||
|
dns_godaddy_secret = 0123456789abcdef0123456789abcdef01234567
|
||||||
|
dns_godaddy_key = abcdef0123456789abcdef01234567abcdef0123
|
6
njallavps/swag/dns-conf/google.json
Normal file
6
njallavps/swag/dns-conf/google.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"instructions": "https://github.com/certbot/certbot/blob/master/certbot-dns-google/certbot_dns_google/__init__.py",
|
||||||
|
"_comment": "Replace with your values",
|
||||||
|
"type": "service_account",
|
||||||
|
"rest": "..."
|
||||||
|
}
|
4
njallavps/swag/dns-conf/he.ini
Normal file
4
njallavps/swag/dns-conf/he.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/TSaaristo/certbot-dns-he#example-usage
|
||||||
|
# Replace with your values
|
||||||
|
dns_he_user = Me
|
||||||
|
dns_he_pass = my HE password
|
3
njallavps/swag/dns-conf/hetzner.ini
Normal file
3
njallavps/swag/dns-conf/hetzner.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/ctrlaltcoop/certbot-dns-hetzner
|
||||||
|
# Replace with your values
|
||||||
|
dns_hetzner_api_token = nohnah4zoo9Kiejee9aGh0thoopee2sa
|
3
njallavps/swag/dns-conf/infomaniak.ini
Normal file
3
njallavps/swag/dns-conf/infomaniak.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Instructions: https://github.com/Infomaniak/certbot-dns-infomaniak#via-ini-file
|
||||||
|
# Replace with your values
|
||||||
|
dns_infomaniak_token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
6
njallavps/swag/dns-conf/inwx.ini
Normal file
6
njallavps/swag/dns-conf/inwx.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Instructions: https://github.com/oGGy990/certbot-dns-inwx
|
||||||
|
# Replace with your values
|
||||||
|
dns_inwx_url = https://api.domrobot.com/xmlrpc/
|
||||||
|
dns_inwx_username = your_username
|
||||||
|
dns_inwx_password = your_password
|
||||||
|
dns_inwx_shared_secret = your_shared_secret optional
|
5
njallavps/swag/dns-conf/ionos.ini
Normal file
5
njallavps/swag/dns-conf/ionos.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Instructions: https://github.com/helgeerbe/certbot-dns-ionos
|
||||||
|
# Replace with your values
|
||||||
|
dns_ionos_prefix = myapikeyprefix
|
||||||
|
dns_ionos_secret = verysecureapikeysecret
|
||||||
|
dns_ionos_endpoint = https://api.hosting.ionos.com
|
3
njallavps/swag/dns-conf/linode.ini
Normal file
3
njallavps/swag/dns-conf/linode.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-linode/certbot_dns_linode/__init__.py#L25
|
||||||
|
# Replace with your values
|
||||||
|
dns_linode_key = 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ64
|
3
njallavps/swag/dns-conf/loopia.ini
Normal file
3
njallavps/swag/dns-conf/loopia.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Replace with your values
|
||||||
|
dns_loopia_user = user@loopiaapi
|
||||||
|
dns_loopia_password = passwordgoeshere
|
4
njallavps/swag/dns-conf/luadns.ini
Normal file
4
njallavps/swag/dns-conf/luadns.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-luadns/certbot_dns_luadns/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
dns_luadns_email = user@example.com
|
||||||
|
dns_luadns_token = 0123456789abcdef0123456789abcdef
|
3
njallavps/swag/dns-conf/netcup.ini
Normal file
3
njallavps/swag/dns-conf/netcup.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dns_netcup_customer_id = 123456
|
||||||
|
dns_netcup_api_key = 0123456789abcdef0123456789abcdef01234567
|
||||||
|
dns_netcup_api_password = abcdef0123456789abcdef01234567abcdef0123
|
2
njallavps/swag/dns-conf/njalla.ini
Normal file
2
njallavps/swag/dns-conf/njalla.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Generate your API token here: https://njal.la/settings/api/
|
||||||
|
dns_njalla_token=0000000000000000000000000000000000000000
|
3
njallavps/swag/dns-conf/nsone.ini
Normal file
3
njallavps/swag/dns-conf/nsone.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-nsone/certbot_dns_nsone/__init__.py#L20
|
||||||
|
# Replace with your value
|
||||||
|
dns_nsone_api_key = MDAwMDAwMDAwMDAwMDAw
|
6
njallavps/swag/dns-conf/ovh.ini
Normal file
6
njallavps/swag/dns-conf/ovh.ini
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-ovh/certbot_dns_ovh/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
dns_ovh_endpoint = ovh-eu
|
||||||
|
dns_ovh_application_key = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
||||||
|
dns_ovh_application_secret = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
||||||
|
dns_ovh_consumer_key = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
4
njallavps/swag/dns-conf/porkbun.ini
Normal file
4
njallavps/swag/dns-conf/porkbun.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://github.com/infinityofspace/certbot_dns_porkbun
|
||||||
|
# Replace with your values
|
||||||
|
dns_porkbun_key=<your-porkbun-api-key>
|
||||||
|
dns_porkbun_secret=<your-porkbun-api-secret>
|
11
njallavps/swag/dns-conf/rfc2136.ini
Normal file
11
njallavps/swag/dns-conf/rfc2136.ini
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-rfc2136/certbot_dns_rfc2136/__init__.py#L20
|
||||||
|
# Replace with your values
|
||||||
|
# Target DNS server
|
||||||
|
dns_rfc2136_server = 192.0.2.1
|
||||||
|
# TSIG key name
|
||||||
|
dns_rfc2136_name = keyname.
|
||||||
|
# TSIG key secret
|
||||||
|
dns_rfc2136_secret = 4q4wM/2I180UXoMyN4INVhJNi8V9BCV+jMw2mXgZw/CSuxUT8C7NKKFs \
|
||||||
|
AmKd7ak51vWKgSl12ib86oQRPkpDjg==
|
||||||
|
# TSIG key algorithm
|
||||||
|
dns_rfc2136_algorithm = HMAC-SHA512
|
5
njallavps/swag/dns-conf/route53.ini
Normal file
5
njallavps/swag/dns-conf/route53.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Instructions: https://github.com/certbot/certbot/blob/master/certbot-dns-route53/certbot_dns_route53/__init__.py#L18
|
||||||
|
# Replace with your values
|
||||||
|
[default]
|
||||||
|
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
|
||||||
|
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
4
njallavps/swag/dns-conf/sakuracloud.ini
Normal file
4
njallavps/swag/dns-conf/sakuracloud.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Instructions: https://certbot-dns-sakuracloud.readthedocs.io/en/stable/
|
||||||
|
# Replace with your values
|
||||||
|
dns_sakuracloud_api_token = 00000000-0000-0000-0000-000000000000
|
||||||
|
dns_sakuracloud_api_secret = MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw
|
8
njallavps/swag/dns-conf/standalone.ini
Normal file
8
njallavps/swag/dns-conf/standalone.ini
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Instructions: https://github.com/siilike/certbot-dns-standalone/blob/master/README.rst
|
||||||
|
# Make sure to expose UDP port 53 from your swag container:
|
||||||
|
# - for docker cli, add argument: `-p 53:53/udp`
|
||||||
|
# - for docker-compose, add the following line under ports: `- 53:53/udp`
|
||||||
|
# This file does not need to be changed:
|
||||||
|
# - no credentials are required
|
||||||
|
# - it's not used and only for informational purpose
|
||||||
|
# - prepare the correct DNS records as described in the plugin instructions instead
|
30
njallavps/swag/dns-conf/transip.ini
Normal file
30
njallavps/swag/dns-conf/transip.ini
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Instructions: https://readthedocs.org/projects/certbot-dns-transip/
|
||||||
|
#
|
||||||
|
# This DNS plugin can be used to generate SSL wildcard certificates via TransIP DNS TXT records
|
||||||
|
#
|
||||||
|
# Login with your TransIP account and go to My Account | API:
|
||||||
|
# 1. API-settings: On
|
||||||
|
#
|
||||||
|
# 2. IP-address/ranges whitelist: Add a new authorized IP address (Swag Docker) to use the API
|
||||||
|
#
|
||||||
|
# 3. Generate a new Key Pair and copy the private key to a new transip.key file in the format:
|
||||||
|
# -----BEGIN PRIVATE KEY-----
|
||||||
|
# ...
|
||||||
|
# -----END PRIVATE KEY-----
|
||||||
|
#
|
||||||
|
# 4. Convert the key to an RSA key with command:
|
||||||
|
# openssl rsa -in transip.key -out /config/dns-conf/transip-rsa.key
|
||||||
|
#
|
||||||
|
# 5. Set permission
|
||||||
|
# chmod 600 /config/dns-conf/transip-rsa.key
|
||||||
|
#
|
||||||
|
# 6. Replace <transip_username> below with your TransIP username
|
||||||
|
#
|
||||||
|
# 7. Create wildcard certificate with Swag environment variables:
|
||||||
|
# SUBDOMAINS=wildcard
|
||||||
|
# VALIDATION=dns
|
||||||
|
# DNSPLUGIN=transip
|
||||||
|
|
||||||
|
dns_transip_username = <transip_username>
|
||||||
|
dns_transip_key_file = /config/dns-conf/transip-rsa.key
|
||||||
|
|
3
njallavps/swag/dns-conf/vultr.ini
Normal file
3
njallavps/swag/dns-conf/vultr.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Instructions: https://github.com/lezgomatt/certbot-dns-vultr
|
||||||
|
# Replace with your vultr Personal Access Token (see https://www.vultr.com/docs/how-to-setup-dynamic-dns).
|
||||||
|
dns_vultr_key = YOUR_VULTR_API_KEY
|
1
njallavps/swag/etc/letsencrypt/note.txt
Normal file
1
njallavps/swag/etc/letsencrypt/note.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
This folder contained letsencrypt files which are important data that can't be uploaded
|
104
njallavps/swag/fail2ban/action.d/abuseipdb.conf
Normal file
104
njallavps/swag/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
njallavps/swag/fail2ban/action.d/apf.conf
Normal file
25
njallavps/swag/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
|
49
njallavps/swag/fail2ban/action.d/apprise.conf
Normal file
49
njallavps/swag/fail2ban/action.d/apprise.conf
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Chris Caron <lead2gold@gmail.com>
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: actionstart
|
||||||
|
# Notes.: command executed once at the start of Fail2Ban.
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstart = printf %%b "The jail <name> as been started successfully." | <apprise> -t "[Fail2Ban] <name>: started on `uname -n`"
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed once at the end of Fail2Ban
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = printf %%b "The jail <name> has been stopped." | <apprise> -t "[Fail2Ban] <name>: stopped on `uname -n`"
|
||||||
|
|
||||||
|
# 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 "The IP <ip> has just been banned by Fail2Ban after <failures> attempts against <name>" | <apprise> -n "warning" -t "[Fail2Ban] <name>: banned <ip> from `uname -n`"
|
||||||
|
|
||||||
|
# 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]
|
||||||
|
|
||||||
|
# Define location of the default apprise configuration file to use
|
||||||
|
#
|
||||||
|
config = /etc/fail2ban/apprise.conf
|
||||||
|
#
|
||||||
|
apprise = apprise -c "<config>"
|
19
njallavps/swag/fail2ban/action.d/badips.conf
Normal file
19
njallavps/swag/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 =
|
391
njallavps/swag/fail2ban/action.d/badips.py
Normal file
391
njallavps/swag/fail2ban/action.d/badips.py
Normal file
@ -0,0 +1,391 @@
|
|||||||
|
# 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 urllib2 import Request, urlopen, HTTPError
|
||||||
|
from urllib 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
njallavps/swag/fail2ban/action.d/blocklist_de.conf
Normal file
84
njallavps/swag/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 =
|
94
njallavps/swag/fail2ban/action.d/bsd-ipfw.conf
Normal file
94
njallavps/swag/fail2ban/action.d/bsd-ipfw.conf
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Nick Munger
|
||||||
|
# Modified by: Ken Menzel
|
||||||
|
# Daniel Black (start/stop)
|
||||||
|
# Fabian Wenk (many ideas as per fail2ban users list)
|
||||||
|
#
|
||||||
|
# Ensure firewall_enable="YES" in the top of /etc/rc.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 = ipfw show | fgrep -c -m 1 -s 'table(<table>)' > /dev/null 2>&1 || (
|
||||||
|
num=$(ipfw show | awk 'BEGIN { b = <lowest_rule_num> } { if ($1 == b) { b = $1 + 1 } } END { print b }');
|
||||||
|
ipfw -q add "$num" <blocktype> <block> from table\(<table>\) to me <port>; echo "$num" > "<startstatefile>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = [ ! -f <startstatefile> ] || ( read num < "<startstatefile>" <br> ipfw -q delete $num <br> rm "<startstatefile>" )
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# requires an ipfw rule like "deny ip from table(1) to me"
|
||||||
|
actionban = e=`ipfw table <table> add <ip> 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XADD): File exists' ] || echo "$e" | grep -q "record already exists" || { echo "$e" 1>&2; exit $x; }
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionunban
|
||||||
|
# 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 = e=`ipfw table <table> delete <ip> 2>&1`; x=$?; [ $x -eq 0 -o "$e" = 'ipfw: setsockopt(IP_FW_TABLE_XDEL): No such process' ] || echo "$e" | grep -q "record not found" || { echo "$e" 1>&2; exit $x; }
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
# Option: table
|
||||||
|
# Notes: The ipfw table to use. If a ipfw rule using this table already exists,
|
||||||
|
# this action will not create a ipfw rule to block it and the following
|
||||||
|
# options will have no effect.
|
||||||
|
# Values: NUM
|
||||||
|
table = 1
|
||||||
|
|
||||||
|
# Option: port
|
||||||
|
# Notes.: Specifies port to monitor. Blank indicate block all ports.
|
||||||
|
# Values: [ NUM | STRING ]
|
||||||
|
#
|
||||||
|
port =
|
||||||
|
|
||||||
|
# Option: startstatefile
|
||||||
|
# Notes: A file to indicate that the table rule that was added. Ensure it is unique per table.
|
||||||
|
# Values: STRING
|
||||||
|
startstatefile = /var/run/fail2ban/ipfw-started-table_<table>
|
||||||
|
|
||||||
|
# Option: block
|
||||||
|
# Notes: This is how much to block.
|
||||||
|
# Can be "ip", "tcp", "udp" or various other options.
|
||||||
|
# Values: STRING
|
||||||
|
block = ip
|
||||||
|
|
||||||
|
# Option: blocktype
|
||||||
|
# Notes.: How to block the traffic. Use a action from man 5 ipfw
|
||||||
|
# Common values: deny, unreach port, reset
|
||||||
|
# ACTION defination at the top of man ipfw for allowed values.
|
||||||
|
# Values: STRING
|
||||||
|
#
|
||||||
|
blocktype = unreach port
|
||||||
|
|
||||||
|
# Option: lowest_rule_num
|
||||||
|
# Notes: When fail2ban starts with action and there is no rule for the given table yet
|
||||||
|
# then fail2ban will start looking for an empty slot starting with this rule number.
|
||||||
|
# Values: NUM
|
||||||
|
lowest_rule_num = 111
|
||||||
|
|
||||||
|
|
92
njallavps/swag/fail2ban/action.d/cloudflare-token.conf
Normal file
92
njallavps/swag/fail2ban/action.d/cloudflare-token.conf
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#
|
||||||
|
# Author: Logic-32
|
||||||
|
#
|
||||||
|
# IMPORTANT
|
||||||
|
#
|
||||||
|
# Please set jail.local's permission to 640 because it contains your CF API token.
|
||||||
|
#
|
||||||
|
# This action depends on curl.
|
||||||
|
#
|
||||||
|
# To get your Cloudflare API token: https://developers.cloudflare.com/api/tokens/create/
|
||||||
|
#
|
||||||
|
# Cloudflare Firewall API: https://developers.cloudflare.com/firewall/api/cf-firewall-rules/endpoints/
|
||||||
|
|
||||||
|
[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
|
||||||
|
actionban = curl -s -X POST "<_cf_api_url>" \
|
||||||
|
<_cf_api_prms> \
|
||||||
|
--data '{"mode":"<cfmode>","configuration":{"target":"<cftarget>","value":"<ip>"},"notes":"<notes>"}'
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
actionunban = id=$(curl -s -X GET "<_cf_api_url>?mode=<cfmode>¬es=<notes>&configuration.target=<cftarget>&configuration.value=<ip>" \
|
||||||
|
<_cf_api_prms> \
|
||||||
|
| awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'id'\042/){print $(i+1)}}}' \
|
||||||
|
| tr -d ' "' \
|
||||||
|
| head -n 1)
|
||||||
|
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found using target <cftarget>"; exit 0; fi; \
|
||||||
|
curl -s -X DELETE "<_cf_api_url>/$id" \
|
||||||
|
<_cf_api_prms> \
|
||||||
|
--data '{"cascade": "none"}'
|
||||||
|
|
||||||
|
_cf_api_url = https://api.cloudflare.com/client/v4/zones/<cfzone>/firewall/access_rules/rules
|
||||||
|
_cf_api_prms = -H "Authorization: Bearer <cftoken>" -H "Content-Type: application/json"
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Declare your Cloudflare Authorization Bearer Token in the [DEFAULT] section of your jail.local file.
|
||||||
|
|
||||||
|
# The Cloudflare <ZONE_ID> of hte domain you want to manage.
|
||||||
|
#
|
||||||
|
# cfzone =
|
||||||
|
|
||||||
|
# Your personal Cloudflare token. Ideally restricted to just have "Zone.Firewall Services" permissions.
|
||||||
|
#
|
||||||
|
# cftoken =
|
||||||
|
|
||||||
|
# Target of the firewall rule. Default is "ip" (v4).
|
||||||
|
#
|
||||||
|
cftarget = ip
|
||||||
|
|
||||||
|
# The firewall mode Cloudflare should use. Default is "block" (deny access).
|
||||||
|
# Consider also "js_challenge" or other "allowed_modes" if you want.
|
||||||
|
#
|
||||||
|
cfmode = block
|
||||||
|
|
||||||
|
# The message to include in the firewall IP banning rule.
|
||||||
|
#
|
||||||
|
notes = Fail2Ban <name>
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
cftarget = ip6
|
88
njallavps/swag/fail2ban/action.d/cloudflare.conf
Normal file
88
njallavps/swag/fail2ban/action.d/cloudflare.conf
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#
|
||||||
|
# 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":"<cftarget>","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=<cftarget>&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 =
|
||||||
|
|
||||||
|
cftarget = ip
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
cftarget = ip6
|
121
njallavps/swag/fail2ban/action.d/complain.conf
Normal file
121
njallavps/swag/fail2ban/action.d/complain.conf
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Russell Odom <russ@gloomytrousers.co.uk>, Daniel Black
|
||||||
|
# Sends a complaint e-mail to addresses listed in the whois record for an
|
||||||
|
# offending IP address.
|
||||||
|
# This uses the https://abusix.com/contactdb.html to lookup abuse contacts.
|
||||||
|
#
|
||||||
|
# DEPENDENCIES:
|
||||||
|
# This requires the dig command from bind-utils
|
||||||
|
#
|
||||||
|
# You should provide the <logpath> in the jail config - lines from the log
|
||||||
|
# matching the given IP address will be provided in the complaint as evidence.
|
||||||
|
#
|
||||||
|
# WARNING
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# Please do not use this action unless you are certain that fail2ban
|
||||||
|
# does not result in "false positives" for your deployment. False
|
||||||
|
# positive reports could serve a mis-favor to the original cause by
|
||||||
|
# flooding corresponding contact addresses, and complicating the work
|
||||||
|
# of administration personnel responsible for handling (verified) legit
|
||||||
|
# complains.
|
||||||
|
#
|
||||||
|
# Please consider using e.g. sendmail-whois-lines.conf action which
|
||||||
|
# would send the reports with relevant information to you, so the
|
||||||
|
# report could be first reviewed and then forwarded to a corresponding
|
||||||
|
# contact if legit.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = helpers-common.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Used in test cases for coverage internal transformations
|
||||||
|
debug = 0
|
||||||
|
|
||||||
|
# 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 =
|
||||||
|
|
||||||
|
# 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 = 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>
|
||||||
|
if [ ! -z "$ADDRESSES" ]; then
|
||||||
|
( printf %%b "<message>\n"; date '+Note: Local timezone is %%z (%%Z)';
|
||||||
|
printf %%b "\nLines containing failures of <ip> (max <grepmax>)\n";
|
||||||
|
%(_grep_logs)s;
|
||||||
|
) | <mailcmd> "Abuse from <ip>" <mailargs> $ADDRESSES
|
||||||
|
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 =
|
||||||
|
|
||||||
|
# Server as resolver used in dig command
|
||||||
|
#
|
||||||
|
addr_resolver = <ip-rev>abuse-contacts.abusix.org
|
||||||
|
|
||||||
|
# Default message used for abuse content
|
||||||
|
#
|
||||||
|
message = Dear Sir/Madam,\n\nWe have detected abuse from the IP address $IP, which according to a 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.\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
|
||||||
|
|
||||||
|
# Path to the log files which contain relevant lines for the abuser IP
|
||||||
|
#
|
||||||
|
logpath = /dev/null
|
||||||
|
|
||||||
|
# Option: mailcmd
|
||||||
|
# Notes.: Your system mail command. Is passed 2 args: subject and recipient
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
mailcmd = mail -E 'set escape' -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 '--' indicates
|
||||||
|
# arguments to be passed to Sendmail:
|
||||||
|
# -- -f me@example.com
|
||||||
|
# Values: [ STRING ]
|
||||||
|
#
|
||||||
|
mailargs =
|
||||||
|
|
||||||
|
# Number of log lines to include in the email
|
||||||
|
#
|
||||||
|
#grepmax = 1000
|
||||||
|
#grepopts = -m <grepmax>
|
207
njallavps/swag/fail2ban/action.d/dshield.conf
Normal file
207
njallavps/swag/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 -E 'set escape' -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
njallavps/swag/fail2ban/action.d/dummy.conf
Normal file
63
njallavps/swag/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
njallavps/swag/fail2ban/action.d/firewallcmd-allports.conf
Normal file
45
njallavps/swag/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
njallavps/swag/fail2ban/action.d/firewallcmd-common.conf
Normal file
76
njallavps/swag/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
|
121
njallavps/swag/fail2ban/action.d/firewallcmd-ipset.conf
Normal file
121
njallavps/swag/fail2ban/action.d/firewallcmd-ipset.conf
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
# 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 = <ipstype_<ipsettype>/actionstart>
|
||||||
|
firewall-cmd --direct --add-rule <family> filter <chain> 0 <actiontype> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
|
||||||
|
actionflush = <ipstype_<ipsettype>/actionflush>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 <actiontype> -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
<actionflush>
|
||||||
|
<ipstype_<ipsettype>/actionstop>
|
||||||
|
|
||||||
|
actionban = <ipstype_<ipsettype>/actionban>
|
||||||
|
|
||||||
|
# actionprolong = %(actionban)s
|
||||||
|
|
||||||
|
actionunban = <ipstype_<ipsettype>/actionunban>
|
||||||
|
|
||||||
|
[ipstype_ipset]
|
||||||
|
|
||||||
|
actionstart = ipset -exist create <ipmset> hash:ip timeout <default-ipsettime> <familyopt>
|
||||||
|
|
||||||
|
actionflush = ipset flush <ipmset>
|
||||||
|
|
||||||
|
actionstop = ipset destroy <ipmset>
|
||||||
|
|
||||||
|
actionban = ipset -exist add <ipmset> <ip> timeout <ipsettime>
|
||||||
|
|
||||||
|
actionunban = ipset -exist del <ipmset> <ip>
|
||||||
|
|
||||||
|
[ipstype_firewalld]
|
||||||
|
|
||||||
|
actionstart = firewall-cmd --direct --new-ipset=<ipmset> --type=hash:ip --option=timeout=<default-ipsettime> <firewalld_familyopt>
|
||||||
|
|
||||||
|
# TODO: there doesn't seem to be an explicit way to invoke the ipset flush function using firewall-cmd
|
||||||
|
actionflush =
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --delete-ipset=<ipmset>
|
||||||
|
|
||||||
|
actionban = firewall-cmd --ipset=<ipmset> --add-entry=<ip>
|
||||||
|
|
||||||
|
actionunban = firewall-cmd --ipset=<ipmset> --remove-entry=<ip>
|
||||||
|
|
||||||
|
[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: ipsettype
|
||||||
|
# Notes.: defines type of ipset used for match-set (firewalld or ipset)
|
||||||
|
# Values: firewalld or ipset
|
||||||
|
# Default: ipset
|
||||||
|
ipsettype = ipset
|
||||||
|
|
||||||
|
# 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 <port>
|
||||||
|
|
||||||
|
ipmset = f2b-<name>
|
||||||
|
familyopt =
|
||||||
|
firewalld_familyopt =
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
|
||||||
|
ipmset = f2b-<name>6
|
||||||
|
familyopt = family inet6
|
||||||
|
firewalld_familyopt = --option=family=inet6
|
||||||
|
|
||||||
|
|
||||||
|
# DEV NOTES:
|
||||||
|
#
|
||||||
|
# Author: Edgar Hoch, Daniel Black, Sergey Brester and Mihail Politaev
|
||||||
|
# firewallcmd-new / iptables-ipset-proto6 combined for maximium goodness
|
26
njallavps/swag/fail2ban/action.d/firewallcmd-multiport.conf
Normal file
26
njallavps/swag/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 <port> -j f2b-<name>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -m conntrack --ctstate NEW -p <protocol> -m multiport --dports <port> -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
njallavps/swag/fail2ban/action.d/firewallcmd-new.conf
Normal file
47
njallavps/swag/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 <port> -j f2b-<name>
|
||||||
|
|
||||||
|
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports <port> -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
|
||||||
|
|
@ -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
njallavps/swag/fail2ban/action.d/firewallcmd-rich-rules.conf
Normal file
44
njallavps/swag/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="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="%(fwcmd_rich_rule)s"; done
|
||||||
|
|
||||||
|
actionunban = ports="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="%(fwcmd_rich_rule)s"; done
|
||||||
|
|
||||||
|
rich-suffix = <rich-blocktype>
|
17
njallavps/swag/fail2ban/action.d/helpers-common.conf
Normal file
17
njallavps/swag/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>
|
62
njallavps/swag/fail2ban/action.d/hostsdeny.conf
Normal file
62
njallavps/swag/fail2ban/action.d/hostsdeny.conf
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Edited for cross platform by: James Stout, Yaroslav Halchenko and Daniel Black
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[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 = printf %%b "<daemon_list>: <ip_value>\n" >> <file>
|
||||||
|
|
||||||
|
# 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 = IP=$(echo "<ip_value>" | sed 's/[][\.]/\\\0/g') && sed -i "/^<daemon_list>: $IP$/d" <file>
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: file
|
||||||
|
# Notes.: hosts.deny file path.
|
||||||
|
# Values: STR Default: /etc/hosts.deny
|
||||||
|
#
|
||||||
|
file = /etc/hosts.deny
|
||||||
|
|
||||||
|
# Option: daemon_list
|
||||||
|
# Notes: The list of services that this action will deny. See the man page
|
||||||
|
# for hosts.deny/hosts_access. Default is all services.
|
||||||
|
# Values: STR Default: ALL
|
||||||
|
daemon_list = ALL
|
||||||
|
|
||||||
|
# internal variable IP (to differentiate the IPv4 and IPv6 syntax, where it is enclosed in brackets):
|
||||||
|
ip_value = <ip>
|
||||||
|
|
||||||
|
[Init?family=inet6]
|
||||||
|
ip_value = [<ip>]
|
58
njallavps/swag/fail2ban/action.d/ipfilter.conf
Normal file
58
njallavps/swag/fail2ban/action.d/ipfilter.conf
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# NetBSD ipfilter (ipf command) ban/unban
|
||||||
|
#
|
||||||
|
# Author: Ed Ravin <eravin@panix.com>
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[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
|
||||||
|
#
|
||||||
|
# enable IPF if not already enabled
|
||||||
|
actionstart = /sbin/ipf -E
|
||||||
|
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
# don't disable IPF with "/sbin/ipf -D", there may be other filters in use
|
||||||
|
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 block <blocktype> in quick from <ip>/32 | /sbin/ipf -f -
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# note -r option used to remove matching rule
|
||||||
|
actionunban = echo block <blocktype> in quick from <ip>/32 | /sbin/ipf -r -f -
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: Blocktype
|
||||||
|
# Notes : This is the return-icmp[return-code] mentioned in the ipf man page section 5. Keep this quoted to prevent
|
||||||
|
# Shell expansion. This should be blank (unquoted) to drop the packet.
|
||||||
|
# Values: STRING
|
||||||
|
blocktype = "return-icmp(port-unr)"
|
68
njallavps/swag/fail2ban/action.d/ipfw.conf
Normal file
68
njallavps/swag/fail2ban/action.d/ipfw.conf
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Nick Munger
|
||||||
|
# Modified by: 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 =
|
||||||
|
|
||||||
|
|
||||||
|
# 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 = ipfw add <blocktype> tcp from <ip> to <localhost> <port>
|
||||||
|
|
||||||
|
|
||||||
|
# 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 = ipfw delete `ipfw list | grep -i "[^0-9]<ip>[^0-9]" | awk '{print $1;}'`
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Option: port
|
||||||
|
# Notes.: specifies port to monitor
|
||||||
|
# Values: [ NUM | STRING ]
|
||||||
|
#
|
||||||
|
port = ssh
|
||||||
|
|
||||||
|
# Option: localhost
|
||||||
|
# Notes.: the local IP address of the network interface
|
||||||
|
# Values: IP
|
||||||
|
#
|
||||||
|
localhost = 127.0.0.1
|
||||||
|
|
||||||
|
|
||||||
|
# Option: blocktype
|
||||||
|
# Notes.: How to block the traffic. Use a action from man 5 ipfw
|
||||||
|
# Common values: deny, unreach port, reset
|
||||||
|
# Values: STRING
|
||||||
|
#
|
||||||
|
blocktype = unreach port
|
15
njallavps/swag/fail2ban/action.d/iptables-allports.conf
Normal file
15
njallavps/swag/fail2ban/action.d/iptables-allports.conf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified: Yaroslav O. Halchenko <debian@onerussian.com>
|
||||||
|
# made active on all ports from original iptables.conf
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by iptables[type=allports]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = allports
|
92
njallavps/swag/fail2ban/action.d/iptables-common.conf
Normal file
92
njallavps/swag/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>
|
||||||
|
|
66
njallavps/swag/fail2ban/action.d/iptables-ipset-proto4.conf
Normal file
66
njallavps/swag/fail2ban/action.d/iptables-ipset-proto4.conf
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# 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.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
|
||||||
|
<_ipt_add_rules>
|
||||||
|
|
||||||
|
|
||||||
|
# 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 = <_ipt_del_rules>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
# Several capabilities used internaly:
|
||||||
|
|
||||||
|
rule-jump = -m set --match-set f2b-<name> src -j <blocktype>
|
@ -0,0 +1,27 @@
|
|||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by iptables-ipset[type=allports]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-ipset.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = allports
|
27
njallavps/swag/fail2ban/action.d/iptables-ipset-proto6.conf
Normal file
27
njallavps/swag/fail2ban/action.d/iptables-ipset-proto6.conf
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by iptables-ipset[type=multiport]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables-ipset.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = multiport
|
90
njallavps/swag/fail2ban/action.d/iptables-ipset.conf
Normal file
90
njallavps/swag/fail2ban/action.d/iptables-ipset.conf
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Authors: Sergey G Brester (sebres), Daniel Black, Alexander Koeppe
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables.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 -exist create <ipmset> hash:ip timeout <default-ipsettime> <familyopt>
|
||||||
|
<_ipt_add_rules>
|
||||||
|
|
||||||
|
# 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 = <_ipt_del_rules>
|
||||||
|
<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 -exist add <ipmset> <ip> timeout <ipsettime>
|
||||||
|
|
||||||
|
# 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 -exist del <ipmset> <ip>
|
||||||
|
|
||||||
|
# Several capabilities used internaly:
|
||||||
|
|
||||||
|
rule-jump = -m set --match-set <ipmset> src -j <blocktype>
|
||||||
|
|
||||||
|
|
||||||
|
[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
njallavps/swag/fail2ban/action.d/iptables-multiport-log.conf
Normal file
68
njallavps/swag/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.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]
|
||||||
|
|
14
njallavps/swag/fail2ban/action.d/iptables-multiport.conf
Normal file
14
njallavps/swag/fail2ban/action.d/iptables-multiport.conf
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified by Yaroslav Halchenko for multiport banning
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by iptables[type=multiport]
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
type = multiport
|
15
njallavps/swag/fail2ban/action.d/iptables-new.conf
Normal file
15
njallavps/swag/fail2ban/action.d/iptables-new.conf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Copied from iptables.conf and modified by Yaroslav Halchenko
|
||||||
|
# to fulfill the needs of bugreporter dbts#350746.
|
||||||
|
#
|
||||||
|
# Obsolete: superseded by iptables[pre-rule='-m state --state NEW<sp>']
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = iptables.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
pre-rule = -m state --state NEW<sp>
|
@ -0,0 +1,87 @@
|
|||||||
|
# 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.conf
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
_ipt_chain_rule = -m recent --update --seconds 3600 --name <iptname> -j <blocktype>
|
||||||
|
_ipt_for_proto-iter =
|
||||||
|
_ipt_for_proto-done =
|
||||||
|
|
||||||
|
# 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
|
||||||
|
{ %(_ipt_check_rule)s >/dev/null 2>&1; } || { <iptables> -I <chain> %(_ipt_chain_rule)s; }
|
||||||
|
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> %(_ipt_chain_rule)s;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed as invariant check (error by ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = { <iptables> -C <chain> %(_ipt_chain_rule)s; } && 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
|
162
njallavps/swag/fail2ban/action.d/iptables.conf
Normal file
162
njallavps/swag/fail2ban/action.d/iptables.conf
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Authors: Sergey G. Brester (sebres), Cyril Jaquier, Daniel Black,
|
||||||
|
# Yaroslav O. Halchenko, Alexander Koeppe et al.
|
||||||
|
#
|
||||||
|
|
||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: type
|
||||||
|
# Notes.: type of the action.
|
||||||
|
# Values: [ oneport | multiport | allports ] Default: oneport
|
||||||
|
#
|
||||||
|
type = oneport
|
||||||
|
|
||||||
|
# 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>
|
||||||
|
|
||||||
|
# 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> -C f2b-<name> -j <returntype> >/dev/null 2>&1; } || { <iptables> -N f2b-<name> || true; <iptables> -A f2b-<name> -j <returntype>; }
|
||||||
|
<_ipt_add_rules>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = <_ipt_del_rules>
|
||||||
|
<actionflush>
|
||||||
|
<iptables> -X f2b-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = <_ipt_check_rules>
|
||||||
|
|
||||||
|
# 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>
|
||||||
|
|
||||||
|
# Option: pre-rule
|
||||||
|
# Notes.: prefix parameter(s) inserted to the begin of rule. No default (empty)
|
||||||
|
#
|
||||||
|
pre-rule =
|
||||||
|
|
||||||
|
rule-jump = -j <_ipt_rule_target>
|
||||||
|
|
||||||
|
# Several capabilities used internaly:
|
||||||
|
|
||||||
|
_ipt_for_proto-iter = for proto in $(echo '<protocol>' | sed 's/,/ /g'); do
|
||||||
|
_ipt_for_proto-done = done
|
||||||
|
|
||||||
|
_ipt_add_rules = <_ipt_for_proto-iter>
|
||||||
|
{ %(_ipt_check_rule)s >/dev/null 2>&1; } || { <iptables> -I <chain> %(_ipt_chain_rule)s; }
|
||||||
|
<_ipt_for_proto-done>
|
||||||
|
|
||||||
|
_ipt_del_rules = <_ipt_for_proto-iter>
|
||||||
|
<iptables> -D <chain> %(_ipt_chain_rule)s
|
||||||
|
<_ipt_for_proto-done>
|
||||||
|
|
||||||
|
_ipt_check_rules = <_ipt_for_proto-iter>
|
||||||
|
%(_ipt_check_rule)s
|
||||||
|
<_ipt_for_proto-done>
|
||||||
|
|
||||||
|
_ipt_chain_rule = <pre-rule><ipt_<type>/_chain_rule>
|
||||||
|
_ipt_check_rule = <iptables> -C <chain> %(_ipt_chain_rule)s
|
||||||
|
_ipt_rule_target = f2b-<name>
|
||||||
|
|
||||||
|
[ipt_oneport]
|
||||||
|
|
||||||
|
_chain_rule = -p $proto --dport <port> <rule-jump>
|
||||||
|
|
||||||
|
[ipt_multiport]
|
||||||
|
|
||||||
|
_chain_rule = -p $proto -m multiport --dports <port> <rule-jump>
|
||||||
|
|
||||||
|
[ipt_allports]
|
||||||
|
|
||||||
|
_chain_rule = -p $proto <rule-jump>
|
||||||
|
|
||||||
|
|
||||||
|
[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>
|
107
njallavps/swag/fail2ban/action.d/ipthreat.conf
Normal file
107
njallavps/swag/fail2ban/action.d/ipthreat.conf
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# IPThreat configuration file
|
||||||
|
#
|
||||||
|
# Added to fail2ban by Jeff Johnson (jjxtra)
|
||||||
|
#
|
||||||
|
# Action to report IP address to ipthreat.net
|
||||||
|
#
|
||||||
|
# You must sign up to obtain an API key from ipthreat.net and request bulk report permissions
|
||||||
|
# https://ipthreat.net/integrations
|
||||||
|
#
|
||||||
|
# IPThreat is a 100% free site and service, all data is licensed under a creative commons by attribution license
|
||||||
|
# Please do not integrate if you do not agree to the license
|
||||||
|
#
|
||||||
|
# IMPORTANT:
|
||||||
|
#
|
||||||
|
# Reporting an IP is a serious action. Make sure that it is legit.
|
||||||
|
# Consider using this action only for:
|
||||||
|
# * IP that has been banned more than once
|
||||||
|
# * High max retry to avoid user mis-typing password
|
||||||
|
# * Filters that are unlikely to be human error
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# action = %(known/action)s
|
||||||
|
# ipthreat[]
|
||||||
|
# ```
|
||||||
|
#
|
||||||
|
# The action accepts the following arguments: ipthreat[ipthreat_flags="8",ipthreat_system="SSH", ipthreat_apikey=...]
|
||||||
|
# In most cases your action could be as simple as: ipthreat[], since the default flags and system are set to the most correct default values.
|
||||||
|
# You can optionally override ipthreat_system and ipthreat_flags if desired.
|
||||||
|
# The ipthreat_apikey must be set at the bottom of this configuration file.
|
||||||
|
#
|
||||||
|
# `ipthreat_system` is a short name of the system attacked, i.e. SSH, SMTP, MYSQL, PHP, etc.
|
||||||
|
#
|
||||||
|
# For `ipthreat_flags`, most cases will use 8 (BruteForce) which is the default, but you could use others.
|
||||||
|
# You can use the name or the ordinal.
|
||||||
|
# Multiple values are comma separated.
|
||||||
|
# ```
|
||||||
|
# Name Ordinal Description
|
||||||
|
# Dns 1 Abuse/attack of dns (domain name server)
|
||||||
|
# Fraud 2 General fraud, whether orders, misuse of payment info, etc
|
||||||
|
# DDos 4 Distributed denial of service attack, whether through http requests, large ping attack, etc
|
||||||
|
# BruteForce 8 Brute force login attack
|
||||||
|
# Proxy 16 IP is a proxy like TOR or other proxy server
|
||||||
|
# Spam 32 Email, comment or other type of spam
|
||||||
|
# Vpn 64 IP is part of a VPN
|
||||||
|
# Hacking 128 General hacking outside of brute force attack (includes vulnerability scans, sql injection, etc.). Use port scan flag instead if it's just probe on ports.
|
||||||
|
# BadBot 256 Bad bot that is not honoring robots.txt or just flooding with too many requests, etc
|
||||||
|
# Compromised 512 The ip has been taken over by malware or botnet
|
||||||
|
# Phishing 1024 The ip is involved in phishing or spoofing
|
||||||
|
# Iot 2048 The ip has targetted an iot (Internet of Things) device
|
||||||
|
# PortScan 4096 Port scan
|
||||||
|
# See https://ipthreat.net/bulkreportformat for more information
|
||||||
|
# ```
|
||||||
|
|
||||||
|
[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.
|
||||||
|
#
|
||||||
|
# Tags: See jail.conf(5) man page
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionban = curl -sSf "https://api.ipthreat.net/api/report" -X POST -H "Content-Type: application/json" -H "X-API-KEY: <ipthreat_apikey>" -d "{\"ip\":\"<ip>\",\"flags\":\"<ipthreat_flags>\",\"system\":\"<ipthreat_system>\",\"notes\":\"fail2ban\"}"
|
||||||
|
|
||||||
|
# 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: ipthreat_apikey
|
||||||
|
# Notes Your API key from ipthreat.net
|
||||||
|
# Values: STRING Default: None
|
||||||
|
# Register for ipthreat [https://ipthreat.net], get api key and set below.
|
||||||
|
# You will need to set the flags and system in the action call in jail.conf
|
||||||
|
ipthreat_apikey =
|
||||||
|
|
||||||
|
# By default, the ipthreat system is the name of the fail2ban jail
|
||||||
|
ipthreat_system = <name>
|
||||||
|
|
||||||
|
# By default the ip threat flags is 8 (brute force), but you can override this per jail if desired
|
||||||
|
ipthreat_flags = 8
|
86
njallavps/swag/fail2ban/action.d/mail-buffered.conf
Normal file
86
njallavps/swag/fail2ban/action.d/mail-buffered.conf
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[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 "Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Output will be buffered until <lines> lines are available.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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 "Hi,\n
|
||||||
|
These hosts have been banned by Fail2Ban.\n
|
||||||
|
`cat <tmpfile>`
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: Summary from <fq-hostname>" <dest>
|
||||||
|
rm <tmpfile>
|
||||||
|
fi
|
||||||
|
printf %%b "Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: stopped on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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 "Hi,\n
|
||||||
|
These hosts have been banned by Fail2Ban.\n
|
||||||
|
`cat <tmpfile>`
|
||||||
|
\nRegards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: Summary" <dest>
|
||||||
|
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
|
||||||
|
|
||||||
|
# Destination/Addressee of the mail
|
||||||
|
#
|
||||||
|
dest = root
|
28
njallavps/swag/fail2ban/action.d/mail-whois-common.conf
Normal file
28
njallavps/swag/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]
|
92
njallavps/swag/fail2ban/action.d/mail-whois-lines.conf
Normal file
92
njallavps/swag/fail2ban/action.d/mail-whois-lines.conf
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
# Modified-By: Yaroslav Halchenko to include grepping on IP over log files
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = mail-whois-common.conf
|
||||||
|
helpers-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 "Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd> "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = printf %%b "Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban" | <mailcmd> "[Fail2Ban] <name>: stopped on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
_ban_mail_content = ( printf %%b "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" )
|
||||||
|
|
||||||
|
actionban = %(_ban_mail_content)s | <mailcmd> "[Fail2Ban] <name>: banned <ip> from <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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: mailcmd
|
||||||
|
# Notes.: Your system mail command. Is passed 2 args: subject and recipient
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
mailcmd = mail -E 'set escape' -s
|
||||||
|
|
||||||
|
# Default name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Destinataire of the mail
|
||||||
|
#
|
||||||
|
dest = root
|
||||||
|
|
||||||
|
# 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>
|
71
njallavps/swag/fail2ban/action.d/mail-whois.conf
Normal file
71
njallavps/swag/fail2ban/action.d/mail-whois.conf
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[INCLUDES]
|
||||||
|
|
||||||
|
before = mail-whois-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 "Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = printf %%b "Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: stopped on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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 "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"|mail -E 'set escape' -s "[Fail2Ban] <name>: banned <ip> from <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Destination/Addressee of the mail
|
||||||
|
#
|
||||||
|
dest = root
|
||||||
|
|
65
njallavps/swag/fail2ban/action.d/mail.conf
Normal file
65
njallavps/swag/fail2ban/action.d/mail.conf
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Fail2Ban configuration file
|
||||||
|
#
|
||||||
|
# Author: Cyril Jaquier
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
[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 "Hi,\n
|
||||||
|
The jail <name> has been started successfully.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = printf %%b "Hi,\n
|
||||||
|
The jail <name> has been stopped.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: stopped on <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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 "Hi,\n
|
||||||
|
The IP <ip> has just been banned by Fail2Ban after
|
||||||
|
<failures> attempts against <name>.\n
|
||||||
|
Regards,\n
|
||||||
|
Fail2Ban"|mail -E 'set escape' -s "[Fail2Ban] <name>: banned <ip> from <fq-hostname>" <dest>
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Destination/Addressee of the mail
|
||||||
|
#
|
||||||
|
dest = root
|
||||||
|
|
143
njallavps/swag/fail2ban/action.d/mynetwatchman.conf
Normal file
143
njallavps/swag/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
njallavps/swag/fail2ban/action.d/netscaler.conf
Normal file
33
njallavps/swag/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
njallavps/swag/fail2ban/action.d/nftables-allports.conf
Normal file
17
njallavps/swag/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
njallavps/swag/fail2ban/action.d/nftables-multiport.conf
Normal file
17
njallavps/swag/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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user