AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题

问题[fail2ban](computer)

Martin Hope
vvkatwss vvkatwss
Asked: 2023-02-07 04:16:53 +0800 CST

如何使用 fail2ban 和 nftables 禁止 <SUBNET>

  • 6

我有 Debian 10,带有 iptables 的 Fail2Ban v0.10.6 和我的过滤器<SUBNET>。现在我有 Ubuntu 22.04,Fail2Ban v0.11.2,我试图让它与 nftables 一起工作。jail.local我只为 nftables添加。我的配置:

# /etc/fail2ban/fail2ban.conf
[DEFAULT]
loglevel = INFO
logtarget = /var/log/fail2ban.log
syslogsocket = auto
socket = /var/run/fail2ban/fail2ban.sock
pidfile = /var/run/fail2ban/fail2ban.pid
dbfile = /var/lib/fail2ban/fail2ban.sqlite3
dbpurgeage = 1d
dbmaxmatches = 10
[Definition]
[Thread]

# /etc/fail2ban/jail.local
[DEFAULT]
banaction = nftables-multiport
banaction_allports = nftables-allports

# /etc/fail2ban/jail.d/00-geologger.conf
[geologger]
enabled     = true
__name__    = geologger
filter      = geologger
action      = %(action_)s
port        = ssh,2222,smtp,465,submission
logpath     = /var/log/geologger.log
backend     = %(default_backend)s
bantime     = 1m
maxretry    = 1
findtime    = 30m

# /etc/fail2ban/filter.d/geologger.conf 
[INCLUDES]
before = common.conf
[Definition]
mode      = normal
failregex = ipv4_addr=\([\d\./:]+-<SUBNET>\).*$

ignoreregex =

# nft list ruleset:
table ip filter {
    chain INPUT {
    }

    chain FORWARD {
    }

    chain f2b-geologger {
    }
}
table inet f2b-table {
    chain f2b-chain {
        type filter hook input priority filter - 1; policy accept;
    }
}

这是来自 fail2ban.log 的错误:

2023-02-03 14:09:18,948 fail2ban.filter         [3985]: INFO    [geologger] Found 178.127.150.0/24 - 2023-02-03 14:09:18
2023-02-03 14:09:19,552 fail2ban.actions        [3985]: NOTICE  [geologger] Ban 178.127.150.0/24
2023-02-03 14:09:19,673 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- exec: nft add table inet f2b-table
nft -- add chain inet f2b-table f2b-chain \{ type filter hook input priority -1 \; \}
nft add set inet f2b-table addr-set-geologger \{ type ipv4_addr\; \}
for proto in $(echo 'tcp' | sed 's/,/ /g'); do
nft add rule inet f2b-table f2b-chain $proto dport \{ $(echo 'ssh,2222,smtp,465,submission' | sed s/:/-/g) \} ip saddr @addr-set-geologger reject
done
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: 'Error: Could not process rule: Numerical result out of range'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: 'add set inet f2b-table addr-set-geologger { type ipv4_addr; }'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: 'Error: No such file or directory'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: 'add rule inet f2b-table f2b-chain tcp dport { ssh,2999,smtp,465,submission } ip saddr @addr-set-geologger reject'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- stderr: '                                                                                      ^^^^^^^^^^^^^^^^^^^'
2023-02-03 14:09:19,674 fail2ban.utils          [3985]: ERROR   7fc55d851980 -- returned 1
2023-02-03 14:09:19,674 fail2ban.actions        [3985]: ERROR   Failed to execute ban jail 'geologger' action 'nftables-multiport' info 'ActionInfo({'ip': '178.127.150.0/24', 'family': 'inet4', 'fid': <function Actions.ActionInfo.<lambda> at 0x7fc55efa4940>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x7fc55efa5000>})': Error starting action Jail('geologger')/nftables-multiport: 'Script error'

如何解决?

fail2ban
  • 1 个回答
  • 53 Views
Martin Hope
x43
Asked: 2020-11-02 10:22:00 +0800 CST

Fail2ban - 配置期间失败:文件不包含节标题

  • 6

我正在为我的 linux (debian) 服务器设置 Fail2ban。当我检查 fail2ban 服务的状态时,我收到此错误:

● fail2ban.service - Fail2Ban Service
   Loaded: loaded (/lib/systemd/system/fail2ban.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-11-01 13:15:05 EST; 5s ago
     Docs: man:fail2ban(1)
  Process: 17851 ExecStartPre=/bin/mkdir -p /var/run/fail2ban (code=exited, status=0/SUCCESS)
  Process: 17852 ExecStart=/usr/bin/fail2ban-server -xf start (code=exited, status=255/EXCEPTION)
 Main PID: 17852 (code=exited, status=255/EXCEPTION)

Nov 01 13:15:05 raspberrypi systemd[1]: Starting Fail2Ban Service...
Nov 01 13:15:05 raspberrypi systemd[1]: Started Fail2Ban Service.
Nov 01 13:15:05 raspberrypi fail2ban-server[17852]:  Failed during configuration: File contains no section headers.
Nov 01 13:15:05 raspberrypi fail2ban-server[17852]: file: '/etc/fail2ban/jail.local', line: 21
Nov 01 13:15:05 raspberrypi fail2ban-server[17852]: 'bantime = 1h\n'
Nov 01 13:15:05 raspberrypi fail2ban-server[17852]:  Async configuration of server failed
Nov 01 13:15:05 raspberrypi systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Nov 01 13:15:05 raspberrypi systemd[1]: fail2ban.service: Failed with result 'exit-code'.

我感觉这与我的配置文件有关,这是它的前 30 行:

#
# WARNING: heavily refactored in 0.9.0 release.  Please review and
#          customize settings for your setup.
#
# Changes:  in most of the cases you should not modify this
#           file, but provide customizations in jail.local file,
#           or separate .conf files under jail.d/ directory, e.g.:
#
# HOW TO ACTIVATE JAILS:
#
# YOU SHOULD NOT MODIFY THIS FILE.
#
# It will probably be overwritten or improved in a distribution update.
#
# Provide customizations in a jail.local file or a jail.d/customisation.local.
# For example to change the default bantime for all jails and to enable the
# ssh-iptables jail the following (uncommented) would appear in the .local file.
# See man 5 jail.conf for details.
#
# [DEFAULT]
bantime = 1h
#
# [sshd]
enabled = true
#
# See jail.conf(5) man page for more information



# Comments: use '#' for comment lines and ';' (following a space) for inline comments


[INCLUDES]

#before = paths-distro.conf
before = paths-debian.conf

# The DEFAULT allows a global definition of the options. They can be overridden
# in each jail afterwards.

[DEFAULT]

#
# MISCELLANEOUS OPTIONS
#
ssh fail2ban
  • 1 个回答
  • 2702 Views
Martin Hope
Kenny
Asked: 2020-04-01 21:09:01 +0800 CST

Fail2ban Debian 拉伸roundcube-auth failregex 不起作用

  • 5

Debian Stretch - roundcube-auth 不禁止从 IP 登录失败。似乎 fileregex 与记录的失败登录不匹配。

从 roundcube 登录 /var/log/mail.log 失败就像

Mar 30 16:15:31 debian roundcube[13209]: <ppt6hqpa> IMAP Error: Login failed for [email protected] against localhost from 255.255.255.255. LOGIN: Login failed. in /var/www/html/roundcube/program/lib/Roundcube/rcube_imap.php on line 200 (POST /roundcube/?_task=login&_action=login)
Mar 30 16:15:32 debian roundcube[13209]: <ppt6hqpa> Failed login for [email protected] from 255.255.255.255 in session ppt6hqpajq3nup5v (error: 0)

fail2ban -roundcube-auth.conf

[INCLUDES]

before = common.conf

[Definition]
failregex = ^\s*(\[\])?(%(__hostname)s\s*(roundcube:)?\s*(<[\w]+>)? IMAP Error)?: (FAILED login|Login failed) for .*? from <HOST>(\. .* in .*?/rcube_imap\.php on line \d+ \(\S+ \S+\))?$
                ^\[\]:\s*(<[\w]+>)? Failed login for [\w\-\.\+]+(@[\w\-\.\+]+\.[a-zA-Z]{2,6})? from <HOST> in session \w+( \(error: \d\))?$

fail2ban - jail.conf

[roundcube-auth]

port     = http,https
#logpath  = %(roundcube_errors_log)s
logpath  = /var/log/mail.log
enabled = true
maxretry = 2
bantime = 3600

fail2ban-客户端状态

fail2ban-client status
Status
|- Number of jail:      9
`- Jail list:   apache-badbots, courier-auth, postfix, postfix-ispmail, postfix-sasl, proftpd, roundcube-auth, squirrelmail, sshd

fail2ban-client 状态 roundcube-auth

Status for the jail: roundcube-auth
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     0
|  `- File list:        /var/log/mail.log
`- Actions
   |- Currently banned: 0
   |- Total banned:     0
   `- Banned IP list:
debian fail2ban
  • 1 个回答
  • 238 Views
Martin Hope
Cédric Françoys
Asked: 2019-09-20 00:57:15 +0800 CST

什么是 Fail2ban 持续时间接受的符号?

  • 5

我一直在寻找可接受的 Fail2ban Jail 配置文件的持续时间格式(也许它不是 F2B 独有的)。

我想确保在表达时间量时哪些后缀是有效的。

F2B 配置对此并不明确:https ://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Jails

到目前为止,似乎接受了以下符号:m、h、d

谁能指出这些后缀的完整列表?

time fail2ban
  • 1 个回答
  • 256 Views
Martin Hope
KNIF
Asked: 2019-08-19 07:42:38 +0800 CST

fail2ban 404 暴力破解 sharex

  • 7

我使用自己的服务器(nginx,我使用https://yunohost.org作为 CP)作为带有 ShareX(https://getsharex.com/)的屏幕截图上传器。在屏幕截图的上传过程中,文件名是随机的。

问题:最近很多人都在为这些图片上传网站编写暴力破解程序。他们只是编写了一个小程序,向 url 发送随机 httprequest,并检查它是否返回 404,如果没有,则保存 url。这些人可以获得他们不应该看到的半私人屏幕截图。

解决方案:这些程序不使用任何代理,因此您应该能够使用 fail2ban 阻止这些请求。我没有任何经验,所以我不能自己做,所以我问你。

我需要一个 fail2ban 正则表达式和 jail 来阻止 IP 的太多请求,这些请求导致错误 404(例如,如果有人每秒发送 5 个请求(404!),它会禁止它们)。

我希望任何人都可以帮助我。

最好的问候 KNIF

brute-force fail2ban
  • 1 个回答
  • 319 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve