-- sandbox environment prepended to the loader carrier local _realprint = print local _logparts = {} local function _log(...) local p = {} for i = 1, select('#', ...) do p[i] = tostring(select(i, ...)) end _realprint('[SB] ' .. table.concat(p, ' ')) end local function _proxy(name) local t = {} local mt = {} mt.__index = function(self, k) _log('IDX', name, tostring(k)) local c = _proxy(name .. '.' .. tostring(k)) rawset(self, k, c) return c end mt.__call = function(self, ...) local a = {} for i = 1, select('#', ...) do a[i] = tostring(select(i, ...)) end _log('CALL', name, table.concat(a, ',')) return _proxy(name .. '()') end mt.__tostring = function() return '<' .. name .. '>' end mt.__concat = function(a, b) return tostring(a) .. tostring(b) end mt.__len = function() return 0 end mt.__eq = function() return false end mt.__lt = function() return false end mt.__le = function() return false end setmetatable(t, mt) return t end local _ws_instances = {} local _ws_queue = {} local WS = {} WS.__index = WS function WS.new(url) _log('WS.CONNECT', tostring(url)) local self = setmetatable({url = url, onmessage = nil, queue = {}}, WS) table.insert(_ws_instances, self) return self end function WS:Send(msg) _log('WS.SEND', tostring(msg)) return true end function WS:Close() _log('WS.CLOSE', tostring(self.url)) end function WS:Receive() _log('WS.RECEIVE') return nil end function WS:OnMessage(cb) _log('WS.ONMESSAGE_REG', tostring(cb)) self.onmessage = cb for _, m in ipairs(self.queue) do cb(m) end self.queue = {} end function WS:deliver(msg) _log('WS.DELIVER', tostring(msg)) if self.onmessage then self.onmessage(msg) else table.insert(self.queue, msg) end end local _HELLO = '{"type":"hello","v":3,"nonce":"9c9b8e3ba23e07ae33c2615af647e15b","ts":"1792726469"}' WS.OnMessage = setmetatable({}, { __index = function(t, k) return function(self, cb) _log('WS.EVT_CONNECT', tostring(k), tostring(cb)) if tostring(k) == 'Connect' then self.onmessage = cb _log('WS.DELIVER_HELLO') local ok, err = pcall(cb, _HELLO) _log('WS.HELLO_CB', tostring(ok), tostring(err)) end end end, }) local _sandbox = {} _sandbox.print = print _sandbox.warn = function(...) _log('WARN', ...) end _sandbox.error = error _sandbox.assert = assert _sandbox.pcall = pcall _sandbox.xpcall = xpcall _sandbox.type = type _sandbox.tostring = tostring _sandbox.tonumber = tonumber _sandbox.select = select _sandbox.next = next _sandbox.pairs = pairs _sandbox.ipairs = ipairs _sandbox.unpack = table.unpack _sandbox.rawget = rawget _sandbox.rawset = rawset _sandbox.rawequal = rawequal _sandbox.setmetatable = setmetatable _sandbox.getmetatable = getmetatable _sandbox.string = string _sandbox.table = table _sandbox.math = math _sandbox.bit32 = bit32 _sandbox.buffer = buffer _sandbox.coroutine = coroutine _sandbox.debug = debug _sandbox.os = os _sandbox.loadstring = loadstring _sandbox.load = load _sandbox.getfenv = getfenv _sandbox.setfenv = setfenv _sandbox.require = function(...) _log('REQUIRE', ...); return _proxy('require()') end _sandbox.identifyexecutor = function() _log('IDENTIFYEXECUTOR'); return 'sandbox', '1.0' end _sandbox.getexecutorname = function() return 'sandbox' end _sandbox.getgenv = function() _log('GETGENV'); return _sandbox end _sandbox.getrenv = function() return _sandbox end _sandbox.getreg = function() return _proxy('getreg()') end _sandbox.tick = function() return os.clock() end _sandbox.time = function() return os.time() end _sandbox.wait = function(t) _log('WAIT', tostring(t)); return t end _sandbox.task = { wait = function(t) _log('TASK.WAIT', tostring(t)); return t end, spawn = function(f, ...) _log('TASK.SPAWN', tostring(f)); return f(...) end, delay = function(t, f, ...) _log('TASK.DELAY', tostring(t), tostring(f)); return f(...) end, defer = function(f, ...) _log('TASK.DEFER', tostring(f)); return f(...) end, } _sandbox.request = function(t) _log('REQUEST', tostring(t and t.Url)) return { Success = true, StatusCode = 200, Body = '{}', Headers = {} } end _sandbox.http_request = _sandbox.request _sandbox.syn = { request = _sandbox.request, websocket = { connect = function(url) return WS.new(url) end } } _sandbox.websocket = { connect = function(url) return WS.new(url) end } _sandbox.WebSocket = { connect = function(url) return WS.new(url) end } _sandbox.readfile = function(p) _log('READFILE', tostring(p)); return nil end _sandbox.writefile = function(p, c) _log('WRITEFILE', tostring(p), tostring(c)) end _sandbox.isfile = function(p) _log('ISFILE', tostring(p)); return false end _sandbox.makefolder = function(p) _log('MAKEFOLDER', tostring(p)) end _sandbox.setclipboard = function(s) _log('SETCLIPBOARD', tostring(s)) end _sandbox.script_key = 'ZzVseIY2FGhANzWACUU16XQMHVfVsiC9' local function _json_decode(s) local t = {} for k, v in tostring(s):gmatch('"([%w_%-]+)"%s*:%s*"([^"]*)"') do t[k] = v end for k, v in tostring(s):gmatch('"([%w_%-]+)"%s*:%s*(-?%d+%.?%d*)') do t[k] = tonumber(v) end for k, v in tostring(s):gmatch('"([%w_%-]+)"%s*:%s*(%a+)') do if v == 'true' then t[k] = true elseif v == 'false' then t[k] = false end end return t end local _http = {} _http.JSONDecode = function(self, s) _log('JSONDECODE', tostring(s)); return _json_decode(s) end _http.JSONEncode = function(self, t) local parts = {} for k, v in pairs(t) do _log('JSONENCODE_FIELD', tostring(k), type(v), tostring(v)) local sv if type(v) == 'string' then sv = '"'..v:gsub('"','\\"')..'"' elseif type(v) == 'number' or type(v) == 'boolean' then sv = tostring(v) else sv = '"<'..type(v)..'>"' end table.insert(parts, '"'..k..'":'..sv) end return '{'..table.concat(parts, ',')..'}' end _http.GetAsync = function(self, url) _log('HTTP.GETASYNC', tostring(url)); return '' end _http.PostAsync = function(self, url, body, ct) _log('HTTP.POSTASYNC', tostring(url), tostring(body)); return '' end _http.RequestAsync = function(self, opts) _log('HTTP.REQUESTASYNC', tostring(opts and opts.Url)); return {Success=true, StatusCode=200, Body='{}'} end local game = _proxy('game') game.GetService = function(self, name) _log('GETSERVICE', tostring(name)) if tostring(name) == 'HttpService' then return _http end return _proxy('service:' .. tostring(name)) end game.HttpGet = function(self, url, ...) _log('GAME.HTTPGET', tostring(url)); return '' end game.HttpGetAsync = game.HttpGet game.PlaceId = 0 game.JobId = 'sandbox' game.GameId = 0 _sandbox.game = game _sandbox.workspace = _proxy('workspace') _sandbox.Workspace = _sandbox.workspace _sandbox.Instance = { new = function(cls) _log('INSTANCE.NEW', tostring(cls)); return _proxy('Instance:' .. tostring(cls)) end } _sandbox.Vector3 = { new = function(...) return _proxy('Vector3') end } _sandbox.Vector2 = { new = function(...) return _proxy('Vector2') end } _sandbox.CFrame = { new = function(...) return _proxy('CFrame') end } _sandbox.Color3 = { new = function(...) return _proxy('Color3') end } _sandbox.UDim2 = { new = function(...) return _proxy('UDim2') end } _sandbox.Enum = _proxy('Enum') _sandbox.EnumItem = _proxy('EnumItem') _sandbox.TweenInfo = { new = function(...) return _proxy('TweenInfo') end } _sandbox.Ray = { new = function(...) return _proxy('Ray') end } _sandbox.loadstring = loadstring _sandbox.shared = {} _sandbox._WS = { instances = _ws_instances, queue = _ws_queue } _sandbox._log = _log setmetatable(_sandbox, { __index = function(t, k) _log('GLOBAL MISSING', tostring(k)) local p = _proxy(tostring(k)) rawset(t, k, p) return p end, }) _SANDBOX_ENV = _sandbox _sandbox.gethwid = function() _log('GETHWID'); return 'HWID-TEST-0001' end _sandbox.get_hwid = _sandbox.gethwid _sandbox.getdeviceid = _sandbox.gethwid _sandbox.get_device_id = _sandbox.gethwid _sandbox.fluxus = { get_hwid = _sandbox.gethwid } _sandbox.crypt = { generatebytes = function(n) _log('CRYPT.GEN', tostring(n)); return string.rep('A', tonumber(n) or 16) end } _sandbox.crypt.base64 = function(s) return s end _sandbox.crypt.hash = function(s) return 'HASH' end