diff --git a/BTPanel/__init__.py b/BTPanel/__init__.py index a7c51c19..a01c9269 100644 --- a/BTPanel/__init__.py +++ b/BTPanel/__init__.py @@ -80,7 +80,7 @@ admin_path_file = 'data/admin_path.pl' admin_path = '/' if os.path.exists(admin_path_file): admin_path = public.readFile(admin_path_file).strip() -admin_path_checks = ['/','/close','/task','/login','/config','/site','/sites','ftp','/public','/database','/data','/download_file','/control','/crontab','/firewall','/files','config','/soft','/ajax','/system','/panel_data','/code','/ssl','/plugin','/wxapp','/hook','/safe','/yield','/downloadApi','/pluginApi','/auth','/download','/cloud','/webssh','/connect_event','/panel'] +admin_path_checks = ['/','/san','/monitor','/abnormal','/close','/task','/login','/config','/site','/sites','ftp','/public','/database','/data','/download_file','/control','/crontab','/firewall','/files','config','/soft','/ajax','/system','/panel_data','/code','/ssl','/plugin','/wxapp','/hook','/safe','/yield','/downloadApi','/pluginApi','/auth','/download','/cloud','/webssh','/connect_event','/panel'] if admin_path in admin_path_checks: admin_path = '/bt' @app.route('/service_status',methods = method_get) @@ -322,7 +322,7 @@ def panel_monitor(pdata=None): if comReturn: return comReturn import monitor dataObject = monitor.Monitor() - defs = ('get_access_ip', 'get_exception', 'get_exception_logs', 'get_attack_nums', 'php_count', 'return_php', 'mysql_client_count') + defs = ('get_spider', 'get_exception', 'get_request_count_qps', 'load_and_up_flow', 'get_request_count_by_hour') return publicObject(dataObject, defs, None, pdata) @@ -334,15 +334,15 @@ def san_baseline(pdata=None): dataObject = san_baseline.san_baseline() defs = ('start', 'get_api_log', 'get_resut', 'get_ssh_errorlogin') return publicObject(dataObject, defs, None, pdata) - - + + @app.route('/abnormal', methods=method_all) def abnormal(pdata=None): comReturn = comm.local() if comReturn: return comReturn import abnormal dataObject = abnormal.abnormal() - defs = ( 'mysql_server', 'mysql_cpu', 'mysql_count', 'php_server', 'php_conn_max', 'php_cpu', 'CPU', 'Memory', 'disk', 'not_root_user','start') + defs = ('mysql_server', 'mysql_cpu', 'mysql_count', 'php_server', 'php_conn_max', 'php_cpu', 'CPU', 'Memory', 'disk', 'not_root_user', 'start') return publicObject(dataObject, defs, None, pdata) @app.route('/files',methods=method_all) @@ -514,7 +514,7 @@ def plugin(pdata = None): def panel_public(): get = get_input(); get.client_ip = public.GetClientIp(); - + if not public.path_safe_check("%s/%s" % (get.name,get.fun)): return abort(404) if get.fun in ['scan_login','login_qrcode','set_login','is_scan_ok','blind']: #检查是否验证过安全入口 if get.fun in ['login_qrcode','is_scan_ok']: @@ -530,7 +530,6 @@ def panel_public(): import panelPlugin plu = panelPlugin.panelPlugin() get.s = '_check'; - checks = plu.a(get) if type(checks) != bool or not checks: return public.getJson(checks),json_header get.s = get.fun @@ -548,30 +547,6 @@ def send_favicon(): return send_file(s_file,conditional=True,add_etags=True) -@socketio.on('coll_socket') -def coll_socket(msg): - coll_path = '/www/server/panel/plugin/coll' - if not os.path.exists(coll_path): - emit('coll_response',{'data':'未安装宝塔群控主控端!'}) - return; - if type(msg) == str or not 'f' in msg: - emit('coll_response',{'data':'参数错误!'}) - return; - sys.path.insert(0,coll_path) - from inc import coll_terminal - try: - if sys.version_info[0] == 2: - reload(coll_terminal) - else: - from imp import reload - reload(coll_terminal) - except:pass - t = coll_terminal.coll_terminal() - if not hasattr(t,msg['f']): - emit('coll_response',{'data':'指定方法不存在!'}) - return; - emit('coll_response',getattr(t,msg['f'])(msg)) - @app.route('/coll',methods=method_all) @app.route('/coll/',methods=method_all) @app.route('//',methods=method_all) @@ -589,10 +564,12 @@ def panel_other(name=None,fun = None,stype=None): #前置准备 if not name: name = 'coll' + if not public.path_safe_check("%s/%s/%s" % (name,fun,stype)): return abort(404) #是否响应面板默认静态文件 if name == 'static': s_file = '/www/server/panel/BTPanel/static/' + fun + '/' + stype + if s_file.find('..') != -1 or s_file.find('./') != -1: return abort(404) if not os.path.exists(s_file): return abort(404) return send_file(s_file,conditional=True,add_etags=True) @@ -606,6 +583,7 @@ def panel_other(name=None,fun = None,stype=None): if fun == 'static': if stype.find('./') != -1 or not os.path.exists(p_path + '/static'): return public.returnJson(False,'错误的请求!'),json_header s_file = p_path + '/static/' + stype + if s_file.find('..') != -1: return abort(404) if not os.path.exists(s_file): return public.returnJson(False,'指定文件不存在['+stype+']'),json_header return send_file(s_file,conditional=True,add_etags=True) @@ -778,44 +756,6 @@ def check_token(data): if result['token'] != token: return False; return result; -@app.route('/yield',methods=method_all) -def panel_yield(): - get = get_input() - import panelPlugin - plu = panelPlugin.panelPlugin() - get.s = '_check'; - get.client_ip = public.GetClientIp() - checks = plu.a(get) - if type(checks) != bool or not checks: return - get.s = get.fun - filename = plu.a(get); - mimetype = 'application/octet-stream' - return send_file(filename,mimetype=mimetype, as_attachment=True,attachment_filename=os.path.basename(filename)) - -@app.route('/downloadApi',methods=method_all) -def panel_downloadApi(): - get = get_input() - if not public.checkToken(get): get.filename = str(time.time()); - filename = 'plugin/psync/backup/' + get.filename.encode('utf-8'); - mimetype = 'application/octet-stream' - return send_file(filename,mimetype=mimetype, as_attachment=True,attachment_filename=os.path.basename(filename)) - - -@app.route('/pluginApi',methods=method_all) -def panel_pluginApi(): - get = get_input() - if not public.checkToken(get): return public.returnJson(False,'INIT_TOKEN_ERR'); - infoFile = 'plugin/' + get.name + '/info.json'; - if not os.path.exists(infoFile): return False; - import json - info = json.loads(public.readFile(infoFile)); - if not info['api']: return public.returnJson(False,'INIT_PLU_ACC_ERR'); - - import panelPlugin - pluginObject = panelPlugin.panelPlugin() - - defs = ('install','unInstall','getPluginList','getPluginInfo','getPluginStatus','setPluginStatus','a','getCloudPlugin','getConfigHtml','savePluginSort') - return publicObject(pluginObject,defs); @app.route('/auth',methods=method_all) def auth(pdata = None): @@ -875,6 +815,11 @@ def panel_cloud(): except: public.ExecShell('pip install paramiko==2.0.2 &') +@socketio.on('connect') +def socket_connect(msg=None): + if not check_login(): + raise emit('server_response',{'data':public.getMsg('INIT_WEBSSH_LOGOUT')}) + @socketio.on('webssh') def webssh(msg): if not check_login(msg['x_http_token']): diff --git a/BTPanel/static/img/dep_ico/empirecms.png b/BTPanel/static/img/dep_ico/empirecms.png new file mode 100644 index 00000000..aaa29eb1 Binary files /dev/null and b/BTPanel/static/img/dep_ico/empirecms.png differ diff --git a/BTPanel/static/js/config.js b/BTPanel/static/js/config.js index 6e962e5a..a48b8cf9 100644 --- a/BTPanel/static/js/config.js +++ b/BTPanel/static/js/config.js @@ -468,7 +468,7 @@ function GetPanelApi() {
\ 接口密钥\
\ - \ + \ \
\
\ diff --git a/class/config.py b/class/config.py index 8b5127c9..f269937c 100644 --- a/class/config.py +++ b/class/config.py @@ -421,6 +421,9 @@ def SetPanelSSL(self,get): os.system('rm -f ' + sslConf); return public.returnMsg(True,'PANEL_SSL_CLOSE'); else: + os.system('pip install cffi'); + os.system('pip install cryptography'); + os.system('pip install pyOpenSSL'); try: if not self.CreateSSL(): return public.returnMsg(False,'PANEL_SSL_ERR'); public.writeFile(sslConf,'True') diff --git a/class/database.py b/class/database.py index c74e08f7..9ed46799 100644 --- a/class/database.py +++ b/class/database.py @@ -391,7 +391,7 @@ def ToBackup(self,get): fileName = name + '_' + time.strftime('%Y%m%d_%H%M%S',time.localtime()) + '.sql.gz' backupName = session['config']['backup_path'] + '/database/' + fileName - public.ExecShell("/www/server/mysql/bin/mysqldump --force --opt \"" + name + "\" | gzip > " + backupName) + public.ExecShell("/www/server/mysql/bin/mysqldump --default-character-set="+ public.get_database_character(name) +" --force --opt \"" + name + "\" | gzip > " + backupName) if not os.path.exists(backupName): return public.returnMsg(False,'BACKUP_ERROR'); self.mypass(False, root); diff --git a/class/monitor.py b/class/monitor.py index 3f581d90..e17960f4 100644 --- a/class/monitor.py +++ b/class/monitor.py @@ -207,7 +207,7 @@ def get_request_count_qps(self, args): ntime = time.time() new_total_request = self._get_request_count(args) - qps = int(round(float(new_total_request - old_total_request) / (ntime - otime))) + qps = float(new_total_request - old_total_request) / (ntime - otime) cache.set('old_total_request', new_total_request, cache_timeout) cache.set('old_get_time', ntime, cache_timeout) diff --git a/class/panelDnsapi.py b/class/panelDnsapi.py index 63effd13..ce852c4f 100644 --- a/class/panelDnsapi.py +++ b/class/panelDnsapi.py @@ -283,6 +283,8 @@ def create_dns_record(self, domain_name, domain_dns_value): if result == "False": raise ValueError('[DNS]当前绑定的宝塔DNS云解析账户里面不存在这个域名,添加解析失败!') print("[DNS]TXT记录创建成功") + print("[DNS]尝试验证TXT记录") + time.sleep(10) def delete_dns_record(self, domain_name, domain_dns_value): root, _, acme_txt = self.extract_zone(domain_name) diff --git a/class/panelLets.py b/class/panelLets.py index 9603c068..8978895e 100644 --- a/class/panelLets.py +++ b/class/panelLets.py @@ -12,8 +12,18 @@ sys.path.append("class/") import requests,sewer,public from OpenSSL import crypto -requests.packages.urllib3.disable_warnings() +try: + requests.packages.urllib3.disable_warnings() +except:pass import BTPanel +try: + import dns.resolver +except: + os.system("pip install dnspython") + try: + import dns.resolver + except: + pass class panelLets: let_url = "https://acme-v02.api.letsencrypt.org/directory" @@ -83,6 +93,9 @@ def get_error(self,error): return '

签发失败,您今天尝试申请证书的次数已达上限!

' elif "DNS problem: NXDOMAIN looking up A for" in error or "No valid IP addresses found for" in error or "Invalid response from" in error: return '

签发失败,域名解析错误,或解析未生效,或域名未备案!

' + elif error.find('TLS Web Server Authentication') != -1: + public.restart_panel() + return "连接CA服务器失败,请稍候重试." else: return error; @@ -90,6 +103,7 @@ def get_error(self,error): def get_dns_class(self,data): if data['dnsapi'] == 'dns_ali': import panelDnsapi + public.mod_reload(panelDnsapi) dns_class = panelDnsapi.AliyunDns(key = data['dns_param'][0], secret = data['dns_param'][1]) return dns_class elif data['dnsapi'] == 'dns_dp': @@ -97,12 +111,14 @@ def get_dns_class(self,data): return dns_class elif data['dnsapi'] == 'dns_cx': import panelDnsapi + public.mod_reload(panelDnsapi) dns_class = panelDnsapi.CloudxnsDns(key = data['dns_param'][0] ,secret =data['dns_param'][1]) result = dns_class.get_domain_list() if result['code'] == 1: return dns_class elif data['dnsapi'] == 'dns_bt': import panelDnsapi + public.mod_reload(panelDnsapi) dns_class = panelDnsapi.Dns_com() return dns_class return False @@ -138,7 +154,9 @@ def renew_lest_cert(self,data): pfx_buffer = p12.export() public.writeFile(path + "/fullchain.pfx",pfx_buffer,'wb+') - return public.returnMsg(True, '[%s]证书续签成功.' % data['siteName']) + return public.returnMsg(True, '[%s]证书续签成功.' % data['siteName']) + + #申请证书 def apple_lest_cert(self,get): @@ -189,10 +207,11 @@ def apple_lest_cert(self,get): else: #手动解析提前返回 result = self.crate_let_by_oper(data) - public.writeFile(domain_path, json.dumps(result)) - result['code'] = 2 + if 'status' in result and not result['status']: return result result['status'] = True - result['msg'] = '获取成功,请手动解析域名' + public.writeFile(domain_path, json.dumps(result)) + result['msg'] = '获取成功,请手动解析域名' + result['code'] = 2; return result elif get.dnsapi == 'dns_bt': data['dnsapi'] = get.dnsapi @@ -270,7 +289,7 @@ def crate_let_by_oper(self,data): acme_keyauthorization, domain_dns_value = BTPanel.dns_client.get_keyauthorization(dns_token) acme_name = self.get_acme_name(dns_name) - dns_names_to_delete.append({"dns_name": dns_name,"acme_name":acme_name, "domain_dns_value": domain_dns_value}) + dns_names_to_delete.append({"dns_name": public.de_punycode(dns_name),"acme_name":acme_name, "domain_dns_value": domain_dns_value}) responders.append( { "authorization_url": authorization_url, @@ -317,8 +336,8 @@ def crate_let_by_oper(self,data): return result #dns验证 - def crate_let_by_dns(self,data): - dns_class = self.get_dns_class(data) + def crate_let_by_dns(self,data): + dns_class = self.get_dns_class(data) if not dns_class: return public.returnMsg(False, 'DNS连接失败,请检查密钥是否正确.') @@ -344,16 +363,24 @@ def crate_let_by_dns(self,data): dns_challenge_url = identifier_auth["dns_challenge_url"] acme_keyauthorization, domain_dns_value = client.get_keyauthorization(dns_token) - dns_class.create_dns_record(dns_name, domain_dns_value) - dns_names_to_delete.append({"dns_name": dns_name, "domain_dns_value": domain_dns_value}) + dns_class.create_dns_record(public.de_punycode(dns_name), domain_dns_value) + self.check_dns(self.get_acme_name(dns_name),domain_dns_value) + dns_names_to_delete.append({"dns_name": public.de_punycode(dns_name), "domain_dns_value": domain_dns_value}) responders.append({"authorization_url": authorization_url, "acme_keyauthorization": acme_keyauthorization,"dns_challenge_url": dns_challenge_url} ) - for i in responders: - auth_status_response = client.check_authorization_status(i["authorization_url"]) - r_data = auth_status_response.json() - if r_data["status"] == "pending": - client.respond_to_challenge(i["acme_keyauthorization"], i["dns_challenge_url"]) - - for i in responders: client.check_authorization_status(i["authorization_url"], ["valid"]) + n = 0 + while n<2: + print("第",n+1,"次验证") + try: + for i in responders: + auth_status_response = client.check_authorization_status(i["authorization_url"]) + r_data = auth_status_response.json() + if r_data["status"] == "pending": + client.respond_to_challenge(i["acme_keyauthorization"], i["dns_challenge_url"]) + + for i in responders: client.check_authorization_status(i["authorization_url"], ["valid"]) + break + except: + n+=1 certificate_url = client.send_csr(finalize_url) certificate = client.download_certificate(certificate_url) @@ -364,6 +391,7 @@ def crate_let_by_dns(self,data): result['key'] = client.certificate_key result['account_key'] = client.account_key result['status'] = True + except Exception as e: print(public.get_error_info()) raise e @@ -382,6 +410,7 @@ def crate_let_by_dns(self,data): def crate_let_by_file(self,data): result = {} result['status'] = False + result['clecks'] = [] try: log_level = "INFO" if data['account_key']: log_level = 'ERROR' @@ -408,9 +437,22 @@ def crate_let_by_file(self,data): wellknown_path = acme_dir + '/' + http_token public.writeFile(wellknown_path,acme_keyauthorization) wellknown_url = "http://{0}/.well-known/acme-challenge/{1}".format(http_name, http_token) - - retkey = public.httpGet(wellknown_url) - if retkey == acme_keyauthorization: + + result['clecks'].append({'wellknown_url':wellknown_url,'http_token':http_token}); + is_check = False + n = 0 + while n < 5: + print("wait_check_authorization_status") + try: + retkey = public.httpGet(wellknown_url,20) + if retkey == acme_keyauthorization: + is_check = True + break; + except : + pass + n += 1; + time.sleep(1) + if is_check: sucess_domains.append(http_name) responders.append({"authorization_url": authorization_url, "acme_keyauthorization": acme_keyauthorization,"http_challenge_url": http_challenge_url}) @@ -439,7 +481,7 @@ def crate_let_by_file(self,data): else: result['msg'] = "签发失败,我们无法验证您的域名:

1、检查域名是否绑定到对应站点

2、检查域名是否正确解析到本服务器,或解析还未完全生效

3、如果您的站点设置了反向代理,或使用了CDN,请先将其关闭

4、如果您的站点设置了301重定向,请先将其关闭

5、如果以上检查都确认没有问题,请尝试更换DNS服务商

'" except Exception as e: - result['msg'] = self.get_error(str(e)) + result['msg'] = self.get_error(str(e)) return result @@ -469,6 +511,29 @@ def get_identifier_authorization(self,client, url): "http_challenge_url": http_challenge_url, } return identifier_auth + + #检查DNS记录 + def check_dns(self,domain,value,type='TXT'): + time.sleep(5) + n = 0 + while n < 10: + try: + import dns.resolver + ns = dns.resolver.query(domain,type) + for j in ns.response.answer: + for i in j.items: + txt_value = i.to_text().replace('"','').strip() + if txt_value == value: + print("验证成功:%s" % txt_value) + return True + except: + try: + import dns.resolver + except: + return False + n+=1 + time.sleep(5) + return True #获取证书哈希 def get_cert_data(self,path): diff --git a/class/panelMysql.py b/class/panelMysql.py index 838f41da..2296943d 100644 --- a/class/panelMysql.py +++ b/class/panelMysql.py @@ -88,7 +88,10 @@ def query(self,sql): self.__DB_CUR.execute(sql) result = self.__DB_CUR.fetchall() #将元组转换成列表 - data = map(list,result) + if sys.version_info[0] == 2: + data = map(list,result) + else: + data = list(map(list,result)) self.__Close() return data except Exception as ex: diff --git a/class/panelPlugin.py b/class/panelPlugin.py index 835f4292..14af85b9 100644 --- a/class/panelPlugin.py +++ b/class/panelPlugin.py @@ -1552,6 +1552,7 @@ def get_title_byname(self,get): def a(self,get): if not hasattr(get,'name'): return public.returnMsg(False,'PLUGIN_INPUT_A'); try: + if not public.path_safe_check("%s/%s" % (get.name,get.s)): return public.returnMsg(False,'PLUGIN_INPUT_C'); path = self.__install_path + '/' + get.name if not os.path.exists(path + '/'+get.name+'_main.py'): return public.returnMsg(False,'PLUGIN_INPUT_B'); if not self.check_accept(get):return public.returnMsg(False,public.to_string([24744, 26410, 36141, 20080, 91, 37, 115, 93, 25110, 25480, 26435, 24050, 21040, 26399, 33]) % (self.get_title_byname(get),)) diff --git a/class/panelSite.py b/class/panelSite.py index 921e9b1c..01761e1b 100644 --- a/class/panelSite.py +++ b/class/panelSite.py @@ -884,6 +884,7 @@ def CreateLet(self,get): self.check_ssl_pack() import panelLets + public.mod_reload(panelLets) lets = panelLets.panelLets() result = lets.apple_lest_cert(get) if result['status'] and not 'code' in result: diff --git a/class/plugin_deployment.py b/class/plugin_deployment.py index 0766e09c..f69a2c08 100644 --- a/class/plugin_deployment.py +++ b/class/plugin_deployment.py @@ -70,9 +70,10 @@ def GetList(self,get): def get_icon(self,pinfo): path = '/www/server/panel/BTPanel/static/img/dep_ico' if not os.path.exists(path): os.makedirs(path,384) - filename = path + '/' + pinfo['name'] + '.png' + filename = "%s/%s.png" % (path, pinfo['name']) m_uri = pinfo['min_image'] - pinfo['min_image'] = '/static/img/dep_ico/' + pinfo['name'] + '.png' + pinfo['min_image'] = '/static/img/dep_ico/%s.png' % pinfo['name'] + if sys.version_info[0] == 2: filename = filename.encode('utf-8') if os.path.exists(filename): if os.path.getsize(filename) > 100: return pinfo os.system("wget -O " + filename + ' http://www.bt.cn' + m_uri + " &") diff --git a/class/public.py b/class/public.py index 118d995a..b9e0f0b0 100644 --- a/class/public.py +++ b/class/public.py @@ -1264,3 +1264,46 @@ def set_own(filename,user,group=None): group = user_info.pw_gid os.chown(filename,user,group) return True + +#校验路径安全 +def path_safe_check(path): + checks = ['..','./','\\','%','$','^','&','*','~','@','#'] + for c in checks: + if path.find(c) != -1: return False + rep = "^[\w\s\.\/-]+$" + if not re.match(rep,path): return False + return True + +#取数据库字符集 +def get_database_character(db_name): + try: + import panelMysql + tmp = panelMysql.panelMysql().query("show create database `%s`" % db_name.strip()) + return str(re.findall("SET\s+(.+)\s",tmp[0][1])[0]) + except: + return 'utf8' + +def en_punycode(domain): + tmp = domain.split('.'); + newdomain = ''; + for dkey in tmp: + #匹配非ascii字符 + match = re.search(u"[\x80-\xff]+",dkey); + if not match: match = re.search(u"[\u4e00-\u9fa5]+",dkey); + if not match: + newdomain += dkey + '.'; + else: + newdomain += 'xn--' + dkey.encode('punycode').decode('utf-8') + '.' + return newdomain[0:-1]; + +#punycode 转中文 +def de_punycode(domain): + tmp = domain.split('.'); + newdomain = ''; + for dkey in tmp: + if dkey.find('xn--') >=0: + newdomain += dkey.replace('xn--','').encode('utf-8').decode('punycode') + '.' + else: + newdomain += dkey + '.' + return newdomain[0:-1]; + diff --git a/class/san_baseline.py b/class/san_baseline.py index 4e386723..2fc31185 100644 --- a/class/san_baseline.py +++ b/class/san_baseline.py @@ -1196,36 +1196,53 @@ def start(self, get): # 取爆破 def get_ssh_errorlogin(self, get): + import datetime path = '/var/log/secure' if not os.path.exists(path): public.writeFile(path, ''); fp = open(path, 'r'); l = fp.readline(); data = {}; data['intrusion'] = []; - data['intrusion_total'] = 0; + # data['intrusion_total'] = 0; data['defense'] = []; data['defense_total'] = 0; data['success'] = []; data['success_total'] = 0; - - limit = 100; - while l: + day_count = 0 + data['intrusion_total'] = day_count + limit = 10000; + flag_limit = 1 + while l and flag_limit <= 10000: if l.find('Failed password for root') != -1: + flag_limit += 1 if len(data['intrusion']) > limit: del (data['intrusion'][0]); + + months = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'} + time_str11 = re.findall(r'\w+\s+\d+\s+.\d+:\d+:\d+', l) + if time_str11[0]: + time_str = re.findall(r'\w+\s+\d+', time_str11[0]) + month = int(months[time_str[0].split()[0]]) + day = int(time_str[0].split()[1]) + cur_month = datetime.datetime.now().month + cur_day = datetime.datetime.now().day + if month != cur_month: + continue + else: + if month == cur_month and day == cur_day: + day_count+=1 + else: + continue + #data['intrusion'].append(l); - data['intrusion_total'] += 1; + #data['intrusion_total'] += 1; elif l.find('Accepted') != -1: if len(data['success']) > limit: del (data['success'][0]); data['success'].append(l); - data['success_total'] += 1; - # elif l.find('refused') != -1: - # if len(data['defense']) > limit: del (data['defense'][0]); - # data['defense'].append(l); - # data['defense_total'] += 1; + # data['success_total'] += 1; l = fp.readline(); - + data['intrusion_total'] = day_count months = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'} success = []; diff --git a/class/sewer/client.py b/class/sewer/client.py index f7dd0083..6ebcbd9e 100644 --- a/class/sewer/client.py +++ b/class/sewer/client.py @@ -13,7 +13,9 @@ from . import __version__ as sewer_version from .config import ACME_DIRECTORY_URL_PRODUCTION -requests.packages.urllib3.disable_warnings() +try: + requests.packages.urllib3.disable_warnings() +except:pass class Client(object): diff --git a/script/backup.py b/script/backup.py index cec2a265..c732a37b 100644 --- a/script/backup.py +++ b/script/backup.py @@ -92,7 +92,7 @@ def backupDatabase(self,name,count): if len(mycnf) > 100: public.writeFile('/etc/my.cnf',mycnf); - public.ExecShell("/www/server/mysql/bin/mysqldump --force --opt " + name + " | gzip > " + filename) + public.ExecShell("/www/server/mysql/bin/mysqldump --default-character-set="+ public.get_database_character(name) +" --force --opt " + name + " | gzip > " + filename) if not os.path.exists(filename): endDate = time.strftime('%Y/%m/%d %X',time.localtime())