Add test write function
parent
1f65c765cc
commit
1b4dc7cbd3
4
init.lua
4
init.lua
|
@ -60,13 +60,15 @@ end
|
|||
function cc_attack_check()
|
||||
if config_cc_check == "on" then
|
||||
local USER_AGENT = get_user_agent()
|
||||
local ATTACK_URL = ngx.var.host .. ngx.var.request_uri
|
||||
--local ATTACK_URL = ngx.var.host .. ngx.var.request_uri
|
||||
local ATTACK_URL = ngx.var.host .. ngx.var.uri
|
||||
local CC_TOKEN = get_client_ip() .. "." .. ngx.md5(ATTACK_URL .. USER_AGENT)
|
||||
local limit = ngx.shared.limit
|
||||
local CCcount=tonumber(string.match(config_cc_rate,'(.*)/'))
|
||||
local CCseconds=tonumber(string.match(config_cc_rate,'/(.*)'))
|
||||
local req,_ = limit:get(CC_TOKEN)
|
||||
if req then
|
||||
--write('/data/wwwlogs/info.log',CC_TOKEN ..'\t'.. ATTACK_URL .. '\t'.. 'req: ' .. req .. "\n")
|
||||
if req > CCcount then
|
||||
log_record('CC_Attack',ngx.var.request_uri,"-","-")
|
||||
if config_waf_enable == "on" then
|
||||
|
|
12
lib.lua
12
lib.lua
|
@ -71,6 +71,18 @@ function log_record(method,url,data,ruletag)
|
|||
file:close()
|
||||
end
|
||||
|
||||
--test log
|
||||
function write(logfile, msg)
|
||||
local fd,err = io.open(logfile,"a+")
|
||||
if fd == nil then
|
||||
ngx.log(ngx.ERR,"writefile msg : "..msg,err)
|
||||
return
|
||||
end
|
||||
fd:write(msg)
|
||||
fd:flush()
|
||||
fd:close()
|
||||
end
|
||||
|
||||
--WAF return
|
||||
function waf_output()
|
||||
if config_waf_output == "redirect" then
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
\.(htaccess|bash_history)
|
||||
\.(bak|inc|old|mdb|sql|backup|java|class|tgz|gz|tar|zip)$
|
||||
(phpmyadmin|jmx-console|admin-console|jmxinvokerservlet)
|
||||
(jmx-console|admin-console|jmxinvokerservlet)
|
||||
java\.lang
|
||||
\.svn\/
|
||||
/(attachments|upimg|images|css|uploadfiles|html|uploads|templets|static|template|data|inc|forumdata|upload|includes|cache|avatar)/(\\w+).(php|jsp)
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
\.(js|css)$
|
||||
\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$
|
||||
\.(js|css)
|
||||
\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)
|
||||
403\.html
|
||||
|
|
Loading…
Reference in New Issue