Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.93 KB | None | 0 0
  1. --[[
  2. Lua U Remote Spy written by chaserks (chaserks @ v3rmillion.net, superdude914#3441 @ Discord)
  3. Exploits supported: Synapse X, ProtoSmasher (Sirhurt?, Elysian?)
  4. Remote calls are printed to the dev console by default (F9 window)
  5. To use Synapse's console, change Settings.Output to rconsoleprint
  6. ]]
  7.  
  8. _G.Settings = { --// You can change these settings
  9. Enabled = true, --// Remote spy is enabled
  10. Copy = true, --// Set remote calls to clipboard as code
  11. Blacklist = { --// Ignore remote calls made with these remotes
  12. CharacterSoundEvent = true,
  13. },
  14. ShowScript = false, --// Print out the script that made the remote call (Unfunctional with ProtoSmasher)
  15. ShowReturns = true, --// Display what the remote calls return
  16. Output = warn --// Function used to output remote calls (Change to rconsoleprint to use Synapse's console)
  17. }
  18.  
  19. local metatable = getrawmetatable(game)
  20.  
  21. --// Custom functions aliases
  22. local make_writeable = make_writeable or setreadonly or set_readonly
  23. local detour_function = detour_function or replace_closure or hookfunction
  24. local setclipboard = setclipboard or set_clipboard or writeclipboard
  25. local get_namecall_method = get_namecall_method or getnamecallmethod or function(o)
  26. return typeof(o) == "Instance" and Methods[o.ClassName] or nil
  27. end
  28. local protect_function = protect_function or newcclosure or function(...)
  29. return ...
  30. end
  31.  
  32. --// \\--
  33.  
  34. local Original = {}
  35. local Settings = _G.Settings
  36. local Methods = {
  37. RemoteEvent = "FireServer",
  38. RemoteFunction = "InvokeServer"
  39. }
  40.  
  41. local GetInstanceName = function(Object) --// Returns proper string wrapping for instances
  42. local Name = Object.Name
  43. return ((#Name == 0 or Name:match("[^%w]+") or Name:sub(1, 1):match("[^%a]")) and "[\"%s\"]" or ".%s"):format(Name)
  44. end
  45.  
  46. local function Parse(Object) --// Convert the types into strings
  47. local Type = typeof(Object)
  48. if Type == "string" then
  49. return ("\"%s\""):format(Object)
  50. elseif Type == "Instance" then --// Instance:GetFullName() except it's not handicapped
  51. local Path = GetInstanceName(Object)
  52. local Parent = metatable.__index(Object, "Parent")
  53. while Parent and Parent ~= game do
  54. Path = GetInstanceName(Parent) .. Path
  55. Parent = metatable.__index(Parent, "Parent")
  56. end
  57. return (Object:IsDescendantOf(game) and "game" or "NIL") .. Path
  58. elseif Type == "table" then
  59. local Str = ""
  60. local Counter = 0
  61. for Idx, Obj in next, Object do
  62. Counter = Counter + 1
  63. local Obj = Obj ~= Object and Parse(Obj) or "THIS_TABLE"
  64. if Counter ~= Idx then
  65. Str = Str .. ("[%s] = %s, "):format(Idx ~= Object and Parse(Idx) or "THIS_TABLE", Obj) --maybe
  66. else
  67. Str = Str .. ("%s, "):format(Obj)
  68. end
  69. end
  70. return ("{%s}"):format(Str:sub(1, -3))
  71. elseif Type == "CFrame" or Type == "Vector3" or Type == "Vector2" or Type == "UDim2" or Type == "Color3" or Type == "Vector3int16" then
  72. return ("%s.%s(%s)"):format(Type, Type == "Color3" and "fromRGB" or "new", tostring(Object))
  73. elseif Type == "userdata" then --// Remove __tostring fields to counter traps
  74. local Result
  75. local Metatable = getrawmetatable(Object)
  76. local __tostring = Metatable and Metatable.__tostring
  77. if __tostring then
  78. make_writeable(Metatable, false)
  79. Metatable.__tostring = nil
  80. Result = tostring(Object)
  81. rawset(Metatable, "__tostring", __tostring)
  82. make_writeable(Metatable, rawget(Metatable, "__metatable") ~= nil)
  83. else
  84. Result = tostring(Object)
  85. end
  86. return Result
  87. else
  88. return tostring(Object)
  89. end
  90. end
  91.  
  92. local Write = function(Remote, Arguments, Returns) --// Remote (Instance), Arguments (Table), Returns (Table)
  93. local Stuff = ("%s:%s(%s)\r\n"):format(Parse(Remote), Methods[metatable.__index(Remote, "ClassName")], Parse(Arguments):sub(2, -2))
  94. Settings.Output(Stuff) --// Output the remote call
  95. local _ = Settings.Copy and pcall(setclipboard, Stuff)
  96. if Settings.ShowScript and not PROTOSMASHER_LOADED then
  97. local Env = getfenv(3) --// ProtoSmasher HATES this line (detour_function breaks)
  98. local Script = rawget(Env, "script")
  99. if typeof(Script) == "Instance" then
  100. Settings.Output(("Script: %s"):format(Parse(Script)))
  101. end
  102. end
  103. if Returns and #Returns > 0 then
  104. Settings.Output(("Returned: %s"):format(Parse(Returns):sub(2, -2)))
  105. end
  106. end
  107.  
  108. do --// Anti detection for tostring ( tostring(FireServer, InvokeServer) )
  109. local ORIG = tostring
  110. local new_function = protect_function(function(obj)
  111. local Success, Result = pcall(ORIG or original_function, Original[obj] or obj)
  112. if Success then
  113. return Result
  114. else
  115. error(Result:gsub(script.Name .. ":%d+: ", ""))
  116. end
  117. end)
  118. Original[new_function] = ORIG
  119. ORIG = detour_function(ORIG, new_function, true)
  120. end
  121.  
  122. for Class, Method in next, Methods do --// FireServer and InvokeServer hooking ( FireServer(Remote, ...) )
  123. local ORIG = Instance.new(Class)[Method]
  124. local new_function = protect_function(function(self, ...)
  125. local Returns = {(ORIG or original_function)(self, ...)}
  126. if typeof(self) == "Instance" and Methods[self.ClassName] == Method and not Settings.Blacklist[self.Name] and Settings.Enabled then
  127. Write(self, {...}, Settings.ShowReturns and Returns)
  128. end
  129. return unpack(Returns)
  130. end)
  131. Original[new_function] = ORIG
  132. ORIG = detour_function(ORIG, new_function)
  133. end
  134.  
  135. do --// Namecall hooking ( Remote:FireServer(...) )
  136. local ORIG = metatable.__namecall
  137. local new_function = protect_function(function(self, ...)
  138. local Returns = {(ORIG or original_function)(self, ...)}
  139. local Arguments = {...}
  140. local Method = get_namecall_method(self)
  141. if typeof(Method) == "string" and Methods[self.ClassName] == Method and not Settings.Blacklist[self.Name] and Settings.Enabled then
  142. Write(self, Arguments, Settings.ShowReturns and Returns)
  143. end
  144. return unpack(Returns)
  145. end)
  146. Original[new_function] = ORIG
  147. make_writeable(metatable, false)
  148. metatable.__namecall = new_function
  149. make_writeable(metatable, true)
  150. end
  151.  
  152. warn("Settings:")
  153. table.foreach(Settings, print)
  154. warn("----------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement