Advertisement
Guest User

vaeb remotespy

a guest
Apr 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. _G.scanRemotes = true
  2.  
  3. _G.ignoreNames = {
  4. Event = true;
  5. MessagesChanged = true;
  6. }
  7.  
  8. setreadonly(getrawmetatable(game), false)
  9. local pseudoEnv = {}
  10. local gameMeta = getrawmetatable(game)
  11.  
  12. local tabChar = " "
  13.  
  14. local function getSmaller(a, b, notLast)
  15. local aByte = a:byte() or -1
  16. local bByte = b:byte() or -1
  17. if aByte == bByte then
  18. if notLast and #a == 1 and #b == 1 then
  19. return -1
  20. elseif #b == 1 then
  21. return false
  22. elseif #a == 1 then
  23. return true
  24. else
  25. return getSmaller(a:sub(2), b:sub(2), notLast)
  26. end
  27. else
  28. return aByte < bByte
  29. end
  30. end
  31.  
  32. local function parseData(obj, numTabs, isKey, overflow, noTables, forceDict)
  33. local objType = typeof(obj)
  34. local objStr = tostring(obj)
  35. if objType == "table" then
  36. if noTables then
  37. return objStr
  38. end
  39. local isCyclic = overflow[obj]
  40. overflow[obj] = true
  41. local out = {}
  42. local nextIndex = 1
  43. local isDict = false
  44. local hasTables = false
  45. local data = {}
  46.  
  47. for key, val in next, obj do
  48. if not hasTables and typeof(val) == "table" then
  49. hasTables = true
  50. end
  51.  
  52. if not isDict and key ~= nextIndex then
  53. isDict = true
  54. else
  55. nextIndex = nextIndex + 1
  56. end
  57.  
  58. data[#data+1] = {key, val}
  59. end
  60.  
  61. if isDict or hasTables or forceDict then
  62. out[#out+1] = (isCyclic and "Cyclic " or "") .. "{"
  63. table.sort(data, function(a, b)
  64. local aType = typeof(a[2])
  65. local bType = typeof(b[2])
  66. if bType == "string" and aType ~= "string" then
  67. return false
  68. end
  69. local res = getSmaller(aType, bType, true)
  70. if res == -1 then
  71. return getSmaller(tostring(a[1]), tostring(b[1]))
  72. else
  73. return res
  74. end
  75. end)
  76. for i = 1, #data do
  77. local arr = data[i]
  78. local nowKey = arr[1]
  79. local nowVal = arr[2]
  80. local parseKey = parseData(nowKey, numTabs+1, true, overflow, isCyclic)
  81. local parseVal = parseData(nowVal, numTabs+1, false, overflow, isCyclic)
  82. if isDict then
  83. local nowValType = typeof(nowVal)
  84. local preStr = ""
  85. local postStr = ""
  86. if i > 1 and (nowValType == "table" or typeof(data[i-1][2]) ~= nowValType) then
  87. preStr = "\n"
  88. end
  89. if i < #data and nowValType == "table" and typeof(data[i+1][2]) ~= "table" and typeof(data[i+1][2]) == nowValType then
  90. postStr = "\n"
  91. end
  92. out[#out+1] = preStr .. string.rep(tabChar, numTabs+1) .. parseKey .. " = " .. parseVal .. ";" .. postStr
  93. else
  94. out[#out+1] = string.rep(tabChar, numTabs+1) .. parseVal .. ";"
  95. end
  96. end
  97. out[#out+1] = string.rep(tabChar, numTabs) .. "}"
  98. else
  99. local data2 = {}
  100. for i = 1, #data do
  101. local arr = data[i]
  102. local nowVal = arr[2]
  103. local parseVal = parseData(nowVal, 0, false, overflow, isCyclic)
  104. data2[#data2+1] = parseVal
  105. end
  106. out[#out+1] = "{" .. table.concat(data2, ", ") .. "}"
  107. end
  108.  
  109. return table.concat(out, "\n")
  110. else
  111. local returnVal = nil
  112. if (objType == "string" or objType == "Content") and (not isKey or tonumber(obj:sub(1, 1))) then
  113. local retVal = '"' .. objStr .. '"'
  114. if isKey then
  115. retVal = "[" .. retVal .. "]"
  116. end
  117. returnVal = retVal
  118. elseif objType == "EnumItem" then
  119. returnVal = "Enum." .. tostring(obj.EnumType) .. "." .. obj.Name
  120. elseif objType == "Enum" then
  121. returnVal = "Enum." .. objStr
  122. elseif objType == "Instance" then
  123. returnVal = obj.Parent and obj:GetFullName() or obj.ClassName
  124. elseif objType == "CFrame" then
  125. returnVal = "CFrame.new(" .. objStr .. ")"
  126. elseif objType == "Vector3" then
  127. returnVal = "Vector3.new(" .. objStr .. ")"
  128. elseif objType == "Vector2" then
  129. returnVal = "Vector2.new(" .. objStr .. ")"
  130. elseif objType == "UDim2" then
  131. returnVal = "UDim2.new(" .. objStr:gsub("[{}]", "") .. ")"
  132. elseif objType == "BrickColor" then
  133. returnVal = "BrickColor.new(\"" .. objStr .. "\")"
  134. elseif objType == "Color3" then
  135. returnVal = "Color3.new(" .. objStr .. ")"
  136. elseif objType == "NumberRange" then
  137. returnVal = "NumberRange.new(" .. objStr:gsub("^%s*(.-)%s*$", "%1"):gsub(" ", ", ") .. ")"
  138. elseif objType == "PhysicalProperties" then
  139. returnVal = "PhysicalProperties.new(" .. objStr .. ")"
  140. else
  141. returnVal = objStr
  142. end
  143. return returnVal
  144. end
  145. end
  146.  
  147. function tableToString(t)
  148. return parseData(t, 0, false, {}, nil, false)
  149. end
  150.  
  151. local detectClasses = {
  152. BindableEvent = true;
  153. BindableFunction = true;
  154. RemoteEvent = true;
  155. RemoteFunction = true;
  156. }
  157.  
  158. local classMethods = {
  159. BindableEvent = "Fire";
  160. BindableFunction = "Invoke";
  161. RemoteEvent = "FireServer";
  162. RemoteFunction = "InvokeServer";
  163. }
  164.  
  165. local realMethods = {}
  166.  
  167. for name, enabled in next, detectClasses do
  168. if enabled then
  169. realMethods[classMethods[name]] = Instance.new(name)[classMethods[name]]
  170. end
  171. end
  172.  
  173. for key, value in next, gameMeta do pseudoEnv[key] = value end
  174.  
  175. local incId = 0
  176.  
  177. local function getValues(self, key, ...)
  178. return {realMethods[key](self, ...)}
  179. end
  180.  
  181. gameMeta.__index, gameMeta.__namecall = function(self, key)
  182. if not realMethods[key] or _G.ignoreNames[self.Name] or not _G.scanRemotes then return pseudoEnv.__index(self, key) end
  183. return function(_, ...)
  184. incId = incId + 1
  185. local nowId = incId
  186. local strId = "[RemoteSpy_" .. nowId .. "]"
  187.  
  188. local allPassed = {...}
  189. local returnValues = {}
  190.  
  191. local ok, data = pcall(getValues, self, key, ...)
  192.  
  193. if ok then
  194. returnValues = data
  195. print("\n" .. strId .. " ClassName: " .. self.ClassName .. " | Path: " .. self:GetFullName() .. " | Method: " .. key .. "\n" .. strId .. " Packed Arguments: " .. tableToString(allPassed) .. "\n" .. strId .. " Packed Returned: " .. tableToString(returnValues) .. "\n")
  196. else
  197. print("\n" .. strId .. " ClassName: " .. self.ClassName .. " | Path: " .. self:GetFullName() .. " | Method: " .. key .. "\n" .. strId .. " Packed Arguments: " .. tableToString(allPassed) .. "\n" .. strId .. " Packed Returned: [ERROR] " .. data .. "\n")
  198. end
  199.  
  200. return unpack(returnValues)
  201. end
  202. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement