AlphaSploit

Vaeb's RemoteSpy

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