From d3a25ee1904a3e9ead77b87bec8ce2abfe097e52 Mon Sep 17 00:00:00 2001 From: justuser Date: Mon, 19 Aug 2024 14:54:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- network.py | 23 +++++++++++++---------- updater.py | 11 +++++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/network.py b/network.py index ba5fb39..d24edcf 100644 --- a/network.py +++ b/network.py @@ -13,6 +13,9 @@ from db import read from json import loads # Логирование ошибок import logging +# Просто логирование +from icecream import ic +ic.disable() # Отключение логирования from verify import * from domain_check import * @@ -43,7 +46,7 @@ def server_http(): except KeyboardInterrupt: run = False except Exception as e: - print("SERVER_HTTP FALLED") + ic("SERVER_HTTP FALLED") logging.critical(e, exc_info=True) def server(http_port): @@ -59,7 +62,7 @@ def server(http_port): s.listen(2) conn, address = s.accept() - print("Connection from: " + str(address)) + ic("Connection from: " + str(address)) while True: try: @@ -104,7 +107,7 @@ def server(http_port): conn.close() except Exception as e: - print("SERVER_HTTP FALLED") + ic("SERVER_HTTP FALLED") logging.critical(e, exc_info=True) @@ -120,7 +123,7 @@ def recv(s, data_out): okay = True except: pass - print(data) + ic(data) data_out.put(data) # op = operation @@ -177,7 +180,7 @@ def client(port, op = "ping", host = 'bore.del.pw'): g_site = get(f"http://{host}:{str(port)}/{site}.zip") except: return 'error' - print('SIZE: ', g_site.headers['Content-Length']) # Размер + ic('SIZE: ', g_site.headers['Content-Length']) # Размер with open(f"verify/{site}.zip", "wb") as f: f.write(g_site.content) @@ -214,10 +217,10 @@ def client(port, op = "ping", host = 'bore.del.pw'): our_ver = our_conf["ver"] # Если версия не новее - злоумышленник if our_ver >= dest_ver: - print("[!] Обнаружена подмена версии сайта.") + ic("[!] Обнаружена подмена версии сайта.") # Сохраняем ключ злоумышленника os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE") - print(f"[!] Порт злоумышленника: {port}") + ic(f"[!] Порт злоумышленника: {port}") # Удаляем фальшивые файлы os.remove(f"verify/{site}.zip") os.remove(f"verify/{site}.sig") @@ -235,11 +238,11 @@ def client(port, op = "ping", host = 'bore.del.pw'): copytree(f"verify/{site}", f"cached/{site}") rmtree(f"verify/{site}") else: - print("[!] Обнаружена подмена сайта.") + ic("[!] Обнаружена подмена сайта.") # Сохраняем ключ злоумышленника os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE") - print(f"[!] Порт злоумышленника: {port}") - print(f"[!] Ключ (вероятно) злоумышленника сохранён в verify/{site}.pem.FAKE\n") + ic(f"[!] Порт злоумышленника: {port}") + ic(f"[!] Ключ (вероятно) злоумышленника сохранён в verify/{site}.pem.FAKE\n") # Удаляем фальшивые файлы os.remove(f"verify/{site}.zip") os.remove(f"verify/{site}.sig") diff --git a/updater.py b/updater.py index ffe3cc3..2d039f0 100644 --- a/updater.py +++ b/updater.py @@ -6,6 +6,9 @@ from network import * # Логирование ошибок import logging +# Просто логирование +from icecream import ic +ic.disable() # Отключение логирования def update_demon(serv_port): while True: @@ -40,23 +43,23 @@ def update_demon(serv_port): if check[0] == el: # Сверяем версии if check[1] >= ver: - print("Ver_ok: ", el) + ic("Ver_ok: ", el) pass else: # Если версия новее - print("Ver_new: ", el) + ic("Ver_new: ", el) http_port = client(port, f"is_{el}") client(http_port, f"get_{el}") found = True break # Если нашли - выходим if not found: - print("Not_found: ", el) + ic("Not_found: ", el) http_port = client(port, f"is_{el}") client(http_port, f"get_{el}") except: pass except Exception as e: - print("UPDATER FALLED") + ic("UPDATER FALLED") logging.critical(e, exc_info=True)