diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index e3ef7135e..30d4f2fb3 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -639,8 +639,35 @@ def setRetry(): def setSiteRetry(): + return public.returnJson(True, '设置成功-?!', []) + + +def setCcConf(): + args = getArgs() + data = checkArgs(args, ['siteName', 'cycle', 'limit', 'endtime','is_open_global','increase']) + if not data[0]: + return data[1] + + conf = getJsonPath('config') + content = public.readFile(conf) + cobj = json.loads(content) + + tmp = cobj['cc'] + + + tmp['cycle'] = args['cycle'] + tmp['limit'] = args['limit'] + tmp['endtime'] = args['endtime'] + tmp['is_open_global'] = args['is_open_global'] + tmp['increase'] = args['increase'] + cobj['cc'] = tmp + + cjson = public.getJson(cobj) + public.writeFile(conf, cjson) return public.returnJson(True, '设置成功!', []) +def setSiteCcConf(): + return public.returnJson(True, '设置成功-?!', []) def saveScanRule(): args = getArgs() @@ -861,6 +888,7 @@ def setSiteObjOpen(): return public.returnJson(True, '设置成功!') + def getWafSrceen(): conf = getJsonPath('total') return public.readFile(conf) @@ -923,6 +951,10 @@ if __name__ == "__main__": print setObjOpen() elif func == 'set_site_obj_open': print setSiteObjOpen() + elif func == 'set_cc_conf': + print setCcConf() + elif func == 'set_site_cc_conf': + print setSiteCcConf() elif func == 'set_retry': print setRetry() elif func == 'set_site_retry': diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js index 3b9bbdb30..38f76aa4b 100755 --- a/plugins/op_waf/js/op_waf.js +++ b/plugins/op_waf/js/op_waf.js @@ -77,101 +77,104 @@ function setObjOpen(ruleName){ }); } + +//保存CC规则 +function saveCcRule(siteName,is_open_global, type) { + var increase = "0"; + if(type == 2){ + // set_aicc_open('start'); + increase = "0"; + }else{ + // set_aicc_open('stop'); + increase = type; + } + increase = "0"; + var pdata = { + siteName:siteName, + cycle: $("input[name='cc_cycle']").val(), + limit: $("input[name='cc_limit']").val(), + endtime: $("input[name='cc_endtime']").val(), + is_open_global:is_open_global, + increase:increase + } + console.log(pdata); + var act = 'set_cc_conf'; + if (siteName != 'undefined') act = 'set_site_cc_conf'; + + owPost(act, pdata, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + setTimeout(function(){ + if (siteName != 'undefined') { + siteWafConfig(siteName, 1); + } else { + wafGloabl(); + } + },1000); + }); +} + + function setCcRule(cycle, limit, endtime, siteName, increase){ var incstr = '
  • 此处设置仅对当前站点有效。
  • '; if (siteName == 'undefined') { incstr = '
  • 此处设置的是初始值,新添加站点时将继承,对现有站点无效。
  • '; } - - // get_aicc_config(function(res){ - var enhance_mode = ''; - // if(res.status){ - // enhance_mode = 2; - // }else{ - if(increase){ - enhance_mode = 1; - }else{ - enhance_mode = 0; + //
    \ + // 增强模式\ + //
    \ + // \ + //
    \ + //
    \ + //
    \ + // 四层防御\ + //
    \ + // \ + //
    \ + //
    \ + //
  • 增强模式:CC防御加强版,开启后可能会影响用户体验,建议在用户受到CC攻击时开启。
  • \ + + create_l = layer.open({ + type: 1, + title: "设置CC规则", + area: '540px', + closeBtn: 2, + shadeClose: false, + content: '
    \ +
    \ + 周期\ +
    \ +
    \ +
    \ + 频率\ +
    \ +
    \ +
    \ + 封锁时间\ +
    \ +
    \ + \ +
    \ +
    ', + success:function(layero,index){ + $('.btn_cc_all').click(function(){ + saveCcRule(siteName,1,$('[name="enhance_mode"]').val()); + }); + $('.btn_cc_present').click(function(){ + saveCcRule(siteName,0,$('[name="enhance_mode"]').val()); + }); } - // } - create_l = layer.open({ - type: 1, - title: "设置CC规则", - area: '540px', - closeBtn: 2, - shadeClose: false, - content: '
    \ -
    \ - 周期\ -
    \ -
    \ -
    \ - 频率\ -
    \ -
    \ -
    \ - 封锁时间\ -
    \ -
    \ -
    \ - 增强模式\ -
    \ - \ -
    \ -
    \ -
    \ - 四层防御\ -
    \ - \ -
    \ -
    \ - \ -
    \ -
    ', - success:function(layero,index){ - // console.log(siteName == 'undefined'); - // //\ - // if($('[name="enhance_mode"]').val() == 2 && siteName != 'undefined'){ - // $('[name="enhance_mode"]').attr('disabled','disabled'); - // } - // get_stop_ip(function(rdata){ - // $('[name="cc_four_defense"]').val(rdata.status?'1':'0'); - // }); - // $('[name="cc_four_defense"]').change(function(){ - // var _val = $(this).val(); - // if(_val == '0'){ - // set_stop_ip_stop(function(res){ - // layer.msg(res.msg,{icon:res.status?1:2}); - // }); - // }else{ - // set_stop_ip(function(res){ - // layer.msg(res.msg,{icon:res.status?1:2}); - // }); - // } - // }); - // $('.btn_cc_all').click(function(){ - // save_cc_rule(siteName,1,$('[name="enhance_mode"]').val()); - // layer.close(index); - // }); - // $('.btn_cc_present').click(function(){ - // save_cc_rule(siteName,0,$('[name="enhance_mode"]').val()); - // layer.close(index); - // }); - } - }); - // }); - + }); } diff --git a/plugins/op_waf/waf/rule/url_black.json b/plugins/op_waf/waf/rule/url_black.json deleted file mode 100755 index 0637a088a..000000000 --- a/plugins/op_waf/waf/rule/url_black.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/plugins/op_waf/waf/rule/url_white.json b/plugins/op_waf/waf/rule/url_white.json deleted file mode 100755 index 9769f9000..000000000 --- a/plugins/op_waf/waf/rule/url_white.json +++ /dev/null @@ -1 +0,0 @@ -["^/phpmyadmin_", "^/wp-content/themes/begin/timthumb\\.php", "^/web/index\\.php\\?c=cloud", "^/\\.well-known/"] \ No newline at end of file