加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何让sec正确忽略时间戳

发布时间:2020-12-13 18:09:13 所属栏目:Linux 来源:网络整理
导读:我有一个像这样设置的规则; 在/etc/sec/rules.d我有; type=SingleWithSuppressptype=regexppattern=(S+) sshd[d+]: PAM d+ more authentication failures; logname=.* uid=.* euid=.* tty=ssh ruser=.* rhost=(.*) user=(.*)desc=Login Failure: $0act
我有一个像这样设置的规则;

在/etc/sec/rules.d我有;

type=SingleWithSuppress
ptype=regexp
pattern=(S+) sshd[d+]: PAM d+ more authentication failures; logname=.* uid=.* euid=.* tty=ssh ruser=.* rhost=(.*) user=(.*)
desc=Login Failure: $0
action=pipe '%s ' /bin/mail -s "login failure $2 to $3@$1" team@team.com
window=300

所以如果这是通过syslog来的;

Nov 21 11:24:10 servername.server.com sshd[26846]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost= user=kloggins

它应该根据模式匹配(根据我的正则表达式编辑器);

servername.server.com sshd[26846]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost= user=kloggins

我们遇到垃圾邮件问题,因为时间戳正在发生变化.所以我重写了模式以匹配主机名后的所有内容.

但是,这似乎不起作用,每次用户“身份验证失败”时,我仍然会收到一封电子邮件.

我一直在使用以下测试;

logger -p syslog.err 'sshd[26846]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost= user='

有任何想法吗?我可能只是误解了秒.这是我第一次使用它!
任何帮助将不胜感激.谢谢!

解决方法

好吧,经过近一天的拔毛,我终于明白了a)怎么做以及b)我对第二节的误解.

在阅读sec手册页时,它描述了desc =基本上显示匹配.所以在我看来,这意味着它应该显示模式中匹配的内容.嗯,是的,这是真的,在这种情况下,该模式中的匹配是;主机名,rhost和用户.

所以,当我正在做desc =登录失败:$0时,我正在关闭整条线路.那很糟.

所以我改为将其更改为键入用户名和主机名,然后使其遵守window = 300规则,因为时间戳(整行)没有改变;又名,以下纲要;

/etc/sec/rules.d/ssh.sec

type=SingleWithSuppress
ptype=regexp
pattern=(S+) sshd[d+]: PAM d+ more authentication failures; logname=.* uid=.* euid=.* tty=ssh ruser=.* rhost=(.*) user=(.*)
desc=Login Failure: $3@$1
action=pipe '%s $0' /bin/mail -s "Login Failure: $3@$1" email@email.com
window=300

错误行

Nov 21 01:58:10 test.test.com sshd[26846]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=test.test.com user=kloggins

它会注意到用户kloggins@test.test.com并且不会报告它,除非它在300秒后再次发生,因为它键入了kloggins@test.test.com.

我现在已经好几次测试了,它是一个’werkin’.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读