有关apache mod_security console的问题
jjiwei
|
1#
jjiwei 发表于 2008-06-19 15:38
有关apache mod_security console的问题
在使用mod_security这个功能时,不知道为什么console端不能读取mod_security生成的日志文件,不知道大家有谁使用过这个模块与CONSOLE端,对于AUDIT日志进行分析,mod_security.conf配置内容如下:
<IfModule mod_security.c> # Turn the filtering engine On or Off SecFilterEngine On #分析一个http请求 # Make sure that URL encoding is valid SecFilterCheckURLEncoding On #URL编码确认 # Only allow bytes from this range SecFilterForceByteRange 1 255 #字节范Χ检查, 以有效防止stack overflow attacks(栈溢出攻击). # The audit engine works independently and # can be turned On of Off on the per-server or # on the per-directory basis SecAuditEngine RelevantOnly SecAuditLogRelevantStatus "^(?:5|4\d[^4])" SecAuditLogType Concurrent SecAuditLogParts ABCDEFGHZ SecAuditLogStorageDir /usr/local/apache/logs/data/ SecAuditLog "|/usr/local/apache/bin/modsec-auditlog-collector.pl \ /usr/local/apache/logs/data/ /usr/local/apache/logs/modsec_audit.log /usr/local/apache/logs/index.log" #有效解决apache日志对某个用户或攻击者信息记?的不足. 如果要 #对某一个用户或攻击者发出的一个请求的详细记?, 可以访问 #/var/log/httpd/audit_log文件. # The name of the audit log file SecAuditLog /usr/local/apache/logs/modsec_audit.log SecFilterDebugLog /usr/local/apache/logs/modsec_debug.log SecFilterDebugLevel 0 #设置调试模式下的输出文件. # Should mod_security inspect POST payloads #SecFilterScanPOST On # Action to take by default SecFilterDefaultAction "deny,log,status:500" #设置特别的行动, 406为行动名称, 前面的三个为行动参数. # Redirect user on filter match SecFilter sh redirect:http://www.google.com SecFilter chmod redirect:http://www.google.com SecFilter wget redirect:http://www.google.com # 当匹配sh的时候,重新定向到一个特殊的页面,让攻击者知难而退 # Execute the external script on filter match #SecFilter yyy log,exec:/data1/usr/apache/bin/report-attack.pl # Simple filter #SecFilter 111 # Only check the QUERY_STRING variable #SecFilterSelective QUERY_STRING 222 # Only check the body of the POST request #SecFilterSelective POST_PAYLOAD 333 # Only check arguments (will work for GET and POST) #SecFilterSelective ARGS 444 # Test filter SecFilter "/cgi-bin/keyword" # Another test filter, will be denied with 404 but not logged # action supplied as a parameter overrides the default action #SecFilter 999 "deny,nolog,status:404" # Prevent OS specific keywords SecFilter /etc/password SecFilter /etc/*passwd SecFilter /bin/*sh #过滤一些敏感的东西,我们使用*是为了攻击者使用/etc/./passwd来绕开检测 # SecFilter "../" # 防止double dot攻击,也就是类似http://www.test.com/openfile.php?path=/../../. # Prevent path traversal (..) attacks SecFilter "/././" SecFilter "/../../" SecFilter "\.\./" #阻止目?周游攻击. # Weaker XSS protection but allows common HTML tags SecFilter "<( |n)*script" #对不安全的(跨站点脚本)XSS进行保护, 但允许普通的HTML标识. # Prevent XSS atacks (HTML/Javascript injection) SecFilter "<(.|n)+>" #防止XSS攻击 (HTML/Javascript注射) # Very crude filters to prevent SQL injection attacks SecFilter "delete[[:space:]]+from" SecFilter "insert[[:space:]]+into" SecFilter "select.+from" SecFilter "union[[:space:]]+from" SecFilter "drop[[:space:]]table" #防止SQL注射攻击 # Require HTTP_USER_AGENT and HTTP_HOST headers SecFilterSelective "HTTP_USER_AGENT|HTTP_HOST" "^$" #需要 HTTP_USER_AGENT和HTTP_HOST头. # Forbid file upload #SecFilterSelective "HTTP_CONTENT_TYPE" multipart/form-data # Only watch argument p1 #SecFilterSelective "ARG_p1" 555 # Watch all arguments except p1 #SecFilterSelective "ARGS|!ARG_p2" 666 # Only allow our own test utility to send requests (or Mozilla) #SecFilterSelective HTTP_USER_AGENT "!(mod_security|mozilla)" # Do not allow variables with this name #SecFilterSelective ARGS_NAMES 777 # Do now allow this variable value (names are ok) #SecFilterSelective ARGS_VALUES 888 # Stop spamming through FormMail # note the exclamation mark at the beginning # of the filter - only requests that match this regex will # be allowed #<Location /cgi-bin/FormMail> #SecFilterSelective "ARG_recipient" "[email=!@webkreator.com$]!@webkreator.com$[/email]" #</Location> # when allowing upload, only allow images # note that this is not foolproof, a determined attacker # could get around this #<Location /fileupload.php> #SecFilterInheritance Off #SecFilterSelective POST_PAYLOAD "!image/(jpeg|bmp|gif)" #</Location> #限制了/fileupload.php文件只能用来上传jpeg.bmp和gif的图片 #伪装服务器标识 SecServerSignature "Microsoft-IIS/6.0" </IfModule> |