Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Прочее Loader 1.16.5 Python

хз как вообще, но думаю пастерам подойдет


Код:
Expand Collapse Copy
import os
import requests
import zipfile
import subprocess
import ctypes
import sys
import shutil

JAVA_URL = "https://www.dropbox.com/scl/fi/jjvuf4q3h173iitlalvvo/jdk-17.zip?rlkey=00rg4s79afx29417e9pl41ols&st=glytugy3&dl=1"
JAR_URL = "https://www.dropbox.com/scl/fi/2ysuxgfket0mbo3d5jyah/Anfyence.jar?rlkey=0lde1ugygx94br4ag9p7tog56&st=f62t5nn9&dl=1"
ASSETS_URL = "https://www.dropbox.com/scl/fi/7nz9ovnhfxdt1si5fzyel/assets.zip?rlkey=ru43ggzers08k2spcrqvx9afr&st=awe8mg8g&dl=1"

FOLDER = r"C:\AnfyenceFree"
JAR_FILE = os.path.join(FOLDER, "Anfyence.jar")
ASSETS_ZIP = os.path.join(FOLDER, "assets.zip")
ASSETS_FOLDER = os.path.join(FOLDER, "assets")
JAVA_ZIP = os.path.join(FOLDER, "jdk-17.zip")
JAVA_FOLDER = os.path.join(FOLDER, "jdk-17")
JAVA_PATH = os.path.join(JAVA_FOLDER, "bin", "javaw.exe")

NICKNAME = "AnfyenceFreeUser"


def hide_console():
    ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)


def print_progress_bar(current, total, filename):
    bar_length = 50
    percent = current / total
    filled = int(bar_length * percent)
   
    bar = "█" * filled + "░" * (bar_length - filled)
   
    current_mb = current / (1024 * 1024)
    total_mb = total / (1024 * 1024)
   
    percent_display = percent * 100
   
    sys.stdout.write(f"\r{filename}: [{bar}] {percent_display:.1f}% ({current_mb:.1f}MB / {total_mb:.1f}MB)")
    sys.stdout.flush()


def get_remote_file_size(url):
    try:
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        }
        r = requests.get(url, headers=headers, timeout=10, allow_redirects=True, stream=True)
        return int(r.headers.get('content-length', 0))
    except Exception as e:
        print(f"Ошибка при получении размера файла: {e}")
        return 0


def need_update(local_path, remote_url):
    if not os.path.exists(local_path):
        print(f"Файл не найден, скачиваем...")
        return True
   
    local_size = os.path.getsize(local_path)
    remote_size = get_remote_file_size(remote_url)
   
    if remote_size == 0:
        print(f"Не удалось получить размер с сервера, файл считается актуальным")
        return False
   
    print(f"Локально: {local_size} байт, На сервере: {remote_size} байт")
   
    if local_size != remote_size:
        print(f"Обнаружена новая версия файла")
        return True
   
    print(f"Файл актуален")
    return False


def download_file(url, path):
    filename = os.path.basename(path)
    print(f"\nПроверка {filename}...")
   
    if filename == "assets.zip" and os.path.exists(ASSETS_FOLDER):
        print(f"Папка assets уже установлена, пропускаем скачивание.\n")
        return
   
    if filename == "jdk-17.zip" and os.path.exists(JAVA_FOLDER):
        print(f"Java уже установлена, пропускаем скачивание.\n")
        return
   
    if not need_update(path, url):
        print(f"{filename} не требует обновления.\n")
        return
   
    if os.path.exists(path):
        print(f"Удаляем старый файл {filename}...")
        os.remove(path)
   
    print(f"Скачивание {filename}...")
   
    try:
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        }
       
        r = requests.get(url, stream=True, headers=headers, timeout=30, allow_redirects=True)
        r.raise_for_status()
       
        content_type = r.headers.get('content-type', '')
        if 'text/html' in content_type:
            print(f"\nОшибка: Dropbox вернул HTML вместо файла")
            print(f"Проверьте ссылку")
            raise Exception("Неверная ссылка Dropbox")
       
        total_size = int(r.headers.get('content-length', 0))
        downloaded = 0
       
        with open(path, "wb") as f:
            for chunk in r.iter_content(8192):
                if chunk:
                    f.write(chunk)
                    downloaded += len(chunk)
                    if total_size:
                        print_progress_bar(downloaded, total_size, filename)
       
        print(f"\n{filename} скачан успешно!\n")
       
    except Exception as e:
        print(f"\nОшибка при скачивании: {e}")
        raise


def extract_assets():
    if os.path.exists(ASSETS_FOLDER) and os.path.isdir(ASSETS_FOLDER):
        return
   
    print(f"\nПроверка assets...")
   
    if not os.path.exists(ASSETS_ZIP):
        print(f"Файл assets.zip не найден!")
        return
   
    print(f"Распаковка assets.zip...")
    try:
        if not zipfile.is_zipfile(ASSETS_ZIP):
            print(f"Файл assets.zip повреждён!")
            raise zipfile.BadZipFile("Файл повреждён или не является ZIP")
       
        with zipfile.ZipFile(ASSETS_ZIP, 'r') as zip_ref:
            zip_ref.extractall(FOLDER)
        os.remove(ASSETS_ZIP)
        print("Assets распакованы успешно!\n")
       
    except Exception as e:
        print(f"Ошибка при распаковке: {e}")
        raise


def extract_java():
    if os.path.exists(JAVA_FOLDER) and os.path.isdir(JAVA_FOLDER):
        return
   
    print(f"\nПроверка Java...")
   
    if not os.path.exists(JAVA_ZIP):
        print(f"Файл jdk-17.zip не найден!")
        return
   
    print(f"Распаковка jdk-17.zip...")
    try:
        if not zipfile.is_zipfile(JAVA_ZIP):
            print(f"Файл jdk-17.zip повреждён!")
            raise zipfile.BadZipFile("Файл повреждён или не является ZIP")
       
        with zipfile.ZipFile(JAVA_ZIP, 'r') as zip_ref:
            zip_ref.extractall(FOLDER)
        os.remove(JAVA_ZIP)
        print("Java распакована успешно!\n")
       
    except Exception as e:
        print(f"Ошибка при распаковке: {e}")
        raise


def get_ram_amount():
    print("\n" + "=" * 50)
    print("Выделение памяти RAM для клиента")
    print("=" * 50)
    print("Примеры: 1GB = 1024MB, 2GB = 2048MB, 4GB = 4096MB")
    print("Текущее значение: 2048MB (2GB)\n")
   
    while True:
        try:
            ram_input = input("Введите объем RAM в МБ (или нажмите Enter для 2048): ").strip()
           
            if not ram_input:
                return "2048M"
           
            ram_mb = int(ram_input)
           
            if ram_mb < 512:
                print("Минимум 512MB! Попробуйте снова.")
                continue
            if ram_mb > 32768:
                print("Максимум 32768MB (32GB)! Попробуйте снова.")
                continue
           
            print(f"RAM установлена на: {ram_mb}MB\n")
            return f"{ram_mb}M"
       
        except ValueError:
            print("Введите корректное число!")


def launch(max_memory):
    print("Запуск клиента Anfyence...\n")
    hide_console()

    subprocess.Popen([
        JAVA_PATH,
        f"-Xmx{max_memory}",
        "-Duser.name=" + NICKNAME,
        "-jar",
        JAR_FILE
    ], cwd=FOLDER)


def print_banner():
    banner = r"""
 $$$$$$\             $$$$$$\                                                  
$$  __$$\           $$  __$$\                                                  
$$ /  $$ |$$$$$$$\  $$ /  \__|$$\   $$\  $$$$$$\  $$$$$$$\   $$$$$$$\  $$$$$$\
$$$$$$$$ |$$  __$$\ $$$$\     $$ |  $$ |$$  __$$\ $$  __$$\ $$  _____|$$  __$$\
$$  __$$ |$$ |  $$ |$$  _|    $$ |  $$ |$$$$$$$$ |$$ |  $$ |$$ /      $$$$$$$$ |
$$ |  $$ |$$ |  $$ |$$ |      $$ |  $$ |$$   ____|$$ |  $$ |$$ |      $$   ____|
$$ |  $$ |$$ |  $$ |$$ |      \$$$$$$$ |\$$$$$$$\ $$ |  $$ |\$$$$$$$\ \$$$$$$$\
\__|  \__|\__|  \__|\__|       \____$$ | \_______|\__|  \__| \_______| \_______|
                              $$\   $$ |                                      
                              \$$$$$$  |                                      
                               \______/                                                                                                
"""
    print(banner)


def main():
    print_banner()
   
    if not os.path.exists(FOLDER):
        os.makedirs(FOLDER)
   
    print("Проверка файлов...\n")
   
    download_file(JAVA_URL, JAVA_ZIP)
    extract_java()
   
    download_file(JAR_URL, JAR_FILE)
    download_file(ASSETS_URL, ASSETS_ZIP)
    extract_assets()
   
    max_memory = get_ram_amount()
   
    launch(max_memory)
   
    print("=" * 50)
    print("Загрузка завершена!")
    print("=" * 50)


if __name__ == "__main__":
    main()
Бессмысленно, питон хуйня
 
по
$$$$$$\ $$$$$$\
$$ __$$\ $$ __$$\
$$ / $$ |$$$$$$$\ $$ / \__|$$\ $$\ $$$$$$\ $$$$$$$\ $$$$$$$\ $$$$$$\
$$$$$$$$ |$$ __$$\ $$$$\ $$ | $$ |$$ __$$\ $$ __$$\ $$ _____|$$ __$$\
$$ __$$ |$$ | $$ |$$ _| $$ | $$ |$$$$$$$$ |$$ | $$ |$$ / $$$$$$$$ |
$$ | $$ |$$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ |$$ | $$ ____|
$$ | $$ |$$ | $$ |$$ | \$$$$$$$ |\$$$$$$$\ $$ | $$ |\$$$$$$$\ \$$$$$$$\
\__| \__|\__| \__|\__| \____$$ | \_______|\__| \__| \_______| \_______|
$$\ $$ |
\$$$$$$ |
\______/
кажется как будто это cmd лоадер
так цмд лоадеры это круто
 
Назад
Сверху Снизу