DrawingJhon

FE Test

Dec 10th, 2020 (edited)
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.50 KB | None | 0 0
  1. local originals = setmetatable({}, {__mode = "k"})
  2. local wrappeds = setmetatable({}, {__mode = "v"})
  3. local customProperties = {}
  4.  
  5. local function argsFunc(f, ...)
  6.     local t={n=select("#",...),...}
  7.     for i=1,t.n do
  8.         t[i]=f(select(i,...))
  9.     end
  10.     return unpack(t,1,t.n)
  11. end
  12.  
  13. local function isInstance(obj)
  14.     return pcall(game.isA, obj, "Instance")
  15. end
  16.  
  17. local function eject(obj, functionName)
  18.     if not isInstance(obj) then error("Expected ':' not '.' calling member function "..functionName) end
  19. end
  20.  
  21. local function setmeta(meta, obj)
  22.     meta.__tostring = function()
  23.         return tostring(obj);
  24.     end
  25.     meta.__concat = function(v1, v2)
  26.         return wrap(wrap(v1) .. wrap(v2));
  27.     end
  28.     meta.__add = function(v1, v2)
  29.         return wrap(wrap(v1) + wrap(v2));
  30.     end
  31.     meta.__sub = function(v1, v2)
  32.         return wrap(wrap(v1) - wrap(v2));
  33.     end
  34.     meta.__mul = function(v1, v2)
  35.         return wrap(wrap(v1) * wrap(v2));
  36.      end
  37.     meta.__div = function(v1, v2)
  38.         return wrap(wrap(v1) / wrap(v2));
  39.     end
  40.     meta.__mod = function(v1, v2)
  41.         return wrap(wrap(v1) % wrap(v2));
  42.     end
  43.     meta.__pow = function(v1, v2)
  44.         return wrap(wrap(v1) ^ wrap(v2));
  45.     end
  46.     meta.__unm = function()
  47.         return wrap(-obj)
  48.     end
  49.     meta.__eq = function(v1, v2)
  50.         return wrap(wrap(v1) == wrap(v2));
  51.     end
  52.     meta.__lt = function(v1, v2)
  53.         return wrap(wrap(v1) < wrap(v2));
  54.     end
  55.     meta.__le = function(v1, v2)
  56.         return wrap(wrap(v1) <= wrap(v2));
  57.     end
  58.     meta.__len = function()
  59.         return wrap(#obj);
  60.     end
  61.     meta.__metatable = getmetatable(obj);
  62. end
  63.  
  64. function wrap(real)
  65.     local original = originals[real]
  66.     if original then
  67.         return original
  68.     end
  69.     local wrapped = wrappeds[real]
  70.     if wrapped then
  71.         return wrapped
  72.     end
  73.     if type(real) == "userdata" then
  74.         local fake = newproxy(true)
  75.         local meta = getmetatable(fake)
  76.         if isInstance(real) then
  77.             local class = real.ClassName
  78.             meta.__index = function(self, index)
  79.                 local customValue = customProperties["onread:"..class..":"..index] or customProperties["onread:Instance:"..index]
  80.                 local onIndex = customProperties["onindex:"..class] or customProperties["onindex:Instance"] or customProperties["onindex:"..class..":"..index] or customProperties["onindex:Instance:"..index]
  81.                 if onIndex then
  82.                     return wrap(onIndex(real, wrap(index)))
  83.                 elseif customValue then
  84.                     return wrap(customValue)
  85.                 else
  86.                     return wrap(real[wrap(index)])
  87.                 end
  88.             end
  89.             meta.__newindex = function(self, index, value)
  90.                 local onEdit = customProperties["onedit:"..class..":"..index] or customProperties["onedit:Instance:"..index]
  91.                 local onNewIndex = customProperties["onedit:"..class] or customProperties["onedit:Instance"]
  92.                 if onNewIndex then
  93.                     onNewIndex(real, wrap(index), wrap(value))
  94.                 elseif onEdit then
  95.                     onEdit(real, wrap(value))
  96.                 else
  97.                     real[wrap(index)] = wrap(value)
  98.                 end
  99.             end
  100.         else
  101.             meta.__index = function(self, index)
  102.                 return wrap(real[wrap(index)])
  103.             end
  104.             meta.__newindex = function(self, index, value)
  105.                 real[wrap(index)] = wrap(value)
  106.             end
  107.             meta.__call = function(self, ...)
  108.                 local args = wrap{...}
  109.                 local result = wrap{real(unpack(args))}
  110.                 return unpack(result)
  111.             end
  112.         end
  113.         setmeta(meta, real)
  114.         wrappeds[real] = fake
  115.         originals[fake] = real
  116.         return fake
  117.     elseif type(real) == "function" then
  118.         local fake = function(...)
  119.             return argsFunc(wrap, real(argsFunc(wrap, ...)))
  120.         end
  121.         wrappeds[real] = fake
  122.         originals[fake] = real
  123.         return fake
  124.     elseif type(real) == "table" then
  125.         local fake = {}
  126.         for i, v in pairs(real) do
  127.             fake[wrap(i)] = wrap(v)
  128.         end
  129.         if getmetatable(real) then
  130.             local meta = {}
  131.             meta.__index = function(self, index)
  132.                 return wrap(real[wrap(index)])
  133.             end
  134.             meta.__newindex = function(self, index, value)
  135.                 real[wrap(index)] = wrap(value)
  136.             end
  137.             meta.__call = function(self, ...)
  138.                 local fake = function(...)
  139.                     local args = wrap{...}
  140.                     local result = wrap{real(unpack(args))}
  141.                     return unpack(result)
  142.                 end
  143.                 originals[fake] = real
  144.                 wrappeds[real] = fake
  145.                 return fake
  146.             end
  147.             setmeta(meta, real)
  148.             setmetatable(fake, meta)
  149.         end
  150.         return fake
  151.     else
  152.         return real
  153.     end
  154. end
  155.  
  156. local LocalScript = NLS([==[local Event = script:WaitForChild("Remote")
  157. local ahh = script:waitForChild'GetClientProperty'
  158. local Mouse = owner:GetMouse()
  159. local UIS = game:GetService("UserInputService")
  160. local cam = workspace.CurrentCamera
  161. local mData = {'KeyDown','KeyUp','Button1Down','Button1Up','Button2Down','Button2Up'}
  162. local cData = {CFrame=nil,CoordinateFrame=nil,CameraSubject=nil,CameraType=nil,FieldOfView=nil,Focus=nil,HeadLocked=nil,HeadScale=nil,ViewportSize=nil}
  163. local onMouse = function(int, type)
  164.     Mouse[type]:connect(function(...)
  165.         Event:FireServer({Type='Mouse',Event=type:lower(),Args={...}})
  166.     end)
  167. end
  168. table.foreach(mData, onMouse)
  169. local input = function(type)
  170.     UIS[type]:connect(function(io,RobloxHandled)
  171.         if RobloxHandled then return end
  172.         Event:FireServer({Type='UserInput',Event=type:lower(),Args={{KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}, false}})
  173.     end)
  174. end
  175. input('InputBegan') input('InputChanged') input('InputEnded')
  176. UIS.TextBoxFocusReleased:connect(function(inst)
  177.     Event:FireServer{Type='TextboxReplication',TextBox=inst,Text=inst.Text}
  178. end)
  179. Event.OnClientEvent:Connect(function(action, data)
  180.     if action == "newindex" then
  181.         local obj = data.Instance
  182.         if obj == "Camera" then
  183.             cam[data.Index] = data.NewIndex
  184.         else
  185.             obj[data.Index] = data.NewIndex
  186.         end
  187.     end
  188. end)
  189. local h,t,x,y
  190. local HB = game:GetService("RunService").Heartbeat
  191. ahh.OnClientInvoke = function(wht, obj, int)
  192.     if wht == 'Ready' then
  193.         return true
  194.     elseif wht == 'GetProperty' then
  195.         return obj[int]
  196.     end
  197. end
  198. while true do
  199.     if h~=Mouse.Hit or t~=Mouse.Target or x~=Mouse.X or y~=Mouse.Y then
  200.         h,t=Mouse.Hit,Mouse.Target
  201.         Event:FireServer({Type='Mouse',Variables={Hit=h,Target=t,X=x,Y=y}})
  202.     end
  203.     local changed = false
  204.     local sentCam = {}
  205.     for prop, value in pairs(cData) do
  206.         if cam[prop] ~= value then
  207.             sentCam[prop] = cam[prop]
  208.             changed = true
  209.         end
  210.         cData[prop] = cam[prop]
  211.     end
  212.     if changed then
  213.         Event:FireServer({Type='Camera',Variables=sentCam})
  214.     end
  215.     for i=1,2 do
  216.         HB:Wait()
  217.     end
  218. end]==], owner.PlayerGui)
  219.  
  220. local Bindable = Instance.new("BindableEvent")
  221. local remote = Instance.new("RemoteEvent")
  222. remote.Name = "Remote"
  223. local GetProperty = Instance.new("RemoteFunction")
  224. GetProperty.Name = "GetClientProperty"
  225. GetProperty.Parent = LocalScript
  226. remote.Parent = LocalScript
  227. local Sounds = setmetatable({}, {__mode = "k"})
  228. local FakeCam = {
  229.     ["CFrame"] = CFrame.new();
  230.     ["CoordinateFrame"] = CFrame.new();
  231. }
  232.  
  233. local FakeMouse = {
  234.     ["Hit"] = CFrame.new();
  235.     ["Target"] = nil;
  236.     ["X"] = 0;
  237.     ["Y"] = 0;
  238. }
  239.  
  240. remote.OnServerEvent:Connect(function(plr, data)
  241.     if plr ~= owner then return end
  242.     if data.Type == "Camera" then
  243.         for i, v in next, data.Variables do
  244.             FakeCam[i] = v
  245.         end
  246.     elseif data.Type == "Mouse" and data.Variables then
  247.         for i, v in next, data.Variables do
  248.             FakeMouse[i] = v
  249.         end
  250.     elseif data.Type == "TextboxReplication" then
  251.         local tb = data.TextBox
  252.         if not tb then return end
  253.         local text = data.Text
  254.         tb.Text = text
  255.         Bindable:Fire{Type = "TextBox", Event = "FocusLost", Args = {tb}}
  256.     end
  257. end)
  258. local function RegSound(sound)
  259.     if not sound:IsA("Sound") then return end
  260.     game:GetService("RunService").Heartbeat:Connect(function()
  261.         if sound.Parent then
  262.             local pl = GetProperty:InvokeClient(owner, sound.Parent and "GetProperty" or "Ready", sound, "PlaybackLoudness")
  263.             if pl then
  264.                 Sounds[sound] = pl
  265.             end
  266.         end
  267.     end)
  268. end
  269. for i, v in pairs(workspace:GetDescendants()) do
  270.     RegSound(v)
  271. end
  272. workspace.DescendantAdded:Connect(RegSound)
  273.  
  274. customProperties = {
  275.     ["onread:Players:LocalPlayer,localPlayer"] = owner,
  276.     ["onread:RunService:RenderStepped,renderStepped"] = game:GetService("RunService").Heartbeat,
  277.     ["onread:Player:GetMouse,getMouse"] = function(plr)
  278.         eject(plr, "GetMouse")
  279.         if plr ~= owner then return end
  280.         local fake = newproxy(true)
  281.         local mt = getmetatable(fake)
  282.  
  283.         mt.__index = function(self, index)
  284.             if FakeMouse[index] then
  285.                 return FakeMouse[index]
  286.             elseif index == "x" then
  287.                 return FakeMouse.X
  288.             elseif index == "y" then
  289.                 return FakeMouse.Y
  290.             end
  291.             local ValidConns = {"KeyDown", "keyDown", "KeyUp", "keyUp", "Button1Down", "button1Down",
  292.             "Button1Up", "button1Up", "Button2Down", "button2Down", "Button2Up", "button2Up", "HitMoved",
  293.             "hitMoved"}
  294.             local function OnEvent(type)
  295.                 local ud = newproxy(true)
  296.                 local meta = getmetatable(ud)
  297.                 meta.__index = function(self, index)
  298.                     if index == "Connect" or index == "connect" then
  299.                         return function(self, func)
  300.                             if self ~= ud then
  301.                                 error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  302.                             end
  303.                             return remote.OnServerEvent:Connect(function(plr, data)
  304.                                 if plr ~= owner or data.Type ~= "Mouse" then return end
  305.                                 if data.Event == type:lower() then
  306.                                     local args = data.Args
  307.                                     local result = wrap(args)
  308.                                     func(unpack(result))
  309.                                 end
  310.                             end)
  311.                         end
  312.                     elseif index == "Wait" or index == "wait" then
  313.                         return function(self)
  314.                             if self ~= ud then
  315.                                 error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  316.                             end
  317.                             local result
  318.                             repeat
  319.                                 local plr, data = remote.OnServerEvent:Wait()
  320.                                 if plr == owner then
  321.                                     if data.Event == type:lower() then
  322.                                         result = data.Args
  323.                                     end
  324.                                 end
  325.                             until result
  326.                             return unpack(result)
  327.                         end
  328.                     end
  329.                     error(index.." is not valid member of RBXScriptSignal")
  330.                 end
  331.                 meta.__newindex = function(self, k, v)
  332.                     error(k..' is not valid member of PlayerMouse "Instance"')
  333.                 end
  334.                 meta.__tostring = function(self)
  335.                     return "Signal "..type
  336.                 end
  337.                 meta.__metatable = "The metatable is locked"
  338.                 meta.__call = function(self)
  339.                     error("attempt to call a RBXScriptSignal value")
  340.                 end
  341.                 return ud
  342.             end
  343.             if table.find(ValidConns, index) then
  344.                 return OnEvent(index)
  345.             end
  346.             error(index..' is not valid member of PlayerMouse "Instance"')
  347.         end
  348.         mt.__newindex = function(self, k, v)
  349.             error(k..' is not valid member of PlayerMouse "Instance"')
  350.         end
  351.         mt.__metatable = "The metatable is locked"
  352.         mt.__tostring = function(self)
  353.             return "Instance"
  354.         end
  355.         mt.__call = function(self)
  356.             error("attempt to call a "..tostring(self).." value")
  357.         end
  358.         return fake
  359.     end,
  360.     ["onindex:UserInputService"] = function(obj, index)
  361.         local ValidConns = {"InputChanged", "inputChanged", "InputBegan", "inputBegan", "InputEnded",
  362.         "inputEnded"}
  363.         local remote = wrap(remote)
  364.         local function OnEvent(type)
  365.             local ud = newproxy(true)
  366.             local meta = getmetatable(ud)
  367.             meta.__index = function(self, index)
  368.                 if index == "Connect" or index == "connect" then
  369.                     return function(self, func)
  370.                         if self ~= ud then
  371.                             error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  372.                         end
  373.                         return remote.OnServerEvent:Connect(function(plr, data)
  374.                             if plr ~= owner or data.Type ~= "UserInput" then return end
  375.                             if data.Event == type:lower() then
  376.                                 local args = data.Args
  377.                                 func(unpack(wrap(args)))
  378.                             end
  379.                         end)
  380.                     end
  381.                 elseif index == "Wait" or index == "wait" then
  382.                     return function(self)
  383.                         if self ~= ud then
  384.                             error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  385.                         end
  386.                         local result
  387.                         repeat
  388.                             local plr, data = remote.OnServerEvent:Wait()
  389.                             if plr == owner then
  390.                                 if data.Event == type:lower() then
  391.                                     result = data.Args
  392.                                 end
  393.                             end
  394.                         until result
  395.                         return unpack(result)
  396.                     end
  397.                 end
  398.                 error(index.." is not valid member of RBXScriptSignal")
  399.             end
  400.             meta.__newindex = function(self, k, v)
  401.                 error(k..' cannot be assigned to')
  402.             end
  403.             meta.__tostring = function(self)
  404.                 return "Signal "..type
  405.             end
  406.             meta.__metatable = "The metatable is locked"
  407.             meta.__call = function(self)
  408.                 error("attempt to call a "..tostring(self).." value")
  409.             end
  410.             return ud
  411.         end
  412.         if table.find(ValidConns, index) then
  413.             return OnEvent(index)
  414.         end
  415.         error(index..' is not valid member of UserInputService "Instance"')        
  416.     end,
  417.     ["onindex:Camera"] = function(obj, index)
  418.         local prop = obj[index]
  419.         return FakeCam[index] or prop
  420.     end,
  421.     ["onedit:Camera"] = function(obj, i, v)
  422.         local bruh = obj[i]
  423.         if obj == workspace.CurrentCamera then
  424.             remote:FireClient(owner, "newindex", {Instance = "Camera", Index = i, NewIndex = v})
  425.         else
  426.             remote:FireClient(owner, "newindex", {Instance = obj, Index = i, NewIndex = v})
  427.         end
  428.     end,
  429.     ["onindex:Sound:PlaybackLoudness"] = function(obj, index)
  430.         local result = Sounds[obj]
  431.         return result or obj[index]
  432.     end,
  433.     ["onindex:TextBox:FocusLost,focusLost"] = function(obj, index)
  434.         local ud = newproxy(true)
  435.         local meta = getmetatable(ud)
  436.         meta.__index = function(self, index)
  437.             if index == "Connect" or index == "connect" then
  438.                 return function(self, func)
  439.                     if self ~= ud then
  440.                         error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  441.                     end
  442.                     return Bindable.Event:Connect(function(data)
  443.                         if data.Type ~= "TextBox" then return end
  444.                         if data.Event == "FocusLost" then
  445.                             local tb = data.Args[1]
  446.                             if tb == obj then
  447.                                 local args = data.Args
  448.                                 local result = wrap(args)
  449.                                 func(unpack(result))
  450.                             end
  451.                         end
  452.                     end)
  453.                 end
  454.             elseif index == "Wait" or index == "wait" then
  455.                 return function(self)
  456.                     if self ~= ud then
  457.                         error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  458.                     end
  459.                     local result
  460.                     repeat wait()
  461.                         local data = Bindable.Event:Wait()
  462.                         if data.Event == "FocusLost" then
  463.                             local textbox = data.Args[1]
  464.                             if textbox == obj then
  465.                                 result = data.Args
  466.                             end
  467.                         end
  468.                     until result
  469.                     return unpack(result)
  470.                 end
  471.             end
  472.             error(index.." is not valid member of RBXScriptSignal")
  473.         end
  474.         meta.__newindex = function(self, k, v)
  475.             error(k..' cannot be assigned to')
  476.         end
  477.         meta.__tostring = function(self)
  478.             return "Signal "..type
  479.         end
  480.         meta.__metatable = "The metatable is locked"
  481.         meta.__call = function(self)
  482.             error("attempt to call a "..tostring(self).." value")
  483.         end
  484.         return ud
  485.     end
  486. }
  487. do
  488.     local modifiedCustomProperties = {};
  489.     local modifiedcustomLibrary = {};
  490.     for data, value in next, customProperties do
  491.         local behavior, class, props = string.match(data, "(%a+):(%a+):(.+)");
  492.         if props then
  493.             for prop in string.gmatch(props, "[^,]+") do
  494.                 modifiedCustomProperties[behavior..":"..class..":"..prop] = value;
  495.             end
  496.         else
  497.             modifiedCustomProperties[data] = value
  498.         end
  499.     end
  500.     customProperties = modifiedCustomProperties;
  501. end
  502.  
  503. repeat wait() until GetProperty:InvokeClient(owner, "Ready")
  504. local http = game:GetService("HttpService"):GetAsync("https://pastebin.com/raw/EEKTXf2S")
  505. local Loadstring = loadstring(http, "Bruh")
  506. if Loadstring then
  507.     local env = getfenv(Loadstring)
  508.     local FakeEnv = {}
  509.     setfenv(Loadstring, setmetatable({script = wrap(script), owner = wrap(owner)}, {
  510.         __index = function(self, k)
  511.             local lib = env[k]
  512.             if wrappeds[lib] then
  513.                 return wrappeds[lib]
  514.             end
  515.             return wrap(env[k])
  516.         end,
  517.         __metatable = getmetatable(env)
  518.     }))
  519.     print("Running...")
  520.     Loadstring()
  521. end
Add Comment
Please, Sign In to add comment