Advertisement
Vzurxy

Untitled

Jul 27th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.06 KB | None | 0 0
  1. --[[
  2.  
  3. -Vaeb's RemoteSpy.
  4.  
  5. ]]
  6.  
  7. _G.scanRemotes = true --
  8. _G.CopyRemoteCallMethodToClipboard = true
  9.  
  10. _G.ignoreNames = {
  11. Event = true;
  12. MessagesChanged = true;
  13. }
  14.  
  15. local pseudoEnv = {}
  16. local gameMeta = getrawmetatable(game)
  17. setreadonly(gameMeta,false)
  18.  
  19. local tabChar = " "
  20. local NumberOfRemotesRan = 0
  21. local function getSmaller(a, b, notLast)
  22. local aByte = a:byte() or -1
  23. local bByte = b:byte() or -1
  24. if aByte == bByte then
  25. if notLast and #a == 1 and #b == 1 then
  26. return -1
  27. elseif #b == 1 then
  28. return false
  29. elseif #a == 1 then
  30. return true
  31. else
  32. return getSmaller(a:sub(2), b:sub(2), notLast)
  33. end
  34. else
  35. return aByte < bByte
  36. end
  37. end
  38.  
  39. local function parseData(obj, numTabs, isk, overflow, noTables, forceDict)
  40. local objType = typeof(obj)
  41. local objStr = tostring(obj)
  42. if objType == "table" then
  43. if noTables then
  44. return objStr
  45. end
  46. local isCyclic = overflow[obj]
  47. overflow[obj] = true
  48. local out = {}
  49. local nextIndex = 1
  50. local isDict = false
  51. local hasTables = false
  52. local data = {}
  53.  
  54. for k, val in next, obj do
  55. if not hasTables and typeof(val) == "table" then
  56. hasTables = true
  57. end
  58.  
  59. if not isDict and k ~= nextIndex then
  60. isDict = true
  61. else
  62. nextIndex = nextIndex + 1
  63. end
  64.  
  65. data[#data+1] = {k, val}
  66. end
  67.  
  68. if isDict or hasTables or forceDict then
  69. out[#out+1] = (isCyclic and "Cyclic " or "")
  70. table.sort(data, function(a, b)
  71. local aType = typeof(a[2])
  72. local bType = typeof(b[2])
  73. if bType == "string" and aType ~= "string" then
  74. return false
  75. end
  76. local res = getSmaller(aType, bType, true)
  77. if res == -1 then
  78. return getSmaller(tostring(a[1]), tostring(b[1]))
  79. else
  80. return res
  81. end
  82. end)
  83. for i = 1, #data do
  84. local arr = data[i]
  85. local nowk = arr[1]
  86. local nowVal = arr[2]
  87. local parsek = parseData(nowk, numTabs+1, true, overflow, isCyclic)
  88. local parseVal = parseData(nowVal, numTabs+1, false, overflow, isCyclic)
  89. if isDict then
  90. local nowValType = typeof(nowVal)
  91. local preStr = ""
  92. local postStr = ""
  93. if i > 1 and (nowValType == "table" or typeof(data[i-1][2]) ~= nowValType) then
  94. preStr = "\n"
  95. end
  96. if i < #data and nowValType == "table" and typeof(data[i+1][2]) ~= "table" and typeof(data[i+1][2]) == nowValType then
  97. postStr = "\n"
  98. end
  99. out[#out+1] = preStr .. string.rep(tabChar, numTabs+1) .. parsek .. " = " .. parseVal .. ";" .. postStr
  100. else
  101. out[#out+1] = string.rep(tabChar, numTabs+1) .. parseVal .. ";"
  102. end
  103. end
  104. out[#out+1] = string.rep(tabChar, numTabs)
  105. else
  106. local data2 = {}
  107. for i = 1, #data do
  108. local arr = data[i]
  109. local nowVal = arr[2]
  110. local parseVal = parseData(nowVal, 0, false, overflow, isCyclic)
  111. data2[#data2+1] = parseVal
  112. end
  113. out[#out+1] = "{" .. table.concat(data2, ", ") .. "}"
  114. end
  115.  
  116. return table.concat(out, "\n")
  117. else
  118. local returnVal = nil
  119. if (objType == "string" or objType == "Content") and (not isk or tonumber(obj:sub(1, 1))) then
  120. local retVal = '"' .. objStr .. '"'
  121. if isk then
  122. retVal = "[" .. retVal .. "]"
  123. end
  124. returnVal = retVal
  125. elseif objType == "EnumItem" then
  126. returnVal = "Enum." .. tostring(obj.EnumType) .. "." .. obj.Name
  127. elseif objType == "Enum" then
  128. returnVal = "Enum." .. objStr
  129. elseif objType == "Instance" then
  130. returnVal = obj.Parent and obj:GetFullName() or obj.ClassName
  131. elseif objType == "CFrame" then
  132. returnVal = "CFrame.new(" .. objStr .. ")"
  133. elseif objType == "Vector3" then
  134. returnVal = "Vector3.new(" .. objStr .. ")"
  135. elseif objType == "Vector2" then
  136. returnVal = "Vector2.new(" .. objStr .. ")"
  137. elseif objType == "UDim2" then
  138. returnVal = "UDim2.new(" .. objStr:gsub("[{}]", "") .. ")"
  139. elseif objType == "BrickColor" then
  140. returnVal = "BrickColor.new(\"" .. objStr .. "\")"
  141. elseif objType == "Color3" then
  142. returnVal = "Color3.new(" .. objStr .. ")"
  143. elseif objType == "NumberRange" then
  144. returnVal = "NumberRange.new(" .. objStr:gsub("^%s*(.-)%s*$", "%1"):gsub(" ", ", ") .. ")"
  145. elseif objType == "PhysicalProperties" then
  146. returnVal = "PhysicalProperties.new(" .. objStr .. ")"
  147. else
  148. returnVal = objStr
  149. end
  150. return returnVal
  151. end
  152. end
  153.  
  154. function tableToString(t)
  155. return parseData(t, 0, false, {}, nil, false)
  156. end
  157.  
  158. local detectClasses = {
  159. BindableEvent = false;
  160. BindableFunction = false;
  161. RemoteEvent = true;
  162. RemoteFunction = true;
  163. }
  164.  
  165. local classMethods = {
  166. BindableEvent = "Fire";
  167. BindableFunction = "Invoke";
  168. RemoteEvent = "FireServer";
  169. RemoteFunction = "InvokeServer";
  170. }
  171.  
  172. local realMethods = {}
  173.  
  174. for name, enabled in next, detectClasses do
  175. if enabled then
  176. realMethods[classMethods[name]] = Instance.new(name)[classMethods[name]]
  177. end
  178. end
  179.  
  180. for k, value in next, gameMeta do pseudoEnv[k] = value end
  181.  
  182. local incId = 0
  183.  
  184. local function getValues(t, k, ...)
  185. return {realMethods[k](t, ...)}
  186. end
  187.  
  188. gameMeta.__index, gameMeta.__namecall = function(t, k)
  189. if not realMethods[k] or _G.ignoreNames[t.Name] or not _G.scanRemotes then return pseudoEnv.__index(t, k) end
  190. return function(_, ...)
  191.  
  192. local allPassed = {...}
  193. local returnValues = {}
  194. local scriptcaller = getfenv(2).script
  195. if scriptcaller == nil then
  196. scriptcaller = "Not Found"
  197. end
  198. local args = string.sub(tableToString(allPassed), 2, string.len(tableToString(allPassed))-1)
  199. if args == "" then
  200. args = "N/A"
  201. end
  202. local ok, data = pcall(getValues, t, k, ...)
  203. if ok then
  204. returnValues = data
  205. local returns = string.sub(tableToString(returnValues), 2, string.len(tableToString(returnValues))-1)
  206. if returns == "" then
  207. returns = "N/A"
  208. end
  209. else
  210. returns = "An unexpected error has occured in Vaeb's remotespy."
  211. end
  212. NumberOfRemotesRan = NumberOfRemotesRan+1
  213. if string.find(t.ClassName, "Event") then
  214. print()
  215. warn("Number of remotes ran since this instance of Vaeb's RemoteSpy has been executed: " .. NumberOfRemotesRan .. ".\nA " .. t.ClassName .. " was called.\nRemote name: " .. t.Name .. "\nCalled from: game." .. tostring(scriptcaller:GetFullName()) .. "\nRemote path: game." .. t:GetFullName() .. "\n" .. "Method: " .. k .. "\n" .. "Remote arguments: " .. args .. "\nCall method: game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")\n")
  216. if _G.CopyRemoteCallMethodToClipboard == true then
  217. Synapse:CopyString("game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")")
  218. end
  219. elseif string.find(t.ClassName, "Function") then
  220. print()
  221. warn("Number of remotes ran since this instance of Vaeb's RemoteSpy has been executed: " .. NumberOfRemotesRan .. ".\nA " .. t.ClassName .. " was called.\nRemote name: " .. t.Name .. "\nCalled from: game." .. tostring(scriptcaller:GetFullName()) .. "\nRemote path: game." .. t:GetFullName() .. "\n" .. "Method: " .. k .. "\n" .. "Remote arguments: " .. args .. "\nReturned values: " .. returns .. "\nCall method: game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")\n")
  222. if _G.CopyRemoteCallMethodToClipboard == true then
  223. Synapse:CopyString("game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")")
  224. end
  225. else
  226. print()
  227. warn("An unexpected error has occured in determining if it's an event or a function.")
  228. warn("Number of remotes ran since this instance of Vaeb's RemoteSpy has been executed: " .. NumberOfRemotesRan .. ".\nA " .. t.ClassName .. " was called.\nRemote name: " .. t.Name .. "\nCalled from: game." .. tostring(scriptcaller:GetFullName()) .. "\nRemote path: game." .. t:GetFullName() .. "\n" .. "Method: " .. k .. "\n" .. "Remote arguments: " .. args .. "\nReturned values: " .. returns .. "\nCall method: game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")\n")
  229. if _G.CopyRemoteCallMethodToClipboard == true then
  230. Synapse:CopyString("game." .. t:GetFullName() .. ":" .. k .. "(" .. args .. ")")
  231. end
  232. end
  233.  
  234. return unpack(returnValues)
  235. end
  236. end
  237.  
  238. print()
  239. warn("Ran Vaeb's RemoteSpy\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement