fix PCRE_MULTILINE
parent
2b32a34dfc
commit
33940892a5
52
init.lua
52
init.lua
|
@ -33,16 +33,16 @@ function write(logfile,msg)
|
||||||
end
|
end
|
||||||
function log(method,url,data,ruletag)
|
function log(method,url,data,ruletag)
|
||||||
if attacklog then
|
if attacklog then
|
||||||
local realIp = getClientIp()
|
local realIp = getClientIp()
|
||||||
local ua = ngx.var.http_user_agent
|
local ua = ngx.var.http_user_agent
|
||||||
local servername=ngx.var.server_name
|
local servername=ngx.var.server_name
|
||||||
local time=ngx.localtime()
|
local time=ngx.localtime()
|
||||||
if ua then
|
if ua then
|
||||||
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" \""..ua.."\" \""..ruletag.."\"\n"
|
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" \""..ua.."\" \""..ruletag.."\"\n"
|
||||||
else
|
else
|
||||||
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" - \""..ruletag.."\"\n"
|
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" - \""..ruletag.."\"\n"
|
||||||
end
|
end
|
||||||
local filename = logpath..'/'..servername.."_"..ngx.today().."_sec.log"
|
local filename = logpath..'/'..servername.."_"..ngx.today().."_sec.log"
|
||||||
write(filename,line)
|
write(filename,line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ end
|
||||||
function read_rule(var)
|
function read_rule(var)
|
||||||
file = io.open(rulepath..'/'..var,"r")
|
file = io.open(rulepath..'/'..var,"r")
|
||||||
if file==nil then
|
if file==nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
t = {}
|
t = {}
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
|
@ -78,9 +78,9 @@ end
|
||||||
|
|
||||||
function whiteurl()
|
function whiteurl()
|
||||||
if WhiteCheck then
|
if WhiteCheck then
|
||||||
if wturlrules ~=nil then
|
if wturlrules ~=nil then
|
||||||
for _,rule in pairs(wturlrules) do
|
for _,rule in pairs(wturlrules) do
|
||||||
if ngxmatch(ngx.var.request_uri,rule,"isjo") then
|
if ngxmatch(ngx.var.request_uri,rule,"imjo") then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -98,8 +98,8 @@ function args()
|
||||||
else
|
else
|
||||||
data=val
|
data=val
|
||||||
end
|
end
|
||||||
if data and type(data) ~= "boolean" and rule ~="" and ngxmatch(unescape(data),rule,"isjo") then
|
if data and type(data) ~= "boolean" and rule ~="" and ngxmatch(unescape(data),rule,"imjo") then
|
||||||
log('GET',ngx.var.request_uri,"-",rule)
|
log('GET',ngx.var.request_uri,"-",rule)
|
||||||
say_html()
|
say_html()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -112,7 +112,7 @@ end
|
||||||
function url()
|
function url()
|
||||||
if UrlDeny then
|
if UrlDeny then
|
||||||
for _,rule in pairs(urlrules) do
|
for _,rule in pairs(urlrules) do
|
||||||
if rule ~="" and ngxmatch(ngx.var.request_uri,rule,"isjo") then
|
if rule ~="" and ngxmatch(ngx.var.request_uri,rule,"imjo") then
|
||||||
log('GET',ngx.var.request_uri,"-",rule)
|
log('GET',ngx.var.request_uri,"-",rule)
|
||||||
say_html()
|
say_html()
|
||||||
return true
|
return true
|
||||||
|
@ -125,19 +125,19 @@ end
|
||||||
function ua()
|
function ua()
|
||||||
local ua = ngx.var.http_user_agent
|
local ua = ngx.var.http_user_agent
|
||||||
if ua ~= nil then
|
if ua ~= nil then
|
||||||
for _,rule in pairs(uarules) do
|
for _,rule in pairs(uarules) do
|
||||||
if rule ~="" and ngxmatch(ua,rule,"isjo") then
|
if rule ~="" and ngxmatch(ua,rule,"imjo") then
|
||||||
log('UA',ngx.var.request_uri,"-",rule)
|
log('UA',ngx.var.request_uri,"-",rule)
|
||||||
say_html()
|
say_html()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
function body(data)
|
function body(data)
|
||||||
for _,rule in pairs(postrules) do
|
for _,rule in pairs(postrules) do
|
||||||
if rule ~="" and ngxmatch(unescape(data),rule,"isjo") then
|
if rule ~="" and ngxmatch(unescape(data),rule,"imjo") then
|
||||||
log('POST',ngx.var.request_uri,data,rule)
|
log('POST',ngx.var.request_uri,data,rule)
|
||||||
say_html()
|
say_html()
|
||||||
return true
|
return true
|
||||||
|
@ -149,7 +149,7 @@ function cookie()
|
||||||
local ck = ngx.var.http_cookie
|
local ck = ngx.var.http_cookie
|
||||||
if CookieCheck and ck then
|
if CookieCheck and ck then
|
||||||
for _,rule in pairs(ckrules) do
|
for _,rule in pairs(ckrules) do
|
||||||
if rule ~="" and ngxmatch(ck,rule,"isjo") then
|
if rule ~="" and ngxmatch(ck,rule,"imjo") then
|
||||||
log('Cookie',ngx.var.request_uri,"-",rule)
|
log('Cookie',ngx.var.request_uri,"-",rule)
|
||||||
say_html()
|
say_html()
|
||||||
return true
|
return true
|
||||||
|
@ -161,7 +161,7 @@ end
|
||||||
|
|
||||||
function denycc()
|
function denycc()
|
||||||
if CCDeny then
|
if CCDeny then
|
||||||
local uri=ngx.var.uri
|
local uri=ngx.var.uri
|
||||||
CCcount=tonumber(string.match(CCrate,'(.*)/'))
|
CCcount=tonumber(string.match(CCrate,'(.*)/'))
|
||||||
CCseconds=tonumber(string.match(CCrate,'/(.*)'))
|
CCseconds=tonumber(string.match(CCrate,'/(.*)'))
|
||||||
local token = getClientIp()..uri
|
local token = getClientIp()..uri
|
||||||
|
|
Loading…
Reference in New Issue