Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Roblox -- Universal -- Custom functions
- -- This is only for exploits
- -- Put the script in autoexec folder
- local LogService = game:GetService("LogService")
- local ScriptContext = game:GetService("ScriptContext")
- local oldIndex = nil
- local oldNamecall = nil
- local protectedInstances = {}
- local function modifyConstantsFromClosure(closure : (...any) -> any, constantType : string, constantToChange : any, newConstant : any)
- for index, constant in getconstants(closure) do
- if typeof(constant) == constantType and constant == constantToChange then
- setconstant(closure, index, newConstant)
- end
- end
- end
- local function modifyConstantsFromScript(script : LocalScript | ModuleScript, constantType : string, constantToChange : any, newConstant : any)
- local closure = getscriptclosure(script)
- for index, constant in getconstants(closure) do
- if typeof(constant) == constantType and constant == constantToChange then
- setconstant(closure, index, newConstant)
- end
- end
- end
- local function displayConstantsFromClosure(closure : (...any) -> any)
- print("------ Constant Display ------")
- for index, constant in getconstants(closure) do
- if typeof(constant) == "function" then
- print(index, debug.getinfo(constant).name .. " " .. "(function)")
- continue
- end
- print(index, constant)
- end
- end
- local function displayConstantsFromScript(script : LocalScript | ModuleScript)
- print("------ Constant Display ------")
- local closure = getscriptclosure(script)
- for index, constant in getconstants(closure) do
- if typeof(constant) == "function" then
- print(index, debug.getinfo(constant).name .. " " .. "(function)")
- continue
- end
- print(index, constant)
- end
- end
- local function modifyUpValuesFromClosure(closure : (...any) -> any, upValueType : string, upValueToChange : any, newUpValue : any)
- for index, upValue in getupvalues(closure) do
- if typeof(upValue) == upValueType and upValue == upValueToChange then
- setupvalue(closure, index, newUpValue)
- end
- end
- end
- local function modifyUpValuesFromScript(script : LocalScript | ModuleScript, upValueType : string, upValueToChange : any, newUpValue : any)
- local closure = getscriptclosure(script)
- for index, upValue in getupvalues(closure) do
- if typeof(upValue) == upValueType and upValue == upValueToChange then
- setupvalue(closure, index, newUpValue)
- end
- end
- end
- local function displayUpValuesFromClosure(closure : (...any) -> any)
- print("------ UpValue Display ------")
- for index, upValue in getupvalues(closure) do
- if typeof(upValue) == "function" then
- print(index, debug.getinfo(upValue).name .. " " .. "(function)")
- continue
- end
- print(index, upValue)
- end
- end
- local function displayUpValuesFromScript(script : LocalScript | ModuleScript)
- print("------ UpValue Display ------")
- local closure = getscriptclosure(script)
- for index, upValue in getupvalues(closure) do
- if typeof(upValue) == "function" then
- print(index, debug.getinfo(upValue).name .. " " .. "(function)")
- continue
- end
- print(index, upValue)
- end
- end
- local function secureCall(closure : (...any) -> any, script : Instance, ... : any)
- local resultCall = nil
- local environment = getfenv(1)
- local oldTraceback = nil
- local oldDebugInfo = clonefunction(debug.info)
- local securityContext = getthreadcontext()
- local registeryEnvironment = getrenv()
- oldTraceback = hookfunction(debug.traceback, function(... : any)
- local info = string.sub(getinfo(1).source, 2)
- local traceback = oldTraceback(...)
- if string.find(traceback, info, 0, true) then
- return script:GetFullName() .. ":" .. "0" .. "\n" .. script:GetFullName() .. ":" .. "0"
- end
- return traceback
- end)
- hookfunction(debug.info, function(... : any)
- local arguments = table.pack(...)
- if typeof(arguments[1]) ~= "number" then
- return oldDebugInfo(...)
- end
- if string.find(arguments[2], "s", 0, true) then
- local info = string.sub(getinfo(1).source, 2)
- local functionInfo = oldDebugInfo(closure, arguments[2])
- local result, remplacements = string.gsub(functionInfo, info, script:GetFullName(), math.huge)
- return result
- end
- return oldDebugInfo(...)
- end)
- setthreadcontext(2)
- setfenv(1, setmetatable({script = script}, {
- __index = registeryEnvironment
- }))
- resultCall = closure(...)
- setfenv(1, environment)
- setthreadcontext(securityContext)
- debug.info = oldDebugInfo
- return resultCall
- end
- while not game:IsLoaded() do
- task.wait()
- end
- for index, signal in {LogService.MessageOut, ScriptContext.Error} do
- for index, connection in getconnections(signal) do
- connection:Disable()
- end
- end
- oldIndex = hookmetamethod(game, "__index", newcclosure(function(self : Instance, index : string)
- if checkcaller() then
- return oldIndex(self, index)
- end
- if table.find(protectedInstances, self, 1) then
- return nil
- end
- return oldIndex(self, index)
- end))
- oldNamecall = hookmetamethod(game, "__namecall", newcclosure(function(self : Instance, ... : any)
- if checkcaller() then
- return oldNamecall(self, ...)
- end
- local result = oldNamecall(self, ...)
- local namecallmethod = getnamecallmethod()
- if namecallmethod == "WaitForChild" or namecallmethod == "FindFirstChild" then
- if table.find(protectedInstances, result, 1) then
- result = nil
- end
- elseif namecallmethod == "GetChildren" or namecallmethod == "GetDescendants" then
- if typeof(result) == "table" then
- for index, value in result do
- if table.find(protectedInstances, value, 1) then
- table.remove(result, index)
- end
- end
- end
- else
- return oldNamecall(self, ...)
- end
- return result
- end))
- getgenv().__customEnvironment = {
- ["UpValues"] = {
- Modifier = {
- Script = modifyUpValuesFromScript,
- Closure = modifyUpValuesFromClosure
- },
- Displayer = {
- Script = displayUpValuesFromScript,
- Closure = displayUpValuesFromClosure
- }
- },
- ["Constants"] = {
- Modifier = {
- Script = modifyConstantsFromScript,
- Closure = modifyConstantsFromClosure
- },
- Displayer = {
- Script = displayConstantsFromScript,
- Closure = displayConstantsFromClosure
- }
- },
- ["Instances"] = {
- Protect = function(instance : Instance)
- if not table.find(protectedInstances, instance, 1) then
- table.insert(protectedInstances, instance)
- end
- end,
- Unprotect = function(instance : Instance)
- if table.find(protectedInstances, instance, 1) then
- table.remove(protectedInstances, table.find(protectedInstances, instance, 1))
- end
- end
- },
- SecureCall = secureCall
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement