Advertisement
GreenMs02

RemoteSpy edited

Sep 23rd, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. local printtoconsole = printremotespy
  2.  
  3. _G.enabled = {
  4. -- Set any of these objects to false to stop logging them
  5. BindableEvent = true;
  6. BindableFunction = true;
  7. RemoteEvent = true;
  8. RemoteFunction = true;
  9. }
  10.  
  11. local _G.ignore = {
  12. Event = true;
  13. }
  14.  
  15.  
  16. local enable_additional_hooking = false
  17.  
  18. ----------------------------------------------------------------------------------------------------------------------------------------------
  19.  
  20. if _G.RemoteSpyLock then printtoconsole("!!! RemoteSpy is already running!") error() end _G.RemoteSpyLock = true
  21.  
  22. local meta = getrawmetatable(game)
  23.  
  24. local oldmeta = {
  25. __index = meta.__index;
  26. __namecall = meta.__namecall;
  27. }
  28.  
  29. local function formatargs(args,showkeys)
  30. if #args == 0 then return "N/A" end
  31. local strargs = {}
  32. for k,v in next,args do
  33. local argstr = ""
  34. if type(v) == "string" then
  35. argstr = "\"" .. v .. "\""
  36. elseif type(v) == "table" then
  37. argstr = "{" .. formatargs(v,true) .. "}"
  38. else
  39. argstr = tostring(v)
  40. end
  41. if showkeys and type(k) ~= "number" then
  42. table.insert(strargs,k.."="..argstr)
  43. else
  44. table.insert(strargs,argstr)
  45. end
  46. end
  47. return table.concat(strargs, ", ")
  48. end
  49.  
  50. local realmethods = {
  51. Fire = Instance.new("BindableEvent").Fire;
  52. Invoke = Instance.new("BindableFunction").Invoke;
  53. FireServer = Instance.new("RemoteEvent").FireServer;
  54. InvokeServer = Instance.new("RemoteFunction").InvokeServer;
  55. }
  56.  
  57. local hook = function(method)
  58. return function(...)
  59. local args = {...}
  60. local t,k = args[1],args[#args]
  61. if (k == "Fire" or k == "Invoke" or k == "FireServer" or k == "InvokeServer") and (_G.enabled[t.ClassName] and not _G.ignore[t.Name]) then
  62. local fake = function(self,...)
  63. local args = {...}
  64. local ret = {realmethods[k](self,...)}
  65. printtoconsole("RemoteSpy event:\n----------------------------------------\n[*] "..t.ClassName.." called!\n[*] Path: "..t:GetFullName().."\n[*] Args: "..formatargs(args).."\n[*] Return: "..formatargs(ret).."\n----------------------------------------")
  66. return unpack(ret)
  67. end
  68. table.remove(args,#args) -- the key is the only irrelevant argument for __namecall
  69. return method == "__namecall" and fake(unpack(args)) or fake
  70. else
  71. return oldmeta[method](...)
  72. end
  73. end
  74. end
  75.  
  76. meta.__namecall = hook("__namecall")
  77.  
  78. if enable_additional_hooking then
  79. meta.__index = hook("__index")
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement