Molodejkaoff

Untitled

Nov 22nd, 2024 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. -- RemoteHelper module
  2. local RemoteHelper = {}
  3.  
  4. -- Internal: Generates the key based on the player's name and the place version
  5. local function generate_key()
  6. local player_name = game.Players.LocalPlayer.Name
  7. local place_version = game.PlaceVersion
  8. return player_name .. place_version .. "make_games_dont_cheat"
  9. end
  10.  
  11. -- Internal: Removes GUID from a string
  12. local function remove_guid(str)
  13. local guid_pattern = "%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x"
  14. return str:gsub(guid_pattern, "") -- Remove GUID
  15. end
  16.  
  17. -- Internal: Repeats the key for XOR operation
  18. local function repeat_key_upvr(key, length)
  19. local repeated_key = ""
  20. while #repeated_key < length do
  21. repeated_key = repeated_key .. key
  22. end
  23. return repeated_key:sub(1, length)
  24. end
  25.  
  26. -- Internal: Reverses the XOR operation
  27. local function reverse_hash(hash, key)
  28. local repeated_key = repeat_key_upvr(key, #hash)
  29. local original = ""
  30. for i = 1, #hash do
  31. original = original .. string.char(bit32.bxor(hash:sub(i, i):byte(), repeated_key:sub(i, i):byte()))
  32. end
  33. return original
  34. end
  35.  
  36. -- Internal: Retrieves the target module
  37. local function get_cached_remotes()
  38. local target = game:GetService("ReplicatedFirst").Client
  39. local success, requiredModule = pcall(require, target)
  40. if not success then
  41. warn("Failed to require the target module.")
  42. return nil
  43. end
  44. return requiredModule.CachedRemotes
  45. end
  46.  
  47. -- Retrieves remote names with cleaned names
  48. function RemoteHelper.get_remote_names()
  49. local cached_remotes = get_cached_remotes() -- Retrieve cached remotes
  50. if not cached_remotes then
  51. return nil
  52. end
  53.  
  54. local key = generate_key() -- Generate the key
  55. local remote_map = {}
  56. for hashed, value in pairs(cached_remotes) do
  57. local clean_name = remove_guid(reverse_hash(hashed, key)) -- Remove GUID
  58. remote_map[clean_name] = value -- Add cleaned name as key and its value
  59. end
  60. return remote_map
  61. end
  62.  
  63. -- Searches for a specific remote name
  64. function RemoteHelper.search_remote_by_name(toSearch)
  65. local remote_map = RemoteHelper.get_remote_names() -- Get cleaned names
  66. if not remote_map then
  67. warn("Failed to retrieve remote map.")
  68. return nil
  69. end
  70.  
  71. for name, value in pairs(remote_map) do
  72. if name == toSearch then
  73. return value -- Return the value for the searched name
  74. end
  75. end
  76. return nil -- Return nil if not found
  77. end
  78.  
  79. -- Searches for a specific remote value
  80. function RemoteHelper.search_remote_by_value(toSearchValue)
  81. local remote_map = RemoteHelper.get_remote_names() -- Get cleaned names
  82. if not remote_map then
  83. warn("Failed to retrieve remote map.")
  84. return nil
  85. end
  86.  
  87. for name, value in pairs(remote_map) do
  88. if value == toSearchValue then
  89. return name -- Return the name for the searched value
  90. end
  91. end
  92. return nil -- Return nil if not found
  93. end
  94.  
  95. return RemoteHelper
  96.  
Add Comment
Please, Sign In to add comment