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

我有一个像这样设置的规则;

在/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" [email protected]
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 protected]
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

它会注意到用户[email protected]并且不会报告它,除非它在300秒后再次发生,因为它键入了[email protected].

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

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...