Apache上的ModSecurity(Debian Wheezy),身份validation日志logging

我是ModSecurity的新手,在服务器上工作得很好,但我想控制它logging事物的方式。 例如,因为我正在解决我的网站,以便白名单或更正php编码问题,以便我可以有一个干净的modsec_audit.log当一切正常工作,我碰到以下内容。

每当我通过basic或者htdigestauthentication请求一个受密码保护的url时,ModSecurity将它logging在modsec_audit.log ,如下所示:

htdigestauthentication:

 --838e7b1b-A-- [17/Nov/2013:19:13:51 +0200] Uoj5T8CoAWQAABfMVE0AAAAA xxx.xxx.xxx.xxx XXXXX xxx.xxx.xxx.xxx XXXXX --838e7b1b-B-- GET / HTTP/1.1 Host: XXX.XXX.com:XXXX User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive --838e7b1b-F-- HTTP/1.1 401 Authorization Required WWW-Authenticate: Digest realm="Members Only", nonce="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", algorithm=MD5, qop="auth" Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 290 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=iso-8859-1 --838e7b1b-H-- Stopwatch: 1384708431494144 2002 (- - -) Stopwatch2: 1384708431494144 2002; combined=32, p1=0, p2=0, p3=0, p4=0, p5=32, sr=0, sw=0, l=0, gc=0 Producer: ModSecurity for Apache/2.6.6 (http://www.modsecurity.org/); OWASP_CRS/2.2.5. Server: Apache --838e7b1b-Z-- 

要么

基本authentication:

 --b8248f7a-A-- [17/Nov/2013:19:28:11 +0200] Uoj8q8CoAWQAABgxs7kAAAAM xxx.xxx.xxx.xxx XXXXX xxx.xxx.xxx.xxx XXXXX --b8248f7a-B-- GET / HTTP/1.1 Host: XXX.XXX.com User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Cookie: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Connection: keep-alive --b8248f7a-F-- HTTP/1.1 401 Authorization Required WWW-Authenticate: Basic realm="Members Only" Content-Encoding: gzip Vary: Accept-Encoding,User-Agent Cache-Control: no-cache, private, no-transform, must-revalidate, proxy-revalidate, post-check=300, pre-check=300, max-age=300 Pragma: no-cache Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html --b8248f7a-H-- Apache-Handler: x-httpd-suphp Stopwatch: 1384709291811105 152463 (- - -) Stopwatch2: 1384709291811105 152463; combined=54, p1=0, p2=0, p3=0, p4=0, p5=54, sr=0, sw=0, l=0, gc=0 Producer: ModSecurity for Apache/2.6.6 (http://www.modsecurity.org/); OWASP_CRS/2.2.5. Server: Apache --b8248f7a-Z-- 

上面的日志logging发生在请求后,我没有显示失败的密码或成功的密码。

我的问题是,如果有什么办法阻止它login这个。 我试图将我的IP列入白名单,但没有结果。 我不知道是否阻止它logging这样的事情是个好主意,但是我认为每次“I”甚至请求一个这样的信息时,我们都会把/var/log/apache2/modsec_audit.loglogging下来密码保护的url。

有关我的服务器的更多信息:

 # apt-cache show libapache-mod-security | grep Version Version: 2.6.6-6+deb7u1 

到目前为止,我使用了以下规则:

 /usr/share/modsecurity-crs/base_rules/ 

..和modsecurity.conf-推荐为modsecurity.conf

提前致谢。 干杯

编辑:

我想我已经find解决这个问题的解决方法。

为了排除状态401被logging,我改变了modsecurity.confSecAuditLogRelevantStatus正则expression式:

 SecAuditLogRelevantStatus "^(?:5|4(?!04))" 

对此:

 SecAuditLogRelevantStatus "^(?:5|4\d[^41])" 

我也做了一个额外的改变,不确定是否相关,但是我改变了modsecurity_crs_10_setup.conf SecDefaultAction

 SecDefaultAction "phase:2,deny,log" 

对此:

 SecDefaultAction "phase:2,deny,log,noauditlog" 

经过密码保护的urltesting之后,我现在什么都没有在modsec_audit.log这正是我想要的。 我不确定是否有一个更聪明的方法来做到这一点,但这是有效的。 任何意见赞赏。

1)确保您的白名单规则绕过阶段1,是规则集中最高规则中的最高规则。

这是一个示例规则:

 SecRule REMOTE_ADDR "^111.222.333.444" phase:1,nolog,allow,ctl:ruleEngine=off 

注意它在第一阶段绕过,并且不会在扫描过程的任何其他部分继续,它被设置为允许,而不是根本login,不受规则引擎的约束。

2)HTTP 401是一个双叉错误代码。 访问URL资源需要用户身份validation1)尚未提供或2)已提供但未通过授权testing。 这对于蛮力login等入侵企图的补救行为很重要。

3)这些日志的date是否真的是2013年11月? 您可能需要更新设备上的date/时间。