Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Place your loadstring here for testing
- local loadstringInput = [[
- -- Example loadstring (replace this with your own)
- print("Hello from the sandbox!")
- ]]
- -- Sandbox Script
- local function sandboxedLoader(input)
- -- Create a sandbox environment
- local sandboxEnv = {
- print = print, -- Allow harmless functions
- pairs = pairs,
- ipairs = ipairs,
- tonumber = tonumber,
- tostring = tostring,
- math = math,
- string = string,
- table = table,
- }
- -- Restrict sensitive functions
- setmetatable(sandboxEnv, { __index = function(_, key)
- error("Access to " .. tostring(key) .. " is restricted in this sandbox!", 0)
- end })
- -- Load the input in the sandbox
- local func, loadError = loadstring(input)
- if not func then
- return false, "Error loading script: " .. loadError
- end
- setfenv(func, sandboxEnv) -- Set the environment to the sandbox
- local success, result = pcall(func)
- if not success then
- return false, "Error executing script: " .. result
- end
- -- Analyze the result for suspicious behavior
- -- Add custom checks here if needed (e.g., scanning script content)
- return true, "Script executed safely!"
- end
- -- Run the sandbox
- local status, message = sandboxedLoader(loadstringInput)
- if status then
- print("Result: Safe - " .. message)
- else
- print("Result: Suspicious - " .. message)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement