From 172b56505c572d1d0d39e063d5e8b1e4366fec19 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Jan 2016 12:20:08 +0800 Subject: [PATCH] add whit host support --- config.lua | 2 ++ init.lua | 15 +++++++++++++++ waf.lua | 1 + 3 files changed, 18 insertions(+) diff --git a/config.lua b/config.lua index 6e66ce6..fdca34d 100644 --- a/config.lua +++ b/config.lua @@ -6,9 +6,11 @@ Redirect="on" CookieMatch="on" postMatch="on" whiteModule="on" +whiteHostModule="on" black_fileExt={"php","jsp"} ipWhitelist={"127.0.0.1"} ipBlocklist={"1.0.0.1"} +hostWhiteList = {"www.xxx.com"} CCDeny="off" CCrate="100/60" html=[[ diff --git a/init.lua b/init.lua index eb44bf0..8233e7c 100644 --- a/init.lua +++ b/init.lua @@ -10,6 +10,7 @@ UrlDeny = optionIsOn(UrlDeny) PostCheck = optionIsOn(postMatch) CookieCheck = optionIsOn(cookieMatch) WhiteCheck = optionIsOn(whiteModule) +WhiteHostCheck = optionIsOn(whiteHostModule) PathInfoFix = optionIsOn(PathInfoFix) attacklog = optionIsOn(attacklog) CCDeny = optionIsOn(CCDeny) @@ -89,6 +90,20 @@ function whiteurl() end return false end + +function whitehost() + if WhiteHostCheck then + local items = Set(hostWhiteList) + for host in pairs(items) do + if ngxmatch(ngx.var.host, host, "isjo") then + log('POST',ngx.var.request_uri,"-","white host".. host) + return true + end + end + end + return false +end + function fileExtCheck(ext) local items = Set(black_fileExt) ext=string.lower(ext) diff --git a/waf.lua b/waf.lua index 6b1a23e..cc816c6 100644 --- a/waf.lua +++ b/waf.lua @@ -2,6 +2,7 @@ local content_length=tonumber(ngx.req.get_headers()['content-length']) local method=ngx.req.get_method() local ngxmatch=ngx.re.match if whiteip() then +elseif whitehost() then elseif blockip() then elseif denycc() then elseif ngx.var.http_Acunetix_Aspect then