File size: 7,600 Bytes
f670ae3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import subprocess
import sys
import os
import shutil
import zipfile
from pathlib import Path

def install_package(package_name):
    """تثبيت مكتبة باستخدام pip"""
    print(f"جاري تثبيت مكتبة {package_name}...")
    try:
        subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
        print(f"تم تثبيت {package_name} بنجاح.")
        return True
    except Exception as e:
        print(f"فشل تثبيت {package_name}: {e}")
        return False

# التحقق من وجود requests وتثبيتها إذا لزم الأمر
try:
    import requests
except ImportError:
    print("مكتبة requests غير مثبتة. سيتم تثبيتها الآن...")
    if install_package("requests"):
        import requests
    else:
        print("لا يمكن المتابعة بدون مكتبة requests.")
        sys.exit(1)

os.environ["PYTHONIOENCODING"] = "utf-8"

# ======================== Configuration ========================
# دمجنا رابط كروميوم هنا ليتعامل مثل الإضافة وباقي الملفات
DOWNLOAD_URLS = [
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/1.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/in.ps1",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/hash.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/1first.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/Downloads.zip",
    "https://huggingface.co/datasets/swelam100/rdp/resolve/main/acc1.py",
    "https://huggingface.co/datasets/mokasiko2/new11/resolve/main/opendown1.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/prep.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/rest.py",
    "https://huggingface.co/datasets/samilod9/nanni/resolve/main/open21.py",
    "https://huggingface.co/datasets/gfdg34fsd/rdp/resolve/main/restfirst.py",
    "https://huggingface.co/datasets/mokasiko2/new11/resolve/main/la22.py",
    "https://huggingface.co/datasets/samilod9/nanni/resolve/main/my_extension.zip",
    "https://huggingface.co/datasets/samilod9/nanni/resolve/main/Chromium.zip", # رابط كروميوم تمت إضافته هنا
]

TARGET_DIR = Path.cwd() / "downloaded_files"          # فولدر السكربتات والملفات المحملة
ZIP_NAME = "Downloads.zip"
EXTENSION_ZIP_NAME = "my_extension.zip"               
CHROMIUM_ZIP_NAME = "Chromium.zip"                    
TUXLER_SOURCE = TARGET_DIR / "tuxlerVPN"              
TUXLER_DEST = Path("C:/Program Files (x86)/tuxlerVPN")

PYTHON_SCRIPTS = ["prep.py", "restfirst.py", "1first.py", "la22.py"]
PS1_SCRIPT = "in.ps1"

# ======================== Helper Functions ========================
def download_file(url: str, dest_path: Path) -> bool:
    """Download a single file from url to dest_path."""
    try:
        print(f"Downloading {url} -> {dest_path}")
        response = requests.get(url, stream=True, timeout=30)
        response.raise_for_status()
        with open(dest_path, "wb") as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"Downloaded: {dest_path}")
        return True
    except Exception as e:
        print(f"Failed to download {url}: {e}")
        return False

def download_all_files() -> bool:
    """Download all files into TARGET_DIR."""
    TARGET_DIR.mkdir(parents=True, exist_ok=True)
    success = True
    for url in DOWNLOAD_URLS:
        filename = url.split("/")[-1]
        dest = TARGET_DIR / filename
        if not download_file(url, dest):
            success = False
    return success

def extract_any_zip(zip_name: str, target_dir: Path) -> bool:
    """دالة عامة لفك ضغط أي ملف في المسار المحدد"""
    zip_path = target_dir / zip_name
    if not zip_path.exists():
        print(f"Error: {zip_name} not found in {target_dir}")
        return False
    try:
        with zipfile.ZipFile(zip_path, "r") as zip_ref:
            zip_ref.extractall(target_dir)
        print(f"Extracted {zip_name} to {target_dir}")
        return True
    except Exception as e:
        print(f"Failed to extract {zip_name}: {e}")
        return False

def run_powershell_script(script_path: Path) -> bool:
    if not script_path.exists():
        print(f"PowerShell script not found: {script_path}")
        return False
    try:
        cmd = ["powershell.exe", "-ExecutionPolicy", "Bypass", "-File", str(script_path)]
        print(f"Running: {' '.join(cmd)}")
        result = subprocess.run(cmd, capture_output=True, text=True, cwd=TARGET_DIR)
        if result.returncode != 0:
            print(f"PowerShell script stderr:\n{result.stderr}")
            return False
        print(f"PowerShell script output:\n{result.stdout}")
        return True
    except Exception as e:
        print(f"Failed to run PowerShell script: {e}")
        return False

def move_tuxler_folder():
    if not TUXLER_SOURCE.exists():
        print(f"Source folder not found: {TUXLER_SOURCE}")
        return False
    try:
        if TUXLER_DEST.exists():
            print(f"Destination {TUXLER_DEST} already exists. Removing it.")
            shutil.rmtree(TUXLER_DEST)
        shutil.move(str(TUXLER_SOURCE), str(TUXLER_DEST))
        print(f"Moved {TUXLER_SOURCE} -> {TUXLER_DEST}")
        return True
    except Exception as e:
        print(f"Failed to move folder: {e}")
        return False

def run_python_script(script_name: str) -> bool:
    script_path = TARGET_DIR / script_name
    if not script_path.exists():
        print(f"Python script not found: {script_path}")
        return False
    try:
        print(f"Running {script_name} ...")
        result = subprocess.run([sys.executable, str(script_path)], cwd=TARGET_DIR)
        if result.returncode != 0:
            print(f"Script {script_name} failed.")
            return False
        return True
    except Exception as e:
        print(f"Failed to run {script_name}: {e}")
        return False

# ======================== Main Workflow ========================
def main():
    print("=== Step 1: Download all files ===")
    if not download_all_files():
        print("Some downloads failed. Aborting.")
        return 1

    print("\n=== Step 2: Extract Downloads.zip ===")
    if not extract_any_zip(ZIP_NAME, TARGET_DIR):
        print("Extraction for Downloads.zip failed. Aborting.")
        return 1

    print("\n=== Step 3: Extract my_extension.zip ===")
    if not extract_any_zip(EXTENSION_ZIP_NAME, TARGET_DIR):
        print("Extraction for my_extension.zip failed. Aborting.")
        return 1

    print("\n=== Step 4: Extract Chromium.zip ===")
    if not extract_any_zip(CHROMIUM_ZIP_NAME, TARGET_DIR):
        print("Extraction for Chromium.zip failed. Aborting.")
        return 1

    print("\n=== Step 5: Run in.ps1 ===")
    ps1_path = TARGET_DIR / PS1_SCRIPT
    if not run_powershell_script(ps1_path):
        print("PowerShell script execution failed. Aborting.")
        return 1

    print("\n=== Step 6: Move tuxlerVPN to Program Files ===")
    if not move_tuxler_folder():
        print("Moving tuxlerVPN failed. Aborting.")
        return 1

    print("\n=== Step 7: Run Python scripts in order ===")
    for script in PYTHON_SCRIPTS:
        if not run_python_script(script):
            print(f"Failed at script {script}. Aborting.")
            return 1

    print("\n=== All tasks completed successfully ===")
    return 0

if __name__ == "__main__":
    sys.exit(main())