Advertisement
TheRealAaron

Optimize mainScript.lua and fix some bugs

Feb 20th, 2024
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.18 KB | Source Code | 0 0
  1. -- Constants for threat levels
  2. local ThreatLevels = {
  3.     Low = "Low",
  4.     Medium = "Medium",
  5.     High = "High"
  6. }
  7.  
  8. -- List of allowed scripts
  9. local allowed = {}
  10.  
  11. -- Lists of threat levels
  12. local LOWthreatLevel = {
  13.     "print",
  14.     "Loadstring",
  15.     "require"
  16. }
  17.  
  18. local MEDthreatLevel = {
  19.     "workspace.DistributedGameTime",
  20.     "game:GetService",
  21.     "game:service",
  22.     "service",
  23.     "game:HttpGet",
  24.     "game:GetObjects",
  25.     "game:GetService('HttpService'):GetAsync",
  26.     "game:GetService('HttpService'):PostAsync",
  27.     "game:GetService('HttpService'):JSONDecode",
  28.     "game:GetService('HttpService'):JSONEncode",
  29.     "game:GetService('HttpService'):GetAsync",
  30.     "game:GetService('HttpService'):PostAsync"
  31. }
  32.  
  33. local HIGHthreatLevel = {
  34.     "os.",
  35.     "io.",
  36.     "filesystem.",
  37.     "loadstring(",
  38.     "writefile(",
  39.     "readfile(",
  40.     "rconsoleprint(",
  41.     "writefile(",
  42.     "readfile(",
  43.     "rconsolename(",
  44.     "rconsolewarn(",
  45.     "rconsoleerror("
  46. }
  47.  
  48. local virusNames = {
  49.     "synapse",
  50.     "serverlock",
  51.     "freeexploit",
  52.     "exe"
  53. }
  54.  
  55. -- Function to create a template for displaying threats
  56. local function createTemplate(threatName, threatLevel, scriptName, script, isModule, moduleParent)
  57.     local clone = script.ScanButton.Template:Clone()
  58.     clone.Parent = script.ScanButton
  59.     clone.Name = scriptName
  60.     clone.Visible = true
  61.     clone.ThreatLevel.Text = "Threat Level: " .. threatLevel
  62.     clone.ThreatName.Text = "Threat: " .. threatName
  63.     clone.ScriptName.Text = "Script: " .. scriptName
  64.  
  65.     -- Function to handle actions when the template buttons are clicked
  66.     local function handleActions()
  67.         for _, child in pairs(clone.ActionsButton:GetChildren()) do
  68.             if child:IsA("TextButton") then
  69.                 child.Visible = true
  70.             end
  71.         end
  72.         local allowBtn = clone.ActionsButton.Allow
  73.         allowBtn.MouseButton1Click:Connect(function()
  74.             clone:Destroy()
  75.             table.insert(allowed, scriptName)
  76.         end)
  77.         local qBtn = clone.ActionsButton.quaraButton
  78.         qBtn.MouseButton1Click:Connect(function()
  79.             if isModule then
  80.                 local safeZone = game.ServerStorage:FindFirstChild("[MonkeDefender]Safe Zone") or Instance.new("Folder")
  81.                 safeZone.Name = "[MonkeDefender]Safe Zone"
  82.                 safeZone.Parent = game.ServerStorage
  83.  
  84.                 script.Parent = safeZone
  85.                 if not script:IsA("ModuleScript") then
  86.                     script.Disabled = true
  87.                 end
  88.  
  89.                 moduleParent.Parent = safeZone
  90.                 clone:Destroy()
  91.             end
  92.         end)
  93.     end
  94.  
  95.     clone.ActionsButton.MouseButton1Click:Connect(handleActions)
  96. end
  97.  
  98. -- Function to scan a script for threats
  99. local function scanScript(script, allowedScripts)
  100.     for _, threatName in pairs(virusNames) do
  101.         if script.Name:lower() == threatName:lower() then
  102.             createTemplate(threatName, ThreatLevels.Medium, script.Name, script, false)
  103.         end
  104.     end
  105.  
  106.     for _, threatName in pairs(HIGHthreatLevel) do
  107.         if script.Source:lower():find(threatName:lower()) then
  108.             createTemplate(threatName, ThreatLevels.High, script.Name, script, true, script)
  109.         end
  110.     end
  111.  
  112.     for _, threatName in pairs(MEDthreatLevel) do
  113.         if script.Source:lower():find(threatName:lower()) then
  114.             createTemplate(threatName, ThreatLevels.Medium, script.Name, script, true, script)
  115.         end
  116.     end
  117.  
  118.     for _, threatName in pairs(LOWthreatLevel) do
  119.         if script.Source:lower():find(threatName:lower()) then
  120.             createTemplate(threatName, ThreatLevels.Low, script.Name, script, true, script)
  121.         end
  122.     end
  123. end
  124.  
  125. -- Function to handle scan button click
  126. script.ScanButton.MouseButton1Click:Connect(function()
  127.     script.labelclone.Visible = false
  128.     script.novirus.Visible = false
  129.  
  130.     for _, child in pairs(game:GetDescendants()) do
  131.         if child:IsA("Script") and not allowed[child.Name] then
  132.             scanScript(child, allowed)
  133.         end
  134.     end
  135.  
  136.     if not script.ScanButton:GetChildren()[4] then
  137.         script.novirus.Visible = true
  138.     end
  139. end)
  140.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement