KirchohexSX

Roblox Utility Backup

Jun 8th, 2025 (edited)
189
1
Never
14
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.08 KB | None | 1 0
  1. import os
  2. import sys
  3. import ctypes
  4. import tkinter as tk
  5. from tkinter import scrolledtext, messagebox
  6. import shutil
  7. import datetime
  8. import psutil
  9.  
  10. # Enhanced Windows API definitions
  11. kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
  12. advapi32 = ctypes.WinDLL('advapi32', use_last_error=True)
  13.  
  14. # Constants
  15. TOKEN_QUERY = 0x0008
  16. TOKEN_ADJUST_PRIVILEGES = 0x0020
  17. SE_PRIVILEGE_ENABLED = 0x00000002
  18. SE_DEBUG_NAME = "SeDebugPrivilege"
  19. EVENT_MODIFY_STATE = 0x0002
  20. SYNCHRONIZE = 0x00100000
  21. PROCESS_ALL_ACCESS = 0x001F0FFF
  22. DUPLICATE_SAME_ACCESS = 0x00000002
  23.  
  24. # Check for admin rights
  25. def is_admin():
  26. try:
  27. return ctypes.windll.shell32.IsUserAnAdmin()
  28. except:
  29. return False
  30.  
  31. # Show UAC prompt and restart as admin
  32. def request_admin():
  33. script_path = os.path.abspath(sys.argv[0])
  34. ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, f'"{script_path}"', None, 1)
  35. sys.exit()
  36.  
  37. # Main application class
  38. class RobloxUtilityApp:
  39. def __init__(self, root):
  40. self.root = root
  41. self.root.title("Roblox Utility")
  42. self.root.geometry("650x350")
  43. self.root.attributes("-topmost", True) # Always on top
  44.  
  45. # Configure colors
  46. bg_color = "#2d2d2d"
  47. btn_color = "#3c3f41"
  48. text_color = "#e0e0e0"
  49.  
  50. self.root.configure(bg=bg_color)
  51.  
  52. # Create buttons
  53. btn_frame = tk.Frame(root, bg=bg_color)
  54. btn_frame.pack(pady=10)
  55.  
  56. self.kill_btn = tk.Button(
  57. btn_frame, text="Kill Singleton Event", width=20, height=2,
  58. bg=btn_color, fg=text_color, command=self.kill_singleton
  59. )
  60. self.kill_btn.grid(row=0, column=0, padx=5)
  61.  
  62. self.cookies_btn = tk.Button(
  63. btn_frame, text="Delete RobloxCookies.dat", width=20, height=2,
  64. bg=btn_color, fg=text_color, command=self.delete_cookies
  65. )
  66. self.cookies_btn.grid(row=0, column=1, padx=5)
  67.  
  68. self.temp_btn = tk.Button(
  69. btn_frame, text="Clear Temp Folder", width=20, height=2,
  70. bg=btn_color, fg=text_color, command=self.clear_temp
  71. )
  72. self.temp_btn.grid(row=0, column=2, padx=5)
  73.  
  74. # Create console log
  75. self.log_area = scrolledtext.ScrolledText(
  76. root, width=75, height=15, bg="#1e1e1e", fg="#cccccc"
  77. )
  78. self.log_area.pack(padx=10, pady=5)
  79. self.log_area.config(state=tk.DISABLED)
  80.  
  81. # Initial log message
  82. self.log("Roblox Utility started. Run as Admin: ✓")
  83. self.log("Note: Run Roblox before clicking 'Kill Singleton Event'")
  84.  
  85. def log(self, message):
  86. timestamp = datetime.datetime.now().strftime("%H:%M:%S")
  87. self.log_area.config(state=tk.NORMAL)
  88. self.log_area.insert(tk.END, f"[{timestamp}] {message}\n")
  89. self.log_area.config(state=tk.DISABLED)
  90. self.log_area.yview(tk.END)
  91.  
  92. def enable_debug_privilege(self):
  93. """Enable debug privilege required to manipulate other processes"""
  94. try:
  95. # Get current process token
  96. hToken = ctypes.c_void_p()
  97. if not advapi32.OpenProcessToken(kernel32.GetCurrentProcess(),
  98. TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
  99. ctypes.byref(hToken)):
  100. return False
  101.  
  102. # Lookup privilege value
  103. luid = ctypes.c_ulonglong()
  104. if not advapi32.LookupPrivilegeValueW(None, SE_DEBUG_NAME, ctypes.byref(luid)):
  105. kernel32.CloseHandle(hToken)
  106. return False
  107.  
  108. # Enable privilege
  109. new_state = (ctypes.c_ulong * 3)()
  110. new_state[0] = 1 # One privilege to set
  111. new_state[1] = luid.value & 0xFFFFFFFF
  112. new_state[2] = luid.value >> 32
  113. new_state[3] = SE_PRIVILEGE_ENABLED
  114.  
  115. if not advapi32.AdjustTokenPrivileges(hToken, False, new_state, 0, None, None):
  116. kernel32.CloseHandle(hToken)
  117. return False
  118.  
  119. kernel32.CloseHandle(hToken)
  120. return True
  121. except:
  122. return False
  123.  
  124. def kill_singleton(self):
  125. """Kill Roblox singleton event using multiple methods"""
  126. self.log("Attempting to kill Roblox singleton event...")
  127.  
  128. # Enable debug privilege first
  129. if not self.enable_debug_privilege():
  130. self.log("Warning: Failed to enable debug privilege")
  131.  
  132. # Try direct event closing method
  133. if self.close_singleton_direct():
  134. return
  135.  
  136. # Try process-based method if direct fails
  137. if self.close_singleton_via_process():
  138. return
  139.  
  140. self.log("All methods failed. Possible solutions:")
  141. self.log("1. Make sure Roblox is running")
  142. self.log("2. Try closing Roblox completely and reopening")
  143. self.log("3. Run this utility before launching Roblox")
  144.  
  145. def close_singleton_direct(self):
  146. """Method 1: Directly close the singleton event"""
  147. try:
  148. # Get session ID
  149. session_id = ctypes.windll.kernel32.WTSGetActiveConsoleSessionId()
  150. event_name = f"\\Sessions\\{session_id}\\BaseNamedObjects\\ROBLOX_singletonEvent"
  151. self.log(f"Targeting event: {event_name}")
  152.  
  153. # Define OpenEvent function
  154. OpenEvent = kernel32.OpenEventW
  155. OpenEvent.argtypes = [ctypes.c_uint32, ctypes.c_int, ctypes.c_wchar_p]
  156. OpenEvent.restype = ctypes.c_void_p
  157.  
  158. # Try to open the event
  159. handle = OpenEvent(EVENT_MODIFY_STATE | SYNCHRONIZE, False, event_name)
  160.  
  161. if handle:
  162. # Close the handle
  163. kernel32.CloseHandle(handle)
  164. self.log("Success! Singleton event closed directly.")
  165. return True
  166. else:
  167. self.log("Direct method failed (event not found)")
  168. return False
  169. except Exception as e:
  170. self.log(f"Direct method error: {str(e)}")
  171. return False
  172.  
  173. def close_singleton_via_process(self):
  174. """Method 2: Close the event through the Roblox process"""
  175. try:
  176. # Find Roblox process
  177. roblox_pid = None
  178. for proc in psutil.process_iter(['pid', 'name']):
  179. if proc.info['name'].lower() in ('robloxplayerbeta.exe', 'roblox.exe'):
  180. roblox_pid = proc.info['pid']
  181. break
  182.  
  183. if not roblox_pid:
  184. self.log("Roblox process not found")
  185. return False
  186.  
  187. self.log(f"Found Roblox process (PID: {roblox_pid})")
  188.  
  189. # Open Roblox process
  190. hProcess = kernel32.OpenProcess(PROCESS_ALL_ACCESS, False, roblox_pid)
  191. if not hProcess:
  192. self.log("Failed to open Roblox process")
  193. return False
  194.  
  195. # Get session ID
  196. session_id = ctypes.windll.kernel32.WTSGetActiveConsoleSessionId()
  197. event_name = f"\\Sessions\\{session_id}\\BaseNamedObjects\\ROBLOX_singletonEvent"
  198.  
  199. # Define OpenEvent function
  200. OpenEvent = kernel32.OpenEventW
  201. OpenEvent.argtypes = [ctypes.c_uint32, ctypes.c_int, ctypes.c_wchar_p]
  202. OpenEvent.restype = ctypes.c_void_p
  203.  
  204. # Open event handle in Roblox process context
  205. handle = OpenEvent(EVENT_MODIFY_STATE | SYNCHRONIZE, False, event_name)
  206. if not handle:
  207. kernel32.CloseHandle(hProcess)
  208. self.log("Failed to open event handle")
  209. return False
  210.  
  211. # Duplicate handle to our process
  212. hCurrentProcess = kernel32.GetCurrentProcess()
  213. hDup = ctypes.c_void_p()
  214.  
  215. if not kernel32.DuplicateHandle(
  216. hProcess, handle, hCurrentProcess, ctypes.byref(hDup),
  217. 0, False, DUPLICATE_SAME_ACCESS
  218. ):
  219. kernel32.CloseHandle(handle)
  220. kernel32.CloseHandle(hProcess)
  221. self.log("Failed to duplicate handle")
  222. return False
  223.  
  224. # Close all handles
  225. kernel32.CloseHandle(handle)
  226. kernel32.CloseHandle(hDup)
  227. kernel32.CloseHandle(hProcess)
  228.  
  229. self.log("Success! Singleton event closed via process handle.")
  230. return True
  231.  
  232. except Exception as e:
  233. self.log(f"Process method error: {str(e)}")
  234. return False
  235.  
  236. def delete_cookies(self):
  237. self.log("Deleting RobloxCookies.dat...")
  238. try:
  239. # Get username from environment
  240. username = os.getenv("USERNAME")
  241. cookie_path = f"C:\\Users\\{username}\\AppData\\Local\\Roblox\\LocalStorage\\RobloxCookies.dat"
  242.  
  243. if os.path.exists(cookie_path):
  244. os.remove(cookie_path)
  245. self.log("RobloxCookies.dat deleted successfully!")
  246. else:
  247. self.log("RobloxCookies.dat not found")
  248. except Exception as e:
  249. self.log(f"Error: {str(e)}")
  250. self.log("Close Roblox before deleting cookies")
  251.  
  252. def clear_temp(self):
  253. self.log("Clearing temporary files...")
  254. try:
  255. temp_path = os.getenv("TEMP")
  256. deleted = 0
  257. skipped = 0
  258.  
  259. # Delete files
  260. for filename in os.listdir(temp_path):
  261. file_path = os.path.join(temp_path, filename)
  262. try:
  263. if os.path.isfile(file_path):
  264. os.unlink(file_path)
  265. deleted += 1
  266. elif os.path.isdir(file_path):
  267. shutil.rmtree(file_path)
  268. deleted += 1
  269. except Exception:
  270. skipped += 1
  271.  
  272. self.log(f"Temp folder cleared! Deleted: {deleted} items | Skipped: {skipped} items")
  273. except Exception as e:
  274. self.log(f"Error: {str(e)}")
  275.  
  276. # Run the application
  277. if __name__ == "__main__":
  278. # First check for admin rights
  279. if not is_admin():
  280. # Show message before requesting elevation
  281. root = tk.Tk()
  282. root.withdraw() # Hide the main window
  283. response = messagebox.askyesno(
  284. "Admin Privileges Required",
  285. "This application requires administrator privileges to function properly.\n\n"
  286. "Do you want to restart it with administrator rights?"
  287. )
  288. root.destroy()
  289.  
  290. if response:
  291. request_admin()
  292. else:
  293. sys.exit()
  294.  
  295. # Create main application window
  296. root = tk.Tk()
  297. app = RobloxUtilityApp(root)
  298. root.mainloop()
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment