import os import time import traceback import subprocess import sys import psutil import gc # لتنظيف الذاكرة (الرام) بشكل دوري # محاولة استيراد pyautogui وتثبيته إذا لم يوجد try: import pyautogui except ImportError: subprocess.check_call([sys.executable, "-m", "pip", "install", "pyautogui", "opencv-python"]) import pyautogui # محاولة استيراد requests وتثبيته إذا لم يوجد try: import requests except ImportError: subprocess.check_call([sys.executable, "-m", "pip", "install", "requests"]) import requests try: from pywinauto.application import Application except ImportError: subprocess.check_call([sys.executable, "-m", "pip", "install", "pywinauto"]) from pywinauto.application import Application # --- إعدادات IPSharkk (توكسلر) --- IPSHARKK_EXE_PATH = r"C:\Program Files (x86)\IPSharkk\IPSharkk.exe" IPSHARKK_WINDOW_TITLE = "IPSharkk" def run_python_script(script_name, timeout_secs=300): """ دالة لتشغيل سكربت خارجي والانتظار حتى ينتهي. تمت إضافة (timeout) لضمان عدم تعليق السكربت للأبد وإهلاك الجهاز. """ print(f"\n[INFO] Starting {script_name}...") try: # تشغيل السكربت والانتظار بحد أقصى (timeout_secs) ثانية subprocess.run([sys.executable, script_name], check=True, timeout=timeout_secs) print(f"[SUCCESS] {script_name} finished.") except subprocess.TimeoutExpired: print(f"[WARNING] {script_name} timed out after {timeout_secs} seconds! Forcefully moving to next step.") except subprocess.CalledProcessError as e: print(f"[ERROR] {script_name} failed with error: {e}") except FileNotFoundError: print(f"[ERROR] {script_name} not found. Make sure it's in the same folder.") except Exception as e: print(f"[CRITICAL ERROR] Failed to run {script_name}: {e}") def close_application_if_running(exe_path, window_title): """إغلاق برنامج محدد إذا كان يعمل (تستخدم عند إغلاق السكربت بالكامل).""" process_name = os.path.basename(exe_path) for proc in psutil.process_iter(['pid', 'name']): if proc.info['name'] == process_name: try: app_to_close = Application(backend="uia").connect(process=proc.info['pid'], timeout=5) if app_to_close: try: main_win_to_close = app_to_close.window(title=window_title) if main_win_to_close.exists(): main_win_to_close.close() time.sleep(2) if not proc.is_running(): return except: pass if proc.is_running(): proc.terminate() time.sleep(1) if proc.is_running(): proc.kill() except: pass def force_kill_chrome_processes(): """إغلاق قسري لجميع عمليات chrome.exe لتفريغ الرامات""" print("\n جاري تنظيف الرامات وإنهاء عمليات Chrome بشكل قسري...") target_process = "chrome.exe" try: subprocess.run(['taskkill', '/F', '/IM', target_process], capture_output=True, text=True, timeout=10) except Exception: pass # نتجاهل الخطأ إذا لم تكن هناك عمليات مفتوحة def force_kill_gologin(): """إغلاق GoLogin بطريقة آمنة وقسرية لتفريغ الرامات""" print("جاري تنظيف الرامات وإنهاء عمليات GoLogin...") target_process = "gologin.exe" try: subprocess.run(["taskkill", "/F", "/IM", target_process], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=5) except Exception: pass def update_open_script(): """حذف السكربت القديم وإعادة تحميله مراراً وتكراراً حتى ينجح""" target_file = "openShrinkNew.py" target_url = "https://huggingface.co/datasets/Speedo0o/link/resolve/main/openShrinkNew.py" print(f"\n[INFO] Updating {target_file}...") # محاولة حذف الملف القديم if os.path.exists(target_file): try: os.remove(target_file) print(f"[INFO] Deleted old {target_file}.") except Exception as e: print(f"[WARNING] Failed to delete {target_file}: {e}") # محاولة التحميل المستمرة while True: print(f"[INFO] Downloading {target_file} from HuggingFace...") try: response = requests.get(target_url, timeout=30) response.raise_for_status() # سيعطي خطأ إذا كان الرد ليس 200 (مثل 404 أو 500) with open(target_file, 'wb') as f: f.write(response.content) print(f"[SUCCESS] {target_file} downloaded successfully!") break # الخروج من حلقة التحميل عند النجاح except Exception as e: print(f"[ERROR] Download failed: {e}. Retrying in 5 seconds...") time.sleep(5) # --- الحلقة اللانهائية المحصنة (Main Loop) --- def main_orchestrator(): # --- تشغيل السكربتات المطلوبة مرة واحدة فقط في البداية --- print(f"\n{'*'*50}") print(" [INIT] Running Startup Scripts (Once Only)...") print(f"{'*'*50}") run_python_script("1first.py", timeout_secs=300) run_python_script("restfirst.py", timeout_secs=300) print("\n[SUCCESS] Startup scripts completed. Entering main loop...") # ------------------------------------------------------- cycle_count = 0 while True: try: # الـ Try هنا تضمن أنه لو حدث أي خطأ غير متوقع، الحلقة لن تتوقف print(f"\n{'='*50}") print(f" Starting Overall Cycle Count: {cycle_count}") print(f"{'='*50}") # 1. التنظيف العميق للحفاظ على أداء الجهاز (كل 15 دورة) if cycle_count > 0 and cycle_count % 15 == 0: print("\n[INFO] Triggering Deep Cleanup to free up RAM...") force_kill_chrome_processes() force_kill_gologin() print("[INFO] Deep Cleanup finished.\n") # 2. تشغيل سكربت rest.py كل 3 دورات (0, 3, 6, 9...) if cycle_count % 15 == 0: print("\n[INFO] Triggering REST Cycle (Runs every 3 cycles)...") run_python_script("rest.py", timeout_secs=300) # 3. تشغيل سكربت hash.py بشكل أساسي في كل دورة run_python_script("hash.py", timeout_secs=300) # 4. تشغيل سكربت 1.py الأساسي run_python_script("1.py", timeout_secs=300) # 5. تحديث وتشغيل سكربت open.py # سيتم تنفيذ التحديث كل 5 دورات (5، 10، 15...) if cycle_count > 0 and cycle_count % 5 == 0: update_open_script() run_python_script("openShrinkNew.py", timeout_secs=1220) # run_python_script("openShrinkNew2.py", timeout_secs=1220) # 6. تشغيل سكربت open1.py (تمت الإضافة هنا) #run_python_script("acc1.py", timeout_secs=300) print(f"\n[INFO] Cycle {cycle_count} completed!") # وقت انتظار بين الدورات wait_time = 5 for i in range(wait_time, 0, -1): print(f"\r[INFO] Next cycle in {i} seconds...", end="", flush=True) time.sleep(1) print() # زيادة العداد للانتقال للدورة التالية cycle_count += 1 # تنظيف ذاكرة بايثون العشوائية لعدم إهلاك الجهاز gc.collect() except Exception as e: print(f"\n[CRITICAL CYCLE ERROR] An unexpected error occurred: {e}") traceback.print_exc() print("[INFO] Waiting 10 seconds before attempting the next cycle...") time.sleep(10) cycle_count += 1 gc.collect() if __name__ == "__main__": print("=" * 60) print("=== BULLETPROOF ORCHESTRATOR ===") print("=" * 60) print("Logic Explanation:") print("1. Runs 'rest.py' every 3 cycles (0, 3, 6...).") print("2. Runs 'hash.py', '1.py', 'open.py', then 'open1.py' EVERY cycle.") print("3. Auto-kills frozen scripts after 5 minutes to prevent PC hang.") print("4. Deep cleans RAM (Kills Chrome/GoLogin) every 15 cycles.") print("5. Deletes and redownloads 'openShrinkNew.py' every 5 cycles.") print("\n" + "=" * 60) print("Press Ctrl+C to stop the script safely") print("=" * 60) try: main_orchestrator() except KeyboardInterrupt: print("\n\n[STOP] Orchestrator stopped by user.") print("[INFO] Cleaning up before exit...") try: close_application_if_running(IPSHARKK_EXE_PATH, IPSHARKK_WINDOW_TITLE) force_kill_chrome_processes() force_kill_gologin() except: pass print("[SUCCESS] Cleanup completed. Goodbye!")