Protectio v1
Key Required VerifiedUniversal

Protectio v1

Universal Scriptvxstyvxsty 518K views 573 executesUpdated Sep 2, 2023
1.7/ 5(27 votes)
91833% Positive
Lua Script•325 lines (11237 chars)
if not game:IsLoaded() then
    game.IsLoaded:Wait()
end
function String2Table(str)
  if type(str) == "string" then
  local length = #str
  local count = 1
  local String = {}
  while not (#String == length) do
    String[count] = str:sub(count, count)
        count = count + 1
  end
  return String
end
end
local Players = game:GetService("Players")
local LocalPlayer = game:GetService("Players").LocalPlayer


local Character = LocalPlayer.Character
if game:GetService("TextChatService").ChatVersion == Enum.ChatVersion.LegacyChatService then
    chat = "legacy"
        ChatBar = LocalPlayer.PlayerGui.Chat.Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar
    chatMain = game:GetService("Players").LocalPlayer.PlayerScripts.ChatScript.ChatMain
    
    lastText = ""
    function makeMessage(message)
        msg = tostring(message)
        game:GetService("StarterGui"):SetCore(
            "ChatMakeSystemMessage",
            {
                Text = msg,
                Color = Color3.fromRGB(255, 89, 98),
                Font = Enum.Font.GothamMedium,
                FontSize = 16
            }
        )
    end
    function makeWarn(message)
        msg = tostring(message)
        game:GetService("StarterGui"):SetCore(
            "ChatMakeSystemMessage",
            {
                Text = "[WARN]\n" .. msg,
                Color = Color3.fromHex("#fdfd96"),
                Font = Enum.Font.GothamMedium,
                FontSize = 16
            }
        )
    end
    function makeError(message)
        msg = tostring(message)
        game:GetService("StarterGui"):SetCore(
            "ChatMakeSystemMessage",
            {
                Text = "[ERROR]\n" .. msg,
                Color = Color3.fromRGB(125, 12, 23),
                Font = Enum.Font.GothamMedium,
                FontSize = 16
            }
        )
    end
    makeMessage("Protectio loaded.")
    if not game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents:FindFirstChild("SayMessageRequest") then
    makeError("Could not find SayMessageRequest, Please send a message in chat to fix this and prevent chat bans.")
    else
    SMR = game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents:FindFirstChild("SayMessageRequest")
    end
else
    chat = "tcs"
    function makeMessage(msg)
        msg = tostring(msg)
        if game:GetService("TextChatService").TextChannels:FindFirstChild("RBXGeneral") then
            game:GetService("TextChatService").TextChannels:FindFirstChild("RBXGeneral"):DisplaySystemMessage(msg)
        end
    end
    function makeWarn(msg)
        msg = tostring(msg)
        if game:GetService("TextChatService").TextChannels:FindFirstChild("RBXGeneral") then
            game:GetService("TextChatService").TextChannels:FindFirstChild("RBXGeneral"):DisplaySystemMessage(
                "[WARN] " .. msg
            )
        end
    end
    function makeError(msg)
        makeMessage("[ERROR]\n" .. msg)
    end
    makeMessage("Protectio loaded.")
end
local function gcs()
    if getcallingscript() ~= nil then
        return getcallingscript():GetFullName()
    else
        return "Unknown script"
    end
end
local r = true

Protectio = {
    AllowSendAsync = false,
    HttpOptions = {
    HttpGet = {Enabled = true, allowedURLs = {
      "https://scriptblox.com";
     }
    },
    HttpPost = {Enabled = false, allowedURLs = {}
    
    }
  },
    Request = {Enabled = false, allowedURLs = {}},
    AllowClientKick = false,
    AllowReportAbuse = false,
    AllowCaptureFocus = false,
    AllowSayMessageRequest = false,
    AllowAccessFriends = false,
    AllowKeyPresses = true
}

OnAttemptDeny = {
    CopyURLs = true,
    CopyReportAbuse = false
}

local hook
hook =
    hookmetamethod(
    game,
    "__namecall",
    function(Self, ...)
        local args, method = {...}, getnamecallmethod()
        if Protectio[1] == false and method == "SendAsync" and Self:IsA("TextChannel") then
            return makeWarn(gcs() .. " tried to SendAsync with the message " .. args[1] .. " in channel " .. Self.Name)
        end
        if
            not Protectio.HttpOptions.HttpGet.Enabled and method:find("HttpGet") then
            if OnAttemptDeny[1] == true then
                setclipboard(args[1])
            end
            
            return makeWarn(
                string.format(
          "%s called %s with the URL %s, HttpGet is not enabled and make sure to put the url in the HttpGet.allowedURLs table if you want to trust the url.", gcs(), method, args[1]
                )
            )
    elseif Protectio.HttpOptions.HttpGet.Enabled and method:find("HttpGet") then
      found = false
      local url = args[1]
      local spl = url:gsub("https://", ""):split("/")
      local dot = "https://" .. spl[1]
      
      for i, v in Protectio.HttpOptions.HttpGet.allowedURLs do
      if v:find(dot) then
       found = true
      end
      end
      if not found then
       if OnAttemptDeny[1] then setclipboard(url) end
      return makeWarn(
        string.format(
          "%s called %s with the URL %s, Attempt blocked as the URL was not found in the allowed urls table.\n"
        , gcs(), method, args[1]))
        end
      end
     
           if
            not Protectio.HttpOptions.HttpPost.Enabled and method:find("HttpPost") then
            if OnAttemptDeny[1] == true then
                setclipboard(args[1])
            end
            
            return makeWarn(
                string.format(
          "%s called %s with the URL %s, HttpPost is not enabled and make sure to put the url in the HttpPost.allowedURLs table if you want to trust the url.", gcs(), method, args[1]
                )
            )
    elseif Protectio.HttpOptions.HttpPost.Enabled and method:find("HttpPost") then
      found2 = false
      local url = args[1]
      local spl = url:gsub("https://", ""):split("/")
      local dot = "https://" .. spl[1]
      
      
      for i, v in Protectio.HttpOptions.HttpPost.allowedURLs do
      if v:find(dot) then
      found2 = true
      end
      end
      if not found2 then
        if OnAttemptDeny[1] == true then
        setclipboard(url)
       end
      return makeWarn(
        string.format(
          "%s called %s with the URL %s, Attempt blocked as the URL was not found in the allowed urls table.\n"
        , gcs(), method, args[1]))
        end
      end
        if method == "FireServer" and SMR == nil and not chatMain == nil and getcallingscript() == chatMain then
        SMR = Self
        makeMessage(
        "SayMessageRequest found disguised as "..Self.Name..", Anti Chat Ban should be working as expected now."
        )
        
        end
        if Protectio[3] == false and method == "Kick" and Self == LocalPlayer then
            return makeWarn(gcs() .. " tried to kick you, Protectio denied the attempt.")
        end
        if Protectio[4] == false and method == "ReportAbuse" then
            if OnAttemptDeny[3] then
                setclipboard(string.format("-- Latest Report Abuse call info: \nCalling Script: %s\nReason: %s\nPlayer: %s\nNote: %s", gcs(), args[1], args[2], args[3]))
            end
            return makeWarn(
                string.format("-- Latest Report Abuse call info: \nCalling Script: %s\nReason: %s\nPlayer: %s\nNote: %s", gcs(), args[1], args[2], args[3]))
        end
        if
            Protectio[5] == false and method == "CaptureFocus" and not getcallingscript() == chatMain and
                Self == ChatBar and
                chat == "legacy"
         then
            return makeWarn(gcs() .. " tried to CaptureFocus, Possible Force Chat attempt denied.")
        elseif chat == "tcs" and method == "CaptureFocus" and Protectio[5] == false then
            return makeWarn(gcs() .. " tried to call CaptureFocus, Attempt denied.")
        end
        if
            chat == "legacy" and Self == SMR and method == "FireServer" and lastText ~= args[1] and
                getcallingscript() ~= chatMain
         then
            return makeWarn(gcs() .. " tried to call SayMessageRequest")
        end
        if Protectio[AllowAccessFriends] == false and method == "GetFriendsAsync" then
        return makeWarn(string.format("%s tried to call GetFriendsAsync (checking your friend list), Attempt denied"), gcs())
        end
        if Protectio.AllowKeyPresses == false and method == "SendKeyEvent" then
      return makeWarn(string.format("%s tried to call SendKeyEvent %s, Attempt denied due to AllowKeyPresses being set to false.", gcs(), tostring(args[2])))
    end
    if method == 'PromptGamePassPurchase' or method == 'PromptBundlePurchase' or method == 'PromptPremiumPurchase' or method == 'PromptProductPurchase' or method == 'PromptPurchase' or method == 'PromptSubscriptionPurchase' then
      local x = ''
      for i, v in args do x = x .. i ..": " .. tostring(x) .. "\n" end
      return makeWarn(
      gcs()
      ..
      "called a robux stealing/draining method, Please do not re-execute the last script; If you haven't executed any scripts then this might be a game script, Arguements: \n" .. x)
    end
        return hook(Self, ...)
    end
)
if ChatBar ~= nil then
    ChatBar.Focused:Connect(
        function()
            repeat
                lastText = ChatBar.Text
            until ChatBar.Text == ""
        end
    )
end

hookfunction(
    error,
    newcclosure(
        function(...)
            if not stopped2 then
                local args = {...}
                for i, v in args do
                    makeError = (v)
                end
                stopped2 = true
                for i, v in args do
                    error(v)
                end
                stopped2 = false
            end
        end
    )
)
hookfunction(
    warn,
    newcclosure(
        function(...)
            if not stopped3 then
                local args = {...}
                for i, v in args do
                    makeWarn(v)
                end
                stopped3 = true
                for i, v in args do
                    warn(v)
                end
                stopped3 = false
            end
        end
    )
)

if Protectio[AllowKeyPresses] == false then
hookfunction(keypress, function(...)
local Args = {...}
return makeWarn(
gcs().. " Tried to keypress with the following code: "..Args[1])
end)
end
local request = (syn and syn.request or fluxus and fluxus.request) or request or Request
if not Protectio.Request.Enabled then
hookfunction(request, newcclosure(function(Args)
    found3 = false
    local x = Args.Url:gsub("https://", ""):split("/")[1]
    for i, v in Protectio.Request.allowedURLs do
    if v:find(x) then found3 = true end
    end
    if not found3 then
    makeWarn(gcs().. " tried to call request with the following arguements")
    local fullname = ''
    for _, Arg in Args do
       if type(Arg) == 'table' then
        for i, v in Arg do
        fullname = fullname .. tostring(i) .. ": " .. v .. "\n"
        end
       elseif type(Arg) == 'string' then
       fullname = fullname .. tostring(_) .. ": " .. Arg .. "\n"
     end
     end
     makeWarn(fullname)
     if OnAttemptDeny[CopyURLs] then setclipboard(Args.Url) end
    end
end))
end

Features & Information

Credits to Hypernova (Creator of guardian script) v1.1 changelogs: * Added options to copy loadstrings, urls and reportabuse information after they fail. * Fixed issues where you cant allow anything and everything would be disabled * Formatted code even more * Script now lets you choose whether to allow loadstrings (enable http requests if it contains a url) * Note that i made the script alone, Credits to Hypernova for the idea of the script v1.2 Removed Stop loadstrings, Fixed script not detecting SayMessageRequest calls, SayMessageRequest's Name now randomizes every .9 seconds to prevent it from being called somehow, Allowed HTTP Requests to be sent to scriptblox.com and robloxscripts.net just because some executors use it for searching 4 scripts, Script has one of the most advanced SayMessageRequest call detections, Fixed 3 bugs, Script now displays warnings, normal messages in chat. Submit more ideas in the discord v1.31: Removed getgenv() or ggv() to prevent other scripts from disabling Protectio, To disable/Enable change the values in the Protectio table before using. Implemented anti webhooks Implemented anti http post (Changeable) v1.32: Removed the getfenv() bs, Improved protectio's HttpGet and HttpPost protection by adding: HttpOptions table to the Protectio table which has: HttpGet, HttpGet.Enabled, HttpGet.allowURLs < -- Another table which has all the allowed urls that HttpGet is allowed to have, if HttpGet is called with a url that is not in that table it will not go through. Same is for HttpPost, Used string.format ( kinda better??) Added more keypress logging (VirtualInputManager's SendKeyEvent (Can be switched)) Fixed minor bugs v1.33: For URLs such as raw.githubusercontent just type in https://raw dont add anything else or it would get flagged, Also fixed that bug where even allowed URLs get flagged v1.34: Simply added a fluxus.request/syn.request logger because i didnt already have that for some reason (Can disable it) v1.35: Added an anti robux drainer / stealer script (Uses MarketplaceService to prompt purchases, these purchases can be scammer's gamepasses) JOIN THE DISCORD! https://discord.gg/Fyu6nTNrfy
#universal#op#free#new

Community Comments (7)

HypernovaHypernovaownerSep 2, 2023(edited)

Thanks for the credits! Would recommend adding self checks (game:SendAsync can detect your script for example)

kr4sk_kr4sk_Sep 2, 2023(edited)

fire

vxstyvxstySep 2, 2023(edited)

@Hypernova will do! This is still v1

Zum0tZum0tSep 2, 2023(edited)

Big W

The_script_userThe_script_userMay 14, 2024(edited)

This script is outdated it literally blocks good/safe scripts. I'm not hating I'm just asking you to fix it please.

vxstyvxstyMay 14, 2024(edited)

@yoan_hristov Use my newer version, RoTotal.

The_script_userThe_script_userMay 17, 2024(edited)

@vxsty ok

More Scripts for Universal Scripts