From 3f1a3e3a7db55d76ab528dcff56419af0fb0e98d Mon Sep 17 00:00:00 2001 From: none Date: Fri, 23 Feb 2024 18:30:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=89=D0=B8=D1=82=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA=20=D0=B2=D1=8B=D1=88=D0=B5=20?= =?UTF-8?q?=D0=B8=20=D0=B4=D1=80=D1=83=D0=B3=D0=B8=D1=85=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=89=D0=B5=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- network.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/network.py b/network.py index 4a778d7..f1a93cc 100644 --- a/network.py +++ b/network.py @@ -1,8 +1,13 @@ +# Работа с сетью import socket from requests import get +# Очевидно import os from random import randint +# Работа с архивами from shutil import unpack_archive +# Убираем ненужное (../some => some) +from re import compile, sub from verify import * @@ -13,6 +18,7 @@ from verify import * # 2. [+] Проверка существования сайта # 3. [+] Передача сайта # 4. Приём рассылки сайтов +# 5. Проверка всех сайтов def port_gen(): port = randint(4000, 4200) @@ -23,6 +29,19 @@ 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") os.system("python -m http.server") @@ -52,6 +71,11 @@ def server(http_port): conn.send("pong".encode()) elif op[:3] == "is_": check = op[3:] + print(check) + # Защита от доступа выше + check = v_check(check) + print(check) + if os.path.exists(f'cached/{check}'): conn.send(str(http_port).encode()) else: