From 1c0ac62b4f1283db844c94bc3bdb9c0ea841232f Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 30 Apr 2019 18:11:58 +0800 Subject: [PATCH] op --- plugins/op_waf/index.py | 86 +++++++++++++++++++++++++++++-- plugins/op_waf/js/op_waf.js | 94 ++++++++++++++++++++++++++++------ plugins/op_waf/waf/config.json | 2 +- 3 files changed, 160 insertions(+), 22 deletions(-) diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index 2cdf9d3ec..7f85db13f 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -96,12 +96,11 @@ def initSiteInfo(): site_contents = "{}" site_contents = json.loads(site_contents) - + site_contents_new = {} for x in range(len(domain_contents)): name = domain_contents[x]['name'] - if name in site_contents: - pass + site_contents_new[name] = site_contents[name] else: tmp = {} tmp['cdn'] = False @@ -109,15 +108,54 @@ def initSiteInfo(): tmp['get'] = True tmp['post'] = True tmp['open'] = False - site_contents[name] = tmp - cjson = public.getJson(site_contents) + data_cc = {} + data_cc['open'] = False + tmp['cc'] = data_cc + + site_contents_new[name] = tmp + + cjson = public.getJson(site_contents_new) public.writeFile(path_site, cjson) +def initTotalInfo(): + data = [] + path_domains = getJsonPath('domains') + path_total = getJsonPath('total') + + domain_contents = public.readFile(path_domains) + domain_contents = json.loads(domain_contents) + + try: + total_contents = public.readFile(path_total) + except Exception as e: + total_contents = "{}" + + total_contents = json.loads(total_contents) + total_contents_new = {} + for x in range(len(domain_contents)): + name = domain_contents[x]['name'] + if 'sites' in total_contents and name in total_contents['sites']: + pass + else: + tmp = {} + tmp['cdn'] = 0 + tmp['log'] = 0 + tmp['get'] = 0 + tmp['post'] = 0 + tmp['total'] = 0 + _name = {} + _name[name] = tmp + total_contents['sites'] = _name + + cjson = public.getJson(total_contents) + public.writeFile(path_total, cjson) + def status(): initDomainInfo() initSiteInfo() + initTotalInfo() path = getConf() if not os.path.exists(path): @@ -290,6 +328,42 @@ def saveScanRule(): return public.returnJson(True, '设置成功!', []) +def getSiteConfig(): + path = getJsonPath('site') + content = public.readFile(path) + + content = json.loads(content) + + total = getJsonPath('total') + total_content = public.readFile(total) + total_content = json.loads(total_content) + + # print total_content + + for x in content: + tmp = [] + tmp_v = {} + if 'sites' in total_content and x in total_content['sites']: + tmp_v = total_content['sites'][x]; + + key_list = ['get','post','user-agent','cookie','cdn','cc'] + for kx in range(len(key_list)): + ktmp = {} + + if kx in tmp_v : + ktmp['value'] = tmp_v[key_list[kx]] + else: + ktmp['value'] = 0 + ktmp['key'] = key_list[kx] + tmp.append(ktmp) + + # print tmp + content[x]['total'] = tmp + + + content = public.getJson(content) + return public.returnJson(True, 'ok!', content) + def setObjOpen(): args = getArgs() data = checkArgs(args, ['obj']) @@ -351,6 +425,8 @@ if __name__ == "__main__": print setSiteRetry() elif func == 'save_scan_rule': print saveScanRule() + elif func == 'get_site_config': + print getSiteConfig() elif func == 'waf_srceen': print getWafSrceen() elif func == 'waf_conf': diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js index df92aa5c7..eae323f1e 100755 --- a/plugins/op_waf/js/op_waf.js +++ b/plugins/op_waf/js/op_waf.js @@ -706,6 +706,7 @@ function urlBlack(type) { } + function wafScreen(){ owPost('waf_srceen', {}, function(data){ @@ -854,24 +855,85 @@ function wafGloabl(){ }); } +//返回css +function back_css(v) { + if (v > 0) { + return 'tipsval' + } + else { + return 'tipsval tipsvalnull' + } +} function wafSite(){ - var con = '
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
站点GETPOSTUACookieCDNCC状态操作
\ -
'; - $(".soft-man-con").html(con); + + owPost('get_site_config', {}, function(data){ + var tmp = $.parseJSON(data.data); + var rdata = $.parseJSON(tmp.data); + console.log(rdata); + + var tbody = ''; + var i = 0; + $.each(rdata, function (k, v) { + console.log(k,v); + i += 1; + tbody += '\ + ' + k + '\ + \ + ' + v.total[1].value + '\ + \ + \ + ' + v.total[0].value + '\ + \ + \ + ' + v.total[3].value + '\ + \ + \ + ' + v.total[4].value + '\ + \ + \ + \ + \ + \ + ' + v.total[2].value + '\ + \ + \ +
\ + \ + \ +
\ + \ + 日志 | 设置\ + ' + }); + + var con = '
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + '+ tbody + '\ +
站点GETPOSTUACookieCDNCC防御状态操作
\ +
\ +
\ +
\ +
'; + $(".soft-man-con").html(con); + tableFixed("siteCon_fix"); + }); } diff --git a/plugins/op_waf/waf/config.json b/plugins/op_waf/waf/config.json index 8ef61762c..18e38c53f 100755 --- a/plugins/op_waf/waf/config.json +++ b/plugins/op_waf/waf/config.json @@ -1 +1 @@ -{"reqfile_path": "/Users/midoks/Desktop/fwww/server/openresty/nginx/conf/waf/html", "retry": {"retry_time": "180", "is_open_global": "0", "retry": "6", "retry_cycle": "60"}, "log": true, "retry_cycle": 60, "scan": {"status": 444, "ps": "\u8fc7\u6ee4\u5e38\u89c1\u626b\u63cf\u6d4b\u8bd5\u5de5\u5177\u7684\u6e17\u900f\u6d4b\u8bd5", "open": true, "reqfile": ""}, "cc": {"status": 444, "ps": "\u8fc7\u8651CC\u653b\u51fb", "limit": 120, "endtime": 300, "open": true, "reqfile": "", "cycle": 60}, "body_character_string": [], "start_time": 1556095983.425878, "get": {"status": 403, "ps": "\u8fc7\u6ee4uri\u3001uri\u53c2\u6570\u4e2d\u5e38\u89c1sql\u6ce8\u5165\u3001xss\u7b49\u653b\u51fb", "open": true, "reqfile": "get.html"}, "body_regular": [], "log_save": 30, "user-agent": {"status": 403, "ps": "\u901a\u5e38\u7528\u4e8e\u8fc7\u6ee4\u6d4f\u89c8\u5668\u3001\u8718\u86db\u53ca\u4e00\u4e9b\u81ea\u52a8\u626b\u63cf\u5668", "open": true, "reqfile": "user_agent.html"}, "logs_path": "/www/wwwlogs/btwaf", "other": {"status": 403, "ps": "\u5176\u5b83\u975e\u901a\u7528\u8fc7\u6ee4", "reqfile": "other.html"}, "cookie": {"status": 403, "ps": "\u8fc7\u6ee4\u5229\u7528Cookie\u53d1\u8d77\u7684\u6e17\u900f\u653b\u51fb", "open": true, "reqfile": "cookie.html"}, "retry_time": 180, "post": {"status": 403, "ps": "\u8fc7\u6ee4POST\u53c2\u6570\u4e2d\u5e38\u89c1sql\u6ce8\u5165\u3001xss\u7b49\u653b\u51fb", "open": true, "reqfile": "post.html"}, "open": true} \ No newline at end of file +{"reqfile_path": "/Users/midoks/Desktop/fwww/server/openresty/nginx/conf/waf/html", "retry": {"retry_time": "180", "is_open_global": "0", "retry": "6", "retry_cycle": "60"}, "log": true, "retry_cycle": 60, "scan": {"status": 444, "ps": "\u8fc7\u6ee4\u5e38\u89c1\u626b\u63cf\u6d4b\u8bd5\u5de5\u5177\u7684\u6e17\u900f\u6d4b\u8bd5", "open": true, "reqfile": ""}, "cc": {"status": 444, "ps": "\u8fc7\u8651CC\u653b\u51fb", "limit": 120, "endtime": 300, "open": true, "reqfile": "", "cycle": 60}, "body_character_string": [], "start_time": 1556095983.425878, "get": {"status": 403, "ps": "\u8fc7\u6ee4uri\u3001uri\u53c2\u6570\u4e2d\u5e38\u89c1sql\u6ce8\u5165\u3001xss\u7b49\u653b\u51fb", "open": true, "reqfile": "get.html"}, "body_regular": [], "log_save": 30, "user-agent": {"status": 403, "ps": "\u901a\u5e38\u7528\u4e8e\u8fc7\u6ee4\u6d4f\u89c8\u5668\u3001\u8718\u86db\u53ca\u4e00\u4e9b\u81ea\u52a8\u626b\u63cf\u5668", "open": true, "reqfile": "user_agent.html"}, "retry_time": 180, "other": {"status": 403, "ps": "\u5176\u5b83\u975e\u901a\u7528\u8fc7\u6ee4", "reqfile": "other.html"}, "cookie": {"status": 403, "ps": "\u8fc7\u6ee4\u5229\u7528Cookie\u53d1\u8d77\u7684\u6e17\u900f\u653b\u51fb", "open": true, "reqfile": "cookie.html"}, "logs_path": "/www/wwwlogs/btwaf", "post": {"status": 403, "ps": "\u8fc7\u6ee4POST\u53c2\u6570\u4e2d\u5e38\u89c1sql\u6ce8\u5165\u3001xss\u7b49\u653b\u51fb", "open": true, "reqfile": "post.html"}, "open": true} \ No newline at end of file