1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| import os import xlwt import json
book = xlwt.Workbook(encoding='GBK',style_compression=0) sheet = book.add_sheet('XX', cell_overwrite_ok=True) sheet.write(0, 0, '所属集群') sheet.write(0, 1, '系统名称') sheet.write(0, 2, '请求白名单') sheet.write(0, 3, '响应白名单') sheet.write(0, 4, 'WAF白名单') sheet.write(0, 5, '封装名单') sheet.write(0, 6, '验证名单') sheet.write(0, 7, 'websocket路径') sheet.write(0, 8, '配置文件名称') sheet.write(0, 9, '是否防护') sheet.write(0, 10, '后端服务器') sheet.write(0, 11, '是否https协议') sheet.write(0, 12, 'IP白名单') sheet.write(0, 13, 'IP黑名单') sheet.write(0, 14, '是否关闭测试页面') sheet.write(0, 15, 'reload状态码') sheet.write(0, 16, 'WAF是否监控') sheet.write(0, 17, 'RAS版本') sheet.write(0, 18, 'RAS指纹') sheet.write(0, 19, 'IP保护模式') sheet.write(0, 20, 'IP白名单个数') sheet.write(0, 21, 'IP黑名单个数') sheet.write(0, 22, '请求白名单个数') sheet.write(0, 23, '响应白名单个数') sheet.write(0, 24, 'WAF白名单个数') sheet.write(0, 25, 'websocket路径个数') sheet.write(0, 26, '自动化工具拦截') sheet.write(0, 27, '破解行为拦截') sheet.write(0, 28, 'WAF模块') sheet.write(0, 29, 'App防护') sheet.write(0, 30, 'web标准保护') sheet.write(0, 31, 'web高级保护') sheet.write(0, 32, '命令执行') sheet.write(0, 33, '文件上传') sheet.write(0, 34, 'java反序列化') sheet.write(0, 35, '本地文件包含') sheet.write(0, 36, 'php注入') sheet.write(0, 37, '协议攻击') sheet.write(0, 38, '远程文件包含') sheet.write(0, 39, '扫描探测') sheet.write(0, 40, '固定会话') sheet.write(0, 41, 'SQL注入') sheet.write(0, 42, 'XSS')
with open('XX.json','r') as f: data = json.load(f)
n = 1 usefuldata=data['system_settings']['_value']['nginx']['upstreams'] ip_black=data['system_settings']['_value']['ip_black']['value']['_value'] sphinx_version=data['sphinx_version']['_value'] certFp=data['system_settings']['_value']['cluster']['mobile']['certFp']['_value'] if 'certFp' in data['system_settings']['_value']['cluster']['mobile'] else ""
for list_item in usefuldata: protect_list=usefuldata[list_item]['protected_list']['_value'] EncapsulationListOut=usefuldata[list_item]['EncapsulationListOut']['_value'] FullWhiteList=usefuldata[list_item]['FullWhiteList']['_value'] FullWhiteListOut=usefuldata[list_item]['FullWhiteListOut']['_value'] Inject_Whitelist=usefuldata[list_item]['Inject_Whitelist']['_value'] VerificationList=usefuldata[list_item]['VerificationList']['_value'] WafEnabledModules=usefuldata[list_item]['WafEnabledModules']['_value'] if 'WafEnabledModules' in usefuldata[list_item] else {} site_customize_name=usefuldata[list_item]['site_customize_name']['_value'] websocket_paths=usefuldata[list_item]['websocket_paths']['_value'] if 'websocket_paths' in usefuldata[list_item] else "" istrue=usefuldata[list_item]['enabled']['_value'] UpstreamList=usefuldata[list_item]['UpstreamList']['_value'] IsUpstreamHttps=usefuldata[list_item]['IsUpstreamHttps']['_value'] IpWhiteList=usefuldata[list_item]['IpWhiteList']['_value'] disable_123456=usefuldata[list_item]['disable_123456']['_value'] if 'disable_123456' in usefuldata[list_item] else "" reload_status_code=usefuldata[list_item]['reload_status_code']['_value'] if 'reload_status_code' in usefuldata[list_item] else "" waf_learning_mode=usefuldata[list_item]['waf_learning_mode']['_value'] IpListSwitch=usefuldata[list_item]['IpListSwitch']['_value'] len_IpWhiteList=len(IpWhiteList) len_ip_black=len(ip_black) len_FullWhiteList=len(FullWhiteList) len_FullWhiteListOut=len(FullWhiteListOut) len_Inject_Whitelist=len(Inject_Whitelist) len_websocket_paths=len(websocket_paths) automated_tool_intercept=protect_list['automated_tool_intercept'] crack_behavior_interception=protect_list['crack_behavior_interception'] injection_attack_interception=protect_list['injection_attack_interception'] mobile_sdk_protection=protect_list['mobile_sdk_protection'] web_standard_protection=protect_list['web_standard_protection'] web_advanced_protection=protect_list['web_advanced_protection'] command_excute_interception=WafEnabledModules['command_excute_interception'] if 'command_excute_interception' in WafEnabledModules else "" file_upload_interception=WafEnabledModules['file_upload_interception'] if 'file_upload_interception' in WafEnabledModules else "" java_deserialization_interception=WafEnabledModules['java_deserialization_interception'] if 'java_deserialization_interception' in WafEnabledModules else "" local_file_include_interception=WafEnabledModules['local_file_include_interception'] if 'local_file_include_interception' in WafEnabledModules else "" php_injection_interception=WafEnabledModules['php_injection_interception'] if 'php_injection_interception' in WafEnabledModules else "" protocol_attack_interception=WafEnabledModules['protocol_attack_interception'] if 'protocol_attack_interception' in WafEnabledModules else "" remote_file_include_interception=WafEnabledModules['remote_file_include_interception'] if 'remote_file_include_interception' in WafEnabledModules else "" scanner_detect_interception=WafEnabledModules['scanner_detect_interception'] if 'scanner_detect_interception' in WafEnabledModules else "" session_fixation_interception=WafEnabledModules['session_fixation_interception'] if 'session_fixation_interception' in WafEnabledModules else "" sql_injection_interception=WafEnabledModules['sql_injection_interception'] if 'sql_injection_interception' in WafEnabledModules else "" xss_injection_interception=WafEnabledModules['xss_injection_interception'] if 'xss_injection_interception' in WafEnabledModules else ""
sheet.write(n,0,'XX') sheet.write(n,1,str(site_customize_name)) sheet.write(n,2,str(FullWhiteList)) sheet.write(n,3,str(FullWhiteListOut)) sheet.write(n,4,str(Inject_Whitelist)) sheet.write(n,5,str(EncapsulationListOut)) sheet.write(n,6,str(VerificationList)) sheet.write(n,7,str(websocket_paths)) sheet.write(n,8,str(list_item)) sheet.write(n,9,str(istrue)) sheet.write(n,10,str(UpstreamList)) sheet.write(n,11,str(IsUpstreamHttps)) sheet.write(n,12,str(IpWhiteList)) sheet.write(n,13,str(ip_black)) sheet.write(n,14,str(disable_123456)) sheet.write(n,15,str(reload_status_code)) sheet.write(n,16,str(waf_learning_mode)) sheet.write(n,17,str(sphinx_version)) sheet.write(n,18,str(certFp)) sheet.write(n,19,str(IpListSwitch)) sheet.write(n,20,str(len_IpWhiteList)) sheet.write(n,21,str(len_ip_black)) sheet.write(n,22,str(len_FullWhiteList)) sheet.write(n,23,str(len_FullWhiteListOut)) sheet.write(n,24,str(len_Inject_Whitelist)) sheet.write(n,25,str(len_websocket_paths)) sheet.write(n,26,str(automated_tool_intercept)) sheet.write(n,27,str(crack_behavior_interception)) sheet.write(n,28,str(injection_attack_interception)) sheet.write(n,29,str(mobile_sdk_protection)) sheet.write(n,30,str(web_standard_protection)) sheet.write(n,31,str(web_advanced_protection)) sheet.write(n,32,str(command_excute_interception)) sheet.write(n,33,str(file_upload_interception)) sheet.write(n,34,str(java_deserialization_interception)) sheet.write(n,35,str(local_file_include_interception)) sheet.write(n,36,str(php_injection_interception)) sheet.write(n,37,str(protocol_attack_interception)) sheet.write(n,38,str(remote_file_include_interception)) sheet.write(n,39,str(scanner_detect_interception)) sheet.write(n,40,str(session_fixation_interception)) sheet.write(n,41,str(sql_injection_interception)) sheet.write(n,42,str(xss_injection_interception))
n=n+1
book.save('XX.xls')
|