Skip to content

Commit eb2e13f

Browse files
committed
v6.7.6
update log: 1.Optimize the thread safety of sqlite module. 2.Enhanced data protection inside the panel. 3.Enhanced panel input verification. 4.After adjusting the anti-cross-site, it will no longer allow access to /proc/. 5.Adjust the panel password to force salt. 6.User name will be encrypted when adjusting login panel. 7.Other details adjustment.
1 parent 5949d76 commit eb2e13f

17 files changed

+746
-159
lines changed

BTPanel/__init__.py

+56-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import public
1919
from flask import Flask,current_app,session,render_template,send_file,request,redirect,g,url_for,make_response,render_template_string,abort
2020
from flask_session import Session
21-
2221
try:
2322
from werkzeug.contrib.cache import SimpleCache
2423
except:
@@ -33,7 +32,6 @@
3332
Compress(app)
3433
sockets = Sockets(app)
3534

36-
3735
import common
3836
import db
3937
import jobs
@@ -150,7 +148,7 @@
150148
]
151149
if admin_path in admin_path_checks: admin_path = '/bt'
152150

153-
@app.route('/service_status',methods = method_get)
151+
@app.route('/service_status',methods = method_all)
154152
def service_status():
155153
return 'True'
156154

@@ -176,7 +174,7 @@ def webssh(ws):
176174
session['ssh_obj'].run(ws,session['ssh_info'])
177175

178176

179-
@app.route('/term_open',methods=method_all)
177+
@app.route('/term_open',methods=method_get)
180178
def term_open():
181179
comReturn = comm.local()
182180
if comReturn: return comReturn
@@ -212,9 +210,18 @@ def reload_mod():
212210

213211
@app.before_request
214212
def request_check():
215-
#if not public.path_safe_check(request.path): return abort(404)
213+
#路由和URI长度过滤
214+
if len(request.path) > 64: return abort(403)
215+
if len(request.url) > 256: return abort(403)
216216
if request.path in ['/service_status']: return
217217

218+
#POST参数过滤
219+
if request.path in ['/login','/safe','/hook','/public','/down','/get_app_bind_status','/check_bind']:
220+
pdata = request.form.to_dict()
221+
for k in pdata.keys():
222+
if len(k) > 32: return abort(403)
223+
if len(pdata[k]) > 128: return abort(403)
224+
218225
if not request.path in ['/safe','/hook','/public','/mail_sys','/down']:
219226
ip_check = public.check_ip_panel()
220227
if ip_check: return ip_check
@@ -291,6 +298,29 @@ def login():
291298
is_auth_path = False
292299
if admin_path != '/bt' and os.path.exists(admin_path_file) and not 'admin_auth' in session:
293300
is_auth_path = True
301+
302+
#登录输入验证
303+
if request.method == method_post[0]:
304+
v_list = ['username','password','code','vcode','cdn_url']
305+
for v in v_list:
306+
pv = request.form.get(v,'').strip()
307+
if v == 'cdn_url':
308+
if len(pv) > 32: return public.returnMsg(False,'Wrong parameter length!')
309+
continue
310+
311+
if not pv: continue
312+
p_len = 32
313+
if v == 'code': p_len = 4
314+
if v == 'vcode': p_len = 6
315+
if len(pv) != p_len:
316+
return public.returnJson(False,'Wrong parameter length'),json_header
317+
if not re.match(r"^\w+$",pv):
318+
return public.returnJson(False,'Wrong parameter format'),json_header
319+
320+
for n in request.form.keys():
321+
if not n in v_list:
322+
return public.returnJson(False,'You cannot have extra parameters in the login parameters'),json_header
323+
294324
get = get_input()
295325
import userlogin
296326
if hasattr(get,'tmp_token'):
@@ -840,6 +870,10 @@ def panel_public():
840870
if panelWaf_data.is_xss(get.__dict__):return 'ERROR'
841871
except:
842872
pass
873+
874+
if len("{}".format(get.__dict__)) > 1024 * 32:
875+
return 'ERROR'
876+
843877
get.client_ip = public.GetClientIp()
844878
if not hasattr(get,'name'): get.name = ''
845879
if not hasattr(get,'fun'): return abort(404)
@@ -1093,6 +1127,8 @@ def download():
10931127
comReturn = comm.local()
10941128
if comReturn: return comReturn
10951129
filename = request.args.get('filename')
1130+
if filename.find('|') != -1:
1131+
filename = filename.split('|')[1]
10961132
if not filename: return public.ReturnJson(False,"INIT_ARGS_ERR"),json_header
10971133
if filename in ['alioss','qiniu','upyun','txcos','ftp']: return panel_cloud()
10981134
if filename in ['gdrive','gcloud_storage']: return "Google storage products do not currently support downloads"
@@ -1210,17 +1246,24 @@ def panel_cloud():
12101246
comReturn = comm.local()
12111247
if comReturn: return comReturn
12121248
get = get_input()
1213-
if not os.path.exists('plugin/' + get.filename + '/' + get.filename+'_main.py'):
1249+
_filename = get.filename
1250+
plugin_name = ""
1251+
if _filename.find('|') != -1:
1252+
plugin_name = get.filename.split('|')[1]
1253+
else:
1254+
plugin_name = get.filename
1255+
1256+
if not os.path.exists('plugin/' + plugin_name + '/' + plugin_name+'_main.py'):
12141257
return public.returnJson(False,'INIT_PLUGIN_NOT_EXISTS'),json_header
1215-
sys.path.append('plugin/' + get.filename)
1216-
plugin_main = __import__(get.filename+'_main')
1217-
reload(plugin_main)
1218-
tmp = eval("plugin_main.%s_main()" % get.filename)
1258+
sys.path.append('plugin/' + plugin_name)
1259+
plugin_main = __import__(plugin_name+'_main')
1260+
public.mod_reload(plugin_main)
1261+
tmp = eval("plugin_main.%s_main()" % plugin_name)
12191262
if not hasattr(tmp,'download_file'): return public.returnJson(False,'INIT_PLUGIN_NOT_DOWN_FUN'),json_header
1220-
if get.filename == 'ftp':
1221-
download_url = tmp.getFile(get.name)
1263+
download_url = tmp.download_file(get.name)
1264+
if plugin_name == 'ftp':
1265+
if download_url.find("ftp") != 0:download_url = "ftp://" + download_url
12221266
else:
1223-
download_url = tmp.download_file(get.name)
12241267
if download_url.find('http') != 0:download_url = 'http://' + download_url
12251268
return redirect(download_url)
12261269

BTPanel/static/css/site.css

+7-6
Original file line numberDiff line numberDiff line change
@@ -4925,11 +4925,11 @@ select[disabled]{
49254925
::-webkit-scrollbar {
49264926
/*滚动条整体样式*/
49274927
width : 10px; /*高宽分别对应横竖滚动条的尺寸*/
4928-
height: 10px;
4928+
height: 5px;
49294929
}
49304930
::-webkit-scrollbar-thumb {
49314931
/*滚动条里面小方块*/
4932-
border-radius: 0;
4932+
border-radius: 10px;
49334933
box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2);
49344934
background : #999;
49354935
}
@@ -5382,7 +5382,7 @@ select[disabled]{
53825382
.ace_catalogue_list::-webkit-scrollbar {
53835383
/*滚动条整体样式*/
53845384
width: 9px; /*高宽分别对应横竖滚动条的尺寸*/
5385-
height: 10px;
5385+
height: 1px;
53865386
}
53875387
.ace_catalogue_list::-webkit-scrollbar-thumb {
53885388
/*滚动条里面小方块*/
@@ -5465,19 +5465,20 @@ select[disabled]{
54655465
}
54665466
.ace_scrollbar::-webkit-scrollbar {
54675467
/*滚动条整体样式*/
5468-
width : 10px; /*高宽分别对应横竖滚动条的尺寸*/
5468+
width : 15px; /*高宽分别对应横竖滚动条的尺寸*/
54695469
height: 10px;
54705470
}
54715471
.ace_scrollbar::-webkit-scrollbar-thumb {
54725472
/*滚动条里面小方块*/
54735473
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
54745474
background: #777;
5475+
border-radius: 0;
54755476
}
54765477
.ace_scrollbar::-webkit-scrollbar-track{
54775478
/*滚动条里面轨道*/
54785479
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
54795480
background: #333;
5480-
border-radius: 10px;
5481+
border-radius: 0;
54815482
}
54825483
.ace_editors.active {
54835484
display: block;
@@ -6768,7 +6769,7 @@ select[disabled]{
67686769
.dropUpLoadFile::-webkit-scrollbar {
67696770
/*滚动条整体样式*/
67706771
width : 15px; /*高宽分别对应横竖滚动条的尺寸*/
6771-
height: 10px;
6772+
height: 1px;
67726773
}
67736774
.dropUpLoadFile::-webkit-scrollbar-thumb {
67746775
/*滚动条里面小方块*/

0 commit comments

Comments
 (0)