You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngx_lua_waf/waf.lua

71 lines
1.7 KiB

11 years ago
local content_length=tonumber(ngx.req.get_headers()['content-length'])
11 years ago
local method=ngx.req.get_method()
if whiteip() then
11 years ago
elseif blockip() then
11 years ago
elseif denycc() then
elseif ngx.var.http_Acunetix_Aspect then
ngx.exit(444)
elseif ngx.var.http_X_Scan_Memo then
ngx.exit(444)
elseif whiteurl() then
elseif ua() then
elseif url() then
elseif args() then
elseif cookie() then
elseif PostCheck then
if method=="POST" then
11 years ago
local boundary = get_boundary()
if boundary then
local len = string.len
local sock, err = ngx.req.socket()
if not sock then
return
11 years ago
end
11 years ago
ngx.req.init_body(128 * 1024)
sock:settimeout(0)
local content_length = nil
content_length=tonumber(ngx.req.get_headers()['content-length'])
local chunk_size = 4096
if content_length < chunk_size then
chunk_size = content_length
end
local size = 0
while size < content_length do
local data, err, partial = sock:receive(chunk_size)
data = data or partial
if not data then
return
end
ngx.req.append_body(data)
size = size + len(data)
local less = content_length - size
if less < chunk_size then
chunk_size = less
end
11 years ago
end
11 years ago
ngx.req.finish_body()
if body(data) then
return true
end
else
11 years ago
ngx.req.read_body()
local args = ngx.req.get_post_args()
if not args then
return
end
for key, val in pairs(args) do
if type(val) == "table" then
data=table.concat(val, ", ")
else
data=val
end
if data and type(data) ~= "boolean" and body(data) then
return true
end
end
end
12 years ago
end
11 years ago
else
return
12 years ago
end