local sh = ngx.shared.ipCache local robotIp ='rb:' .. waf.ip local c, f = sh:get(robotIp)
-- 如果是静态页面且没有进行滑动旋转验证码验证则返回 if not (waf.isQueryString or waf.reqContentLength >0) and f ~=2then returnfalse end
if not c then sh:set(robotIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间段 else if f ==2then return waf.checkRobot(waf) -- 启动机器人滑动旋转验证码验证 end sh:incr(robotIp, 1) if c +1>=360then sh:set(robotIp, c +1, 1800, 2) -- 达到了60秒内请求超过360次的阈值,进入机器人验证模式 returntrue, robotIp, true end end
localform= waf.form localuri= toLower(waf.uri) if form and(has(uri, "login") or has(uri, "logon") or has(uri, "signin")) then localf= form["FORM"] if f then for k, v in pairs(f)do k= toLower(k) if (k == "pass" or has(k, "pwd") or has(k, "passwd") or has(k, "password")) and check(v) then returntrue, form["RAW"], false end end end end
localfunctionrMatch(v) local m = rgx(v, "(?:][^\\]]+$|][^\\]]+\\[)", "jos") if m then return m, v end returnfalse end
local form = waf.form if form then for k, v inpairs(form["FORM"]) do iftype(v) == "table"then returntrue, k.."="..table.concat(v, ","), true end local m, d = rMatch(k) if m then return m, d, true end end end
local queryString = waf.queryString if queryString then for k, v inpairs(queryString) do iftype(v) == "table"then returntrue, k.."="..table.concat(v, ","), true end local m, d = rMatch(k) if m then return m, d, true end end end
local cookies = waf.cookies if cookies then for k, v inpairs(cookies) do iftype(v) == "table"then returntrue, k.."="..table.concat(v, ","), true end local m, d = rMatch(k) if m then return m, d, true end end end returnfalse
条评论