Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import ctypes
- import tkinter as tk
- from tkinter import scrolledtext, messagebox
- import shutil
- import datetime
- import psutil
- # Enhanced Windows API definitions
- kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
- advapi32 = ctypes.WinDLL('advapi32', use_last_error=True)
- # Constants
- TOKEN_QUERY = 0x0008
- TOKEN_ADJUST_PRIVILEGES = 0x0020
- SE_PRIVILEGE_ENABLED = 0x00000002
- SE_DEBUG_NAME = "SeDebugPrivilege"
- EVENT_MODIFY_STATE = 0x0002
- SYNCHRONIZE = 0x00100000
- PROCESS_ALL_ACCESS = 0x001F0FFF
- DUPLICATE_SAME_ACCESS = 0x00000002
- # Check for admin rights
- def is_admin():
- try:
- return ctypes.windll.shell32.IsUserAnAdmin()
- except:
- return False
- # Show UAC prompt and restart as admin
- def request_admin():
- script_path = os.path.abspath(sys.argv[0])
- ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, f'"{script_path}"', None, 1)
- sys.exit()
- # Main application class
- class RobloxUtilityApp:
- def __init__(self, root):
- self.root = root
- self.root.title("Roblox Utility")
- self.root.geometry("650x350")
- self.root.attributes("-topmost", True) # Always on top
- # Configure colors
- bg_color = "#2d2d2d"
- btn_color = "#3c3f41"
- text_color = "#e0e0e0"
- self.root.configure(bg=bg_color)
- # Create buttons
- btn_frame = tk.Frame(root, bg=bg_color)
- btn_frame.pack(pady=10)
- self.kill_btn = tk.Button(
- btn_frame, text="Kill Singleton Event", width=20, height=2,
- bg=btn_color, fg=text_color, command=self.kill_singleton
- )
- self.kill_btn.grid(row=0, column=0, padx=5)
- self.cookies_btn = tk.Button(
- btn_frame, text="Delete RobloxCookies.dat", width=20, height=2,
- bg=btn_color, fg=text_color, command=self.delete_cookies
- )
- self.cookies_btn.grid(row=0, column=1, padx=5)
- self.temp_btn = tk.Button(
- btn_frame, text="Clear Temp Folder", width=20, height=2,
- bg=btn_color, fg=text_color, command=self.clear_temp
- )
- self.temp_btn.grid(row=0, column=2, padx=5)
- # Create console log
- self.log_area = scrolledtext.ScrolledText(
- root, width=75, height=15, bg="#1e1e1e", fg="#cccccc"
- )
- self.log_area.pack(padx=10, pady=5)
- self.log_area.config(state=tk.DISABLED)
- # Initial log message
- self.log("Roblox Utility started. Run as Admin: ✓")
- self.log("Note: Run Roblox before clicking 'Kill Singleton Event'")
- def log(self, message):
- timestamp = datetime.datetime.now().strftime("%H:%M:%S")
- self.log_area.config(state=tk.NORMAL)
- self.log_area.insert(tk.END, f"[{timestamp}] {message}\n")
- self.log_area.config(state=tk.DISABLED)
- self.log_area.yview(tk.END)
- def enable_debug_privilege(self):
- """Enable debug privilege required to manipulate other processes"""
- try:
- # Get current process token
- hToken = ctypes.c_void_p()
- if not advapi32.OpenProcessToken(kernel32.GetCurrentProcess(),
- TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
- ctypes.byref(hToken)):
- return False
- # Lookup privilege value
- luid = ctypes.c_ulonglong()
- if not advapi32.LookupPrivilegeValueW(None, SE_DEBUG_NAME, ctypes.byref(luid)):
- kernel32.CloseHandle(hToken)
- return False
- # Enable privilege
- new_state = (ctypes.c_ulong * 3)()
- new_state[0] = 1 # One privilege to set
- new_state[1] = luid.value & 0xFFFFFFFF
- new_state[2] = luid.value >> 32
- new_state[3] = SE_PRIVILEGE_ENABLED
- if not advapi32.AdjustTokenPrivileges(hToken, False, new_state, 0, None, None):
- kernel32.CloseHandle(hToken)
- return False
- kernel32.CloseHandle(hToken)
- return True
- except:
- return False
- def kill_singleton(self):
- """Kill Roblox singleton event using multiple methods"""
- self.log("Attempting to kill Roblox singleton event...")
- # Enable debug privilege first
- if not self.enable_debug_privilege():
- self.log("Warning: Failed to enable debug privilege")
- # Try direct event closing method
- if self.close_singleton_direct():
- return
- # Try process-based method if direct fails
- if self.close_singleton_via_process():
- return
- self.log("All methods failed. Possible solutions:")
- self.log("1. Make sure Roblox is running")
- self.log("2. Try closing Roblox completely and reopening")
- self.log("3. Run this utility before launching Roblox")
- def close_singleton_direct(self):
- """Method 1: Directly close the singleton event"""
- try:
- # Get session ID
- session_id = ctypes.windll.kernel32.WTSGetActiveConsoleSessionId()
- event_name = f"\\Sessions\\{session_id}\\BaseNamedObjects\\ROBLOX_singletonEvent"
- self.log(f"Targeting event: {event_name}")
- # Define OpenEvent function
- OpenEvent = kernel32.OpenEventW
- OpenEvent.argtypes = [ctypes.c_uint32, ctypes.c_int, ctypes.c_wchar_p]
- OpenEvent.restype = ctypes.c_void_p
- # Try to open the event
- handle = OpenEvent(EVENT_MODIFY_STATE | SYNCHRONIZE, False, event_name)
- if handle:
- # Close the handle
- kernel32.CloseHandle(handle)
- self.log("Success! Singleton event closed directly.")
- return True
- else:
- self.log("Direct method failed (event not found)")
- return False
- except Exception as e:
- self.log(f"Direct method error: {str(e)}")
- return False
- def close_singleton_via_process(self):
- """Method 2: Close the event through the Roblox process"""
- try:
- # Find Roblox process
- roblox_pid = None
- for proc in psutil.process_iter(['pid', 'name']):
- if proc.info['name'].lower() in ('robloxplayerbeta.exe', 'roblox.exe'):
- roblox_pid = proc.info['pid']
- break
- if not roblox_pid:
- self.log("Roblox process not found")
- return False
- self.log(f"Found Roblox process (PID: {roblox_pid})")
- # Open Roblox process
- hProcess = kernel32.OpenProcess(PROCESS_ALL_ACCESS, False, roblox_pid)
- if not hProcess:
- self.log("Failed to open Roblox process")
- return False
- # Get session ID
- session_id = ctypes.windll.kernel32.WTSGetActiveConsoleSessionId()
- event_name = f"\\Sessions\\{session_id}\\BaseNamedObjects\\ROBLOX_singletonEvent"
- # Define OpenEvent function
- OpenEvent = kernel32.OpenEventW
- OpenEvent.argtypes = [ctypes.c_uint32, ctypes.c_int, ctypes.c_wchar_p]
- OpenEvent.restype = ctypes.c_void_p
- # Open event handle in Roblox process context
- handle = OpenEvent(EVENT_MODIFY_STATE | SYNCHRONIZE, False, event_name)
- if not handle:
- kernel32.CloseHandle(hProcess)
- self.log("Failed to open event handle")
- return False
- # Duplicate handle to our process
- hCurrentProcess = kernel32.GetCurrentProcess()
- hDup = ctypes.c_void_p()
- if not kernel32.DuplicateHandle(
- hProcess, handle, hCurrentProcess, ctypes.byref(hDup),
- 0, False, DUPLICATE_SAME_ACCESS
- ):
- kernel32.CloseHandle(handle)
- kernel32.CloseHandle(hProcess)
- self.log("Failed to duplicate handle")
- return False
- # Close all handles
- kernel32.CloseHandle(handle)
- kernel32.CloseHandle(hDup)
- kernel32.CloseHandle(hProcess)
- self.log("Success! Singleton event closed via process handle.")
- return True
- except Exception as e:
- self.log(f"Process method error: {str(e)}")
- return False
- def delete_cookies(self):
- self.log("Deleting RobloxCookies.dat...")
- try:
- # Get username from environment
- username = os.getenv("USERNAME")
- cookie_path = f"C:\\Users\\{username}\\AppData\\Local\\Roblox\\LocalStorage\\RobloxCookies.dat"
- if os.path.exists(cookie_path):
- os.remove(cookie_path)
- self.log("RobloxCookies.dat deleted successfully!")
- else:
- self.log("RobloxCookies.dat not found")
- except Exception as e:
- self.log(f"Error: {str(e)}")
- self.log("Close Roblox before deleting cookies")
- def clear_temp(self):
- self.log("Clearing temporary files...")
- try:
- temp_path = os.getenv("TEMP")
- deleted = 0
- skipped = 0
- # Delete files
- for filename in os.listdir(temp_path):
- file_path = os.path.join(temp_path, filename)
- try:
- if os.path.isfile(file_path):
- os.unlink(file_path)
- deleted += 1
- elif os.path.isdir(file_path):
- shutil.rmtree(file_path)
- deleted += 1
- except Exception:
- skipped += 1
- self.log(f"Temp folder cleared! Deleted: {deleted} items | Skipped: {skipped} items")
- except Exception as e:
- self.log(f"Error: {str(e)}")
- # Run the application
- if __name__ == "__main__":
- # First check for admin rights
- if not is_admin():
- # Show message before requesting elevation
- root = tk.Tk()
- root.withdraw() # Hide the main window
- response = messagebox.askyesno(
- "Admin Privileges Required",
- "This application requires administrator privileges to function properly.\n\n"
- "Do you want to restart it with administrator rights?"
- )
- root.destroy()
- if response:
- request_admin()
- else:
- sys.exit()
- # Create main application window
- root = tk.Tk()
- app = RobloxUtilityApp(root)
- root.mainloop()
Advertisement