From a4edba8db215f1c032f18b5e034f50ade186d773 Mon Sep 17 00:00:00 2001 From: none Date: Fri, 23 Feb 2024 18:39:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain_check.py | 9 ++++++++- network.py | 15 ++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/domain_check.py b/domain_check.py index 26cbc1a..0414b53 100644 --- a/domain_check.py +++ b/domain_check.py @@ -1,8 +1,15 @@ +from re import compile, sub + def domain_ok(domain): domains = ["jet"] if domain.count(".") == 1: if domain.split(".")[1] in domains: - return True + # ../some => some + # Защита от проверки папок выше, чем нужно и др. + regex = compile('[^a-zA-Zа-яА-ЯЁё.]') + c_domain = regex.sub('', domain) + if domain == c_domain: + return domain return False diff --git a/network.py b/network.py index f1a93cc..5e66e7a 100644 --- a/network.py +++ b/network.py @@ -10,6 +10,7 @@ from shutil import unpack_archive from re import compile, sub from verify import * +from domain_check import * # Здесь идёт обработка всех запросов через сеть @@ -29,18 +30,6 @@ def port_gen(): port = randint(4000, 4200) return port -# ../some => some -# Защита от проверки папок выше, чем нужно и др. -def v_check(check): - regex = compile('[^a-zA-Zа-яА-ЯЁё.]') - check = regex.sub('', check) - - if check.count('.') > 1: - return 'BAD' - - return check - - def server_http(): os.chdir("cached") @@ -73,7 +62,7 @@ def server(http_port): check = op[3:] print(check) # Защита от доступа выше - check = v_check(check) + check = domain_ok(check) print(check) if os.path.exists(f'cached/{check}'):