diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py
index 9f26d8b15..25955ab37 100755
--- a/plugins/op_waf/index.py
+++ b/plugins/op_waf/index.py
@@ -1164,6 +1164,12 @@ def installPreInspection():
return 'ok'
+def cleanDropIp():
+ url = "http://127.0.0.1/clean_waf_drop_ip"
+ data = mw.httpGet(url)
+ return mw.returnJson(True, 'ok!', data)
+
+
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -1250,5 +1256,7 @@ if __name__ == "__main__":
print(getWafConf())
elif func == 'waf_site':
print(getWafSite())
+ elif func == 'clean_drop_ip':
+ print(cleanDropIp())
else:
print('error')
diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js
index c3b2bf1af..f88e197a2 100755
--- a/plugins/op_waf/js/op_waf.js
+++ b/plugins/op_waf/js/op_waf.js
@@ -753,6 +753,23 @@ function addIpBlack() {
});
}
+function addIpBlackArgs(ip) {
+ var pdata = {
+ start_ip: ip,
+ end_ip: ip,
+ }
+
+ if (pdata['start_ip'].split('.').length < 4 || pdata['end_ip'].split('.').length < 4) {
+ layer.msg('起始IP或结束IP格式不正确!');
+ return;
+ }
+
+ owPost('add_ip_black', pdata, function(data){
+ var rdata = $.parseJSON(data.data);
+ layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ });
+}
+
//从IP黑名单删除IP段
function removeIpBlack(index) {
@@ -1024,146 +1041,6 @@ function back_css(v) {
}
}
-//查看网站日志
-function siteWafLog(siteName) {
- var loadT = layer.msg('正在处理,请稍候..', { icon: 16, time: 0 });
- owPost('get_logs_list', { siteName: siteName } , function (data) {
- var tmp = $.parseJSON(data.data);
- var rdata = tmp.data;
- var selectLogDay = "";
- var day = rdata[0];
- for (var i = 0; i < rdata.length; i++) {
- selectLogDay += '';
- }
- if (rdata == "") {
- layer.msg("暂无日志记录", { icon: 6, shade: 0.3, time: 1000 });
- return
- }
- layer.open({
- type: 1,
- title: "日志【" + siteName + "】",
- area: ['880px', '500px'],
- closeBtn: 1,
- shadeClose: false,
- content: '
\
-
\
-
\
-
\
-
\
-
\
- 时间 | 用户IP | 类型 | URI地址 | User-Agent | 状态 | 过滤器 | 过滤规则 | 操作 |
\
- \
-
\
-
\
-
\
-
\
-
\
-
'
- });
- siteLogCon(siteName, day, 1);
- tableFixed("site_waf_log");
- });
-}
-
-
-//日志内容
-function siteLogCon(siteName, day, page) {
- if (!page) page = 1;
- var last = page - 1;
- var next = page + 1;
- var pagehtml = '';
- $("#site_waf_log").scrollTop(0);
-
- owPost('get_safe_logs', { siteName: siteName, toDate: day, p: page }, function(data){
- var tmp = $.parseJSON(data.data);
- if (!tmp.status){
- layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
- return;
- }
- var rdata = tmp.data;
- var con = '';
- for (var i = 0; i < rdata.length; i++) {
- con += '\
- '+ escapeHTML(rdata[i][0]) + ' | \
- ' + escapeHTML(rdata[i][1]) + ' | \
- '+ escapeHTML(rdata[i][2]) + ' | \
- '+ escapeHTML(rdata[i][3]) + ' | \
- '+ escapeHTML(rdata[i][4]) + ' | 已拦截 | \
- '+ escapeHTML(rdata[i][5]) + ' | \
- '+ escapeHTML(rdata[i][6]) + ' | \
- 误报 | 详细 | \
-
'
- }
-
- $("#LogDayCon").html(con);
- pagehtml = '首页上一页下一页第 ' + page + ' 页';
- $("#size_log_page").html(pagehtml);
- if (rdata.length < 1) $(".nextPage").hide();
- if (last < 1) $(".prevPage").hide();
-
- // 发送误报请求
- $(".submit_msg").click(function () {
- var _this = $(this);
- var res = rdata[$(this).attr('data-index')];
- layer.confirm('是否确定提交误报反馈?', { title: '误报反馈',closeBtn:2,icon:3}, function () {
- var url_address = res[3];
- var rule_arry = res[6].split(" >> ");
- var pdata = { url_rule: url_address };
- var loadT = layer.msg('正在添加URL白名单..', { icon: 16, time: 0 });
- $.post('/plugin?action=a&name=btwaf&s=add_url_white', pdata, function (rdata) {
- layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
- layer.close(loadT);
- if (rule_arry[1] != undefined){ $.get('https://www.bt.cn/Api/add_waf_logs?data=' + rule_arry[1],function(rdata){},'jsonp')}
- });
- });
- })
-
- // 详情
- $(".btwaf_details").click(function () {
- var res = rdata[$(this).attr('data-index')];
- var time = res[0]; //时间
- var ip_address = res[1]; //IP地址
- var req_type = res[2]; // 请求类型
- var url_address = res[3]; // 请求类型
- var user_agent = res[4]; // 请求类型
- var filters = res[5]; //过滤器
- var filter_rule = ''; //过滤规则
- var rule_arry = res[6].split(" >> ");
- var incoming_value = '',risk_value = ''; //传入值,风险值
- if(rule_arry.length == 0) filter_rule = rule_arry[0]
- incoming_value = rule_arry[1] == undefined?'空':rule_arry[1];
- risk_value = incoming_value.match(new RegExp(rule_arry[0].replace(/\//g,'\\/'),'i'));
- risk_value = risk_value?risk_value[0]:'空';
-
- layer.open({
- type: 1,
- title: time + "详情",
- area: '600px',
- closeBtn: 1,
- shadeClose: false,
- content: '\
-
\
-
URI地址
\
-
'+ escapeHTML(url_address) + '
\
-
User-Agent
\
-
'+ escapeHTML(user_agent) + '
\
-
过滤规则
\
-
'+ escapeHTML(rule_arry[0]) + '
\
-
传入值
\
-
'+ escapeHTML(incoming_value) + '
\
-
风险值
\
-
'+ escapeHTML(risk_value) + '
\
-
'
- })
- })
- $("#LogDayCon td").click(function () {
- $(this).parents("tr").addClass("active").siblings().removeClass("active");
- });
-
- });
-}
-
function html_encode(value) {
return $('').html(value).text();
}
@@ -1734,7 +1611,7 @@ function wafLogRequest(page){
shadeClose: false,
content: '\
\
- 时间 | '+ time + ' | 用户IP | ' + escapeHTML(ip) + ' |
---|
类型 | ' + escapeHTML(res.method) + ' | 过滤器 | ' + escapeHTML(res.rule_name) + ' |
---|
\
+
时间 | '+ time + ' | 用户IP | ' + escapeHTML(ip) + ' |
---|
类型 | ' + escapeHTML(res.method) + ' | 过滤器 | ' + escapeHTML(res.rule_name) + ' |
---|
\
URI地址
\
'+ escapeHTML(res.uri) + '
\
User-Agent
\
@@ -1777,7 +1654,15 @@ function wafLogs(){
// wafLogRequest(1);
$("#UncoverAll").click(function(){
- console.log("UncoverAll");
+ owPost('clean_drop_ip',{},function(data){
+ var rdata = $.parseJSON(data.data);
+ var ndata = $.parseJSON(rdata.data);
+ if (ndata.status == 0){
+ layer.msg("解封所有成功",{icon:1,time:2000,shade: [0.3, '#000']});
+ } else{
+ layer.msg("解封所有异常:"+ndata.msg,{icon:5,time:2000,shade: [0.3, '#000']});
+ }
+ });
});
diff --git a/plugins/op_waf/t/index.py b/plugins/op_waf/t/index.py
index 51f9459cb..19f76311d 100644
--- a/plugins/op_waf/t/index.py
+++ b/plugins/op_waf/t/index.py
@@ -309,16 +309,16 @@ def test_Upload():
def test_start():
# test_OK()
- # test_Dir()
+ test_Dir()
# test_UA()
# test_Header()
# test_UA_for(1000)
# test_POST()
# test_scan()
- # test_CC()
+ test_CC()
# test_url_ext()
# test_cdn()
- test_Upload()
+ # test_Upload()
if __name__ == "__main__":
diff --git a/plugins/op_waf/waf/lua/common.lua b/plugins/op_waf/waf/lua/common.lua
index ce5f6d05e..243e290cf 100644
--- a/plugins/op_waf/waf/lua/common.lua
+++ b/plugins/op_waf/waf/lua/common.lua
@@ -578,8 +578,8 @@ function _M.write_log(self, name, rule)
local reason = retry_cycle .. '秒以内累计超过'..retry..'次以上非法请求,封锁'.. lock_time ..'秒'
self:log(params, name, reason)
- -- else
- -- self:log(params, name, rule)
+ elseif name ~= 'cc' then
+ self:log(params, name, rule)
end
self:stats_total(name, rule)