if not waf.startWith(waf.toLower(waf.uri), "/api/") then returnfalse end
local sh = ngx.shared.ipCache local ccIp ='cc-' .. waf.ip local c, f = sh:get(ccIp) if not c then sh:set(ccIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间 else if f ==2then return waf.block(true) -- 重置TCP连接,不记录日志 end sh:incr(ccIp, 1) if c +1>=360then sh:set(ccIp, c +1, 300, 2) -- 设置5分钟也就是300秒拦截时间 returntrue, ccIp, true end end
local m = rgx(rb, "[a-z]:\\x5cinetpub\\b", "jo") if m then return m, rb, true end
if waf.status ==500 then local m = rgx(rb, "Microsoft OLE DB Provider for SQL Server(?:</font>.{1,20}?error '800(?:04005|40e31)'.{1,40}?Timeout expired| \\(0x80040e31\\)<br>Timeout expired<br>)|<h1>internal server error</h1>.*?<h2>part of the server has crashed or it has a configuration error\\.</h2>|cannot connect to the server: timed out", "jo") if m then return m, rb, true end local m = rgx(rb, "\\b(?:A(?:DODB\\.Command\\b.{0,100}?\\b(?:Application uses a value of the wrong type for the current operation\\b|error')| trappable error occurred in an external object\\. The script cannot continue running\\b)|Microsoft VBScript (?:compilation (?:\\(0x8|error)|runtime (?:Error|\\(0x8))\\b|Object required: '|error '800)|<b>Version Information:</b>(?: |\\s)(?:Microsoft \\.NET Framework|ASP\\.NET) Version:|>error 'ASP\\b|An Error Has Occurred|>Syntax error in string in query expression|/[Ee]rror[Mm]essage\\.aspx?\\?[Ee]rror\\b", "jo") if m then return m, rb, true end end
if waf.status ==404 then local m = rgx(rb, "\\bServer Error in.{0,50}?\\bApplication\\b", "jo") if m then return m, rb, true end end
returnfalse
php报错检测
过滤阶段:返回页面
规则描述:返回页面的php报错可能会泄露服务器敏感信息
规则内容:
1 2 3 4 5 6 7 8 9 10 11
local check = waf.plugins.phpErrorDetection.check local rb = waf.respBody if waf.status == 500 then local m, d = check(rb) if m then return m, "php error: " .. d, true end end return false
Java报错检测
过滤阶段:返回页面
规则描述:返回页面的java报错可能会泄露服务器敏感信息
规则内容:
1 2 3 4 5 6 7 8 9 10 11
local check = waf.plugins.javaErrorDetection.check local rb = waf.respBody if waf.status == 500 then local m,d = check(rb) if m then return m, "Java error: " .. d, true end end return false
条评论