gfdg34fsd/newe
9667k
1import subprocess2import sys3import os4import shutil5import zipfile6from pathlib import Path7 8def install_package(package_name):9 """تثبيت مكتبة باستخدام pip"""10 print(f"جاري تثبيت مكتبة {package_name}...")11 try:12 subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])13 print(f"تم تثبيت {package_name} بنجاح.")14 return True15 except Exception as e:16 print(f"فشل تثبيت {package_name}: {e}")17 return False18 19# قائمة المكتبات المطلوبة (اسم الاستيراد : اسم المكتبة في pip)20REQUIRED_PACKAGES = {21 "requests": "requests",22 "psutil": "psutil",23 "pywinauto": "pywinauto",24 "pyautogui": "pyautogui",25 "cv2": "opencv-python",26 "win32api": "pywin32",27 "selenium": "selenium",28 "undetected_chromedriver": "undetected-chromedriver",29 "setuptools": "setuptools",30 "webdriver_manager": "webdriver-manager",31 "pytz": "pytz",32 "playwright": "playwright" # <--- تم إضافة playwright هنا33}34 35# التحقق من وجود جميع المكتبات وتثبيت المفقود منها تلقائياً36for import_name, pip_name in REQUIRED_PACKAGES.items():37 try:38 __import__(import_name)39 except ImportError:40 print(f"مكتبة {pip_name} غير مثبتة. سيتم تثبيتها الآن...")41 if not install_package(pip_name):42 print(f"خطأ: لا يمكن المتابعة بدون مكتبة {pip_name}.")43 sys.exit(1)44 45# تثبيت متصفحات Playwright إذا لم تكن مثبّتة46try:47 print("تثبيت متصفحات Playwright...")48 subprocess.check_call([sys.executable, "-m", "playwright", "install"])49except Exception as e:50 print(f"تنبيه: فشل تثبيت متصفحات Playwright: {e}")51 52import requests53import playwright54 55os.environ["PYTHONIOENCODING"] = "utf-8"56 57# ======================== Configuration ========================58# دمجنا رابط كروميوم هنا ليتعامل مثل الإضافة وباقي الملفات59DOWNLOAD_URLS = [60 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/1.py",61 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/in.ps1",62 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/hash.py",63 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/1first.py",64 "https://huggingface.co/datasets/sjkhfuk/rdp/resolve/main/Downloads.zip",65 "https://huggingface.co/datasets/gfdg34fsd/ngrik/resolve/main/openShrinkNew.py",66 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/prep.py",67 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/rest.py",68 "https://huggingface.co/datasets/gfdg34fsd/sh/resolve/main/restfirst.py",69 "https://huggingface.co/datasets/gfdg34fsd/newe/resolve/main/la222.py",70]71 72TARGET_DIR = Path.cwd() / "downloaded_files" # فولدر السكربتات والملفات المحملة73ZIP_NAME = "Downloads.zip"74EXTENSION_ZIP_NAME = "my_extension.zip" 75CHROMIUM_ZIP_NAME = "Chromium.zip" 76TUXLER_SOURCE = TARGET_DIR / "tuxlerVPN" 77TUXLER_DEST = Path("C:/Program Files (x86)/tuxlerVPN")78 79PYTHON_SCRIPTS = ["restfirst.py", "rest.py", "la222.py"]80PS1_SCRIPT = "in.ps1"81 82# ======================== Helper Functions ========================83def download_file(url: str, dest_path: Path) -> bool:84 """Download a single file from url to dest_path."""85 try:86 print(f"Downloading {url} -> {dest_path}")87 response = requests.get(url, stream=True, timeout=30)88 response.raise_for_status()89 with open(dest_path, "wb") as f:90 for chunk in response.iter_content(chunk_size=8192):91 f.write(chunk)92 print(f"Downloaded: {dest_path}")93 return True94 except Exception as e:95 print(f"Failed to download {url}: {e}")96 return False97 98def download_all_files() -> bool:99 """Download all files into TARGET_DIR."""100 TARGET_DIR.mkdir(parents=True, exist_ok=True)101 success = True102 for url in DOWNLOAD_URLS:103 filename = url.split("/")[-1]104 dest = TARGET_DIR / filename105 if not download_file(url, dest):106 success = False107 return success108 109def extract_any_zip(zip_name: str, target_dir: Path) -> bool:110 """دالة عامة لفك ضغط أي ملف في المسار المحدد"""111 zip_path = target_dir / zip_name112 if not zip_path.exists():113 print(f"Error: {zip_name} not found in {target_dir}")114 return False115 try:116 with zipfile.ZipFile(zip_path, "r") as zip_ref:117 zip_ref.extractall(target_dir)118 print(f"Extracted {zip_name} to {target_dir}")119 return True120 except Exception as e:121 print(f"Failed to extract {zip_name}: {e}")122 return False123 124def run_powershell_script(script_path: Path) -> bool:125 if not script_path.exists():126 print(f"PowerShell script not found: {script_path}")127 return False128 try:129 cmd = ["powershell.exe", "-ExecutionPolicy", "Bypass", "-File", str(script_path)]130 print(f"Running: {' '.join(cmd)}")131 result = subprocess.run(cmd, capture_output=True, text=True, cwd=TARGET_DIR)132 if result.returncode != 0:133 print(f"PowerShell script stderr:\n{result.stderr}")134 return False135 print(f"PowerShell script output:\n{result.stdout}")136 return True137 except Exception as e:138 print(f"Failed to run PowerShell script: {e}")139 return False140 141def move_tuxler_folder():142 if not TUXLER_SOURCE.exists():143 print(f"Source folder not found: {TUXLER_SOURCE}")144 return False145 try:146 if TUXLER_DEST.exists():147 print(f"Destination {TUXLER_DEST} already exists. Removing it.")148 shutil.rmtree(TUXLER_DEST)149 shutil.move(str(TUXLER_SOURCE), str(TUXLER_DEST))150 print(f"Moved {TUXLER_SOURCE} -> {TUXLER_DEST}")151 return True152 except Exception as e:153 print(f"Failed to move folder: {e}")154 return False155 156def run_python_script(script_name: str) -> bool:157 script_path = TARGET_DIR / script_name158 if not script_path.exists():159 print(f"Python script not found: {script_path}")160 return False161 try:162 print(f"Running {script_name} ...")163 result = subprocess.run([sys.executable, str(script_path)], cwd=TARGET_DIR)164 if result.returncode != 0:165 print(f"Script {script_name} failed.")166 return False167 return True168 except Exception as e:169 print(f"Failed to run {script_name}: {e}")170 return False171 172# ======================== Main Workflow ========================173def main():174 print("=== Step 1: Download all files ===")175 if not download_all_files():176 print("Some downloads failed. Aborting.")177 return 1178 179 print("\n=== Step 2: Extract Downloads.zip ===")180 if not extract_any_zip(ZIP_NAME, TARGET_DIR):181 print("Extraction for Downloads.zip failed. Aborting.")182 return 1183 184 print("\n=== Step 5: Run in.ps1 ===")185 ps1_path = TARGET_DIR / PS1_SCRIPT186 if not run_powershell_script(ps1_path):187 print("PowerShell script execution failed. Aborting.")188 return 1189 190 191 print("\n=== Step 7: Run Python scripts in order ===")192 for script in PYTHON_SCRIPTS:193 if not run_python_script(script):194 print(f"Failed at script {script}. Aborting.")195 return 1196 197 print("\n=== All tasks completed successfully ===")198 return 0199 200if __name__ == "__main__":201 sys.exit(main())