SyntaxIsHere

Untitled

Oct 31st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. local printtoconsole = warn
  2. --[[
  3. RemoteSpy by Autumn
  4.  
  5. This is the original script, reworked for Seraph
  6. Feel free to edit and redistribute it as you desire
  7. If you do though, please leave this header intact!
  8.  
  9. Latest update: Seraph 1.15.0
  10. ]]
  11.  
  12. local enabled = {
  13. -- Set any of these objects to false to stop logging them
  14. BindableEvent = true;
  15. BindableFunction = true;
  16. RemoteEvent = true;
  17. RemoteFunction = true;
  18. }
  19.  
  20. local ignore = {
  21. -- Any remotes matching the names listed below will be ignored
  22. Event = true;
  23. }
  24.  
  25. --[[
  26.  
  27. [!] Workaround for potential __namecall bypass [!]
  28.  
  29. RemoteSpy only hooks the __namecall metamethod (for ':' method calls) by default
  30. Setting the value below to 'true' will enable additional hooking on __index
  31. Doing this will catch sneaky calls in which the '.' operator is delibrately used to avoid the __namecall hook
  32. This setting causes extremely heavy memory and CPU usage, therefore extreme caution is advised
  33.  
  34. ]]
  35.  
  36. local enable_additional_hooking = false
  37.  
  38. ----------------------------------------------------------------------------------------------------------------------------------------------
  39.  
  40. if _G.RemoteSpyLock then printtoconsole("!!! RemoteSpy is already running!") error() end _G.RemoteSpyLock = true
  41.  
  42. local meta = getrawmetatable(game)
  43.  
  44. local oldmeta = {
  45. __index = meta.__index;
  46. __namecall = meta.__namecall;
  47. }
  48.  
  49. local function formatargs(args,showkeys)
  50. if #args == 0 then return "N/A" end
  51. local strargs = {}
  52. for k,v in next,args do
  53. local argstr = ""
  54. if type(v) == "string" then
  55. argstr = "\"" .. v .. "\""
  56. elseif type(v) == "table" then
  57. argstr = "{" .. formatargs(v,true) .. "}"
  58. else
  59. argstr = tostring(v)
  60. end
  61. if showkeys and type(k) ~= "number" then
  62. table.insert(strargs,k.."="..argstr)
  63. else
  64. table.insert(strargs,argstr)
  65. end
  66. end
  67. return table.concat(strargs, ", ")
  68. end
  69.  
  70. local realmethods = {
  71. Fire = Instance.new("BindableEvent").Fire;
  72. Invoke = Instance.new("BindableFunction").Invoke;
  73. FireServer = Instance.new("RemoteEvent").FireServer;
  74. InvokeServer = Instance.new("RemoteFunction").InvokeServer;
  75. }
  76.  
  77. local hook = function(method)
  78. return function(...)
  79. local args = {...}
  80. local t,k = args[1],args[#args]
  81. if (k == "Fire" or k == "Invoke" or k == "FireServer" or k == "InvokeServer") and (enabled[t.ClassName] and not ignore[t.Name]) then
  82. local fake = function(self,...)
  83. local args = {...}
  84. local ret = {realmethods[k](self,...)}
  85. printtoconsole("RemoteSpy event:\n----------------------------------------\n[*] "..t.ClassName.." called!\n[*] Path: "..t:GetFullName().."\n[*] Args: "..formatargs(args).."\n[*] Return: "..formatargs(ret).."\n----------------------------------------")
  86. return unpack(ret)
  87. end
  88. table.remove(args,#args) -- the key is the only irrelevant argument for __namecall
  89. return method == "__namecall" and fake(unpack(args)) or fake
  90. else
  91. return oldmeta[method](...)
  92. end
  93. end
  94. end
  95.  
  96. meta.__namecall = hook("__namecall")
  97.  
  98. if enable_additional_hooking then
  99. meta.__index = hook("__index")
  100. end
Add Comment
Please, Sign In to add comment