--[[
Malicious Script Detector (Deep AST-Lite & Full Context Edition)
i got better in this because i paid claude pro
Features:
- Tokenizer & Variable Alias Tracking (Catches local a = getgenv; a.hookfunction)
- String Entropy Analysis (Catches obfuscated/encrypted payloads without regex)
- Deep Context Analysis (Detects Weak Cooldowns, Fetch+Execute chains)
- Full Instance & Remote Deep Scanning (Collisions, Unanchored Parts, Exposed Scripts)
- Terminal Intro with Skip Notification, INJECT/EXECUTE sequence
- Dynamic FPS throttling (keeps FPS at 40-50+)
- Animation FX (shimmer bar, scan sweep, shockwave ring, shake, typewriter, pop, pulsing/fading cards, button juice)
- Grouped reports with Target, Exploiter Capability, Evidence, Benign Reason and Suggested Action
]]
--
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
local Player = Players.LocalPlayer
-- Types
type ScanContext = {
hasHttp: boolean,
hasWebhook: boolean,
hasRemote: boolean,
hasLoadstring: boolean,
hasExecutor: boolean,
hasDataCollection: boolean,
hasTeleport: boolean,
}
export type Threat = {
Category: string,
Severity: string,
Confidence: string,
Description: string,
Pattern: string,
Instance: Instance?,
InstancePath: string?,
LineNumber: number?,
Target: string?,
ExploitImpact: string?,
Evidence: string,
BenignReason: string?,
SuggestedAction: string,
}
export type GroupedThreat = {
Category: string,
Severity: string,
Description: string,
Instances: { Threat },
}
export type PatternData = {
patterns: { string },
severity: string,
description: string,
target: string,
exploit_impact: string,
benign_reason: string?,
suggested_action: string,
}
local MaliciousDetector = {}
MaliciousDetector.__index = MaliciousDetector
-- Configuration
local CONFIG = {
LogToOutput = true,
MaxLineLength = 5000,
MaxScriptSizeForTokenizer = 100000, -- Prevent lag on massive minified files
MaxRegexChunk = 1500, -- longest text a single pattern match may run on
MaxBytecodeSize = 120000, -- scripts with bigger bytecode are never decompiled (decompile blocks the main thread)
ChunkOverlap = 200, -- overlap between chunks so a match on a boundary isn't lost
}
-- Executor globals (getgenv, decompile, ...) are read through the script environment,
-- so the file type-checks cleanly even where they aren't declared.
local RAW_ENV: { [string]: any } = getfenv() :: any
local getgenvFn: any = RAW_ENV.getgenv
-- LuaSourceContainer is the abstract base class. .Source / .RunContext are declared
-- only on Script / LocalScript / ModuleScript, so the checker refuses to see them.
-- Read through `any` once, safely, and reuse everywhere.
local function ReadScriptProp(container: LuaSourceContainer, key: string): any
local ok, value = pcall(function()
return (container :: any)[key]
end)
if ok then
return value
end
return nil
end
-- Dynamic Yield Throttler
local lastYieldTime = os.clock()
local YIELD_THRESHOLD = 0.008
local function SafeYield()
if os.clock() - lastYieldTime > YIELD_THRESHOLD then
task.wait()
lastYieldTime = os.clock()
end
end
-- Utility: Vibrant Animated Rainbow Stroke
local function ApplyRainbowStroke(instance: Instance, thickness: number, speed: number?): UIStroke
local stroke = Instance.new("UIStroke")
stroke.Thickness = thickness
stroke.Transparency = 0.1
stroke.Parent = instance
local hue = 0
local s = speed or 1.0
task.spawn(function()
while stroke and stroke.Parent do
hue = (hue + 0.01 * s) % 1
stroke.Color = Color3.fromHSV(hue, 1, 1)
task.wait(0.03)
end
end)
return stroke
end
-- ============================================================
-- ANIMATION FX
-- ============================================================
local FX = {}
local function tween(obj: Instance, info: TweenInfo, goal: { [string]: any })
local t = TweenService:Create(obj, info, goal)
t:Play()
return t
end
-- Flowing sheen across a gradient, forever
function FX.Shimmer(gradient: UIGradient, speed: number)
local conn
conn = RunService.Heartbeat:Connect(function(dt)
if not gradient.Parent then
conn:Disconnect()
return
end
local x = gradient.Offset.X
gradient.Offset = Vector2.new(((x + 1 + dt * speed) % 2) - 1, 0)
end)
return conn
end
-- Glowing progress bar fill
function FX.GlowBar(barFill: Frame)
local g = Instance.new("UIGradient")
g.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(0, 110, 210)),
ColorSequenceKeypoint.new(0.5, Color3.fromRGB(140, 235, 255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(0, 110, 210)),
})
g.Parent = barFill
return FX.Shimmer(g, 0.7)
end
-- Vertical scanline that sweeps up and down the window
function FX.CreateSweep(parent: Instance)
local sweep = Instance.new("Frame")
sweep.Name = "ScanSweep"
sweep.Size = UDim2.new(1, 0, 0, 50)
sweep.Position = UDim2.new(0, 0, 0, 0)
sweep.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
sweep.BackgroundTransparency = 0.88
sweep.BorderSizePixel = 0
sweep.ZIndex = 0
sweep.Parent = parent
local g = Instance.new("UIGradient")
g.Rotation = 90
g.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 1),
NumberSequenceKeypoint.new(0.5, 0),
NumberSequenceKeypoint.new(1, 1),
})
g.Parent = sweep
local tw = tween(
sweep,
TweenInfo.new(1.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{ Position = UDim2.new(0, 0, 1, -50) }
)
return sweep, tw
end
-- Expanding shockwave ring
function FX.Ring(parent: Instance, color: Color3)
local ring = Instance.new("Frame")
ring.AnchorPoint = Vector2.new(0.5, 0.5)
ring.Position = UDim2.new(0.5, 0, 0.5, 0)
ring.Size = UDim2.fromOffset(40, 40)
ring.BackgroundTransparency = 1
ring.Parent = parent
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(1, 0)
corner.Parent = ring
local stroke = Instance.new("UIStroke")
stroke.Color = color
stroke.Thickness = 4
stroke.Parent = ring
tween(ring, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Size = UDim2.fromOffset(900, 900) })
local t = tween(stroke, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { Transparency = 1, Thickness = 1 })
t.Completed:Connect(function()
ring:Destroy()
end)
end
-- Screen shake with falloff
function FX.Shake(frame: GuiObject, magnitude: number, duration: number)
local base = frame.Position
local start = os.clock()
local conn
conn = RunService.RenderStepped:Connect(function()
local elapsed = os.clock() - start
if elapsed >= duration or not frame.Parent then
if frame.Parent then
frame.Position = base
end
conn:Disconnect()
return
end
local falloff = 1 - elapsed / duration
local dx = (math.random() * 2 - 1) * magnitude * falloff
local dy = (math.random() * 2 - 1) * magnitude * falloff
frame.Position = UDim2.new(base.X.Scale, base.X.Offset + dx, base.Y.Scale, base.Y.Offset + dy)
end)
end
-- Typewriter text (use only for the final message, so it doesn't fight other updates)
function FX.Typewrite(label: TextLabel, text: string, charDelay: number)
label.Text = ""
task.spawn(function()
for i = 1, #text do
if not label.Parent then
return
end
label.Text = string.sub(text, 1, i)
task.wait(charDelay)
end
end)
end
-- Quick bounce when a value changes
function FX.Pop(guiObj: GuiObject)
local scale = guiObj:FindFirstChild("PopScale") :: UIScale?
if not scale then
local newScale = Instance.new("UIScale")
newScale.Name = "PopScale"
newScale.Parent = guiObj
scale = newScale
end
local s = scale :: UIScale
s.Scale = 1.08
tween(s, TweenInfo.new(0.3, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
end
-- Pulsing border for dangerous threats
function FX.PulseStroke(stroke: UIStroke)
tween(stroke, TweenInfo.new(0.7, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), { Thickness = 3 })
end
-- Staggered card entrance: fade + scale-up, text fades in too
function FX.FadeInCard(card: Frame, delay: number, stroke: UIStroke)
local scale = Instance.new("UIScale")
scale.Scale = 0.9
scale.Parent = card
card.BackgroundTransparency = 1
stroke.Transparency = 1
local labels = {}
for _, d in ipairs(card:GetDescendants()) do
if d:IsA("TextLabel") then
d.TextTransparency = 1
table.insert(labels, d)
end
end
task.delay(delay, function()
if not card.Parent then
return
end
tween(card, TweenInfo.new(0.35, Enum.EasingStyle.Quad), { BackgroundTransparency = 0 })
tween(stroke, TweenInfo.new(0.35, Enum.EasingStyle.Quad), { Transparency = 0.2 })
tween(scale, TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
for _, label in ipairs(labels) do
tween(label, TweenInfo.new(0.4, Enum.EasingStyle.Quad), { TextTransparency = 0 })
end
end)
end
-- Closing animation shared by every window: shrinks slightly while everything fades to fully transparent
function FX.Close(frame: GuiObject, onDone: (() -> ())?)
if frame:GetAttribute("Closing") then
return
end
frame:SetAttribute("Closing", true)
local info = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local scale = frame:FindFirstChildOfClass("UIScale")
if not scale then
scale = Instance.new("UIScale")
scale.Parent = frame
end
tween(scale :: UIScale, info, { Scale = 0.85 })
local function fade(obj: Instance)
if obj:IsA("UIStroke") then
tween(obj, info, { Transparency = 1 })
elseif obj:IsA("GuiObject") then
if obj.BackgroundTransparency < 1 then
tween(obj, info, { BackgroundTransparency = 1 })
end
if obj:IsA("TextLabel") or obj:IsA("TextButton") or obj:IsA("TextBox") then
tween(obj, info, { TextTransparency = 1 })
elseif obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
tween(obj, info, { ImageTransparency = 1 })
elseif obj:IsA("ScrollingFrame") then
tween(obj, info, { ScrollBarImageTransparency = 1 })
end
end
end
fade(frame)
for _, d in ipairs(frame:GetDescendants()) do
fade(d)
end
task.delay(info.Time, function()
if onDone then
onDone()
end
end)
end
-- Springy hover and press feedback for buttons
function FX.Hover(button: TextButton)
-- Same hover as the threat map nodes: border thickens and the surface lightens.
-- Uses an overlay instead of changing BackgroundColor3, so buttons that recolor themselves keep working.
local stroke = Instance.new("UIStroke")
stroke.Color = Color3.new(1, 1, 1)
stroke.Thickness = 1.5
stroke.Transparency = 0.75
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = button
local overlay = Instance.new("Frame")
overlay.Name = "HoverOverlay"
overlay.Size = UDim2.fromScale(1, 1)
overlay.BackgroundColor3 = Color3.new(1, 1, 1)
overlay.BackgroundTransparency = 1
overlay.BorderSizePixel = 0
overlay.Active = false
overlay.Parent = button
local corner = button:FindFirstChildOfClass("UICorner")
if corner then
corner:Clone().Parent = overlay
end
button.MouseEnter:Connect(function()
tween(stroke, TweenInfo.new(0.12), { Thickness = 3, Transparency = 0.4 })
tween(overlay, TweenInfo.new(0.12), { BackgroundTransparency = 0.9 })
end)
button.MouseLeave:Connect(function()
tween(stroke, TweenInfo.new(0.12), { Thickness = 1.5, Transparency = 0.75 })
tween(overlay, TweenInfo.new(0.12), { BackgroundTransparency = 1 })
end)
end
-- String Entropy Calculator (Finds Obfuscated Code)
local function CalculateEntropy(s: string): number
if #s == 0 then
return 0
end
local counts = {}
for i = 1, #s do
local c = s:sub(i, i)
counts[c] = (counts[c] or 0) + 1
end
local entropy = 0
for _, count in pairs(counts) do
local p = count / #s
entropy = entropy - p * math.log(p, 2)
end
return entropy
end
-- Tokenizer & Alias Tracker (Deep Scan)
local function TokenizeAndAnalyze(source: string, scriptInstance: LuaSourceContainer): { Threat }
local threats: { Threat } = {}
if #source > CONFIG.MaxScriptSizeForTokenizer then
return threats
end
local tokens = {}
local pos = 1
local lineNum = 1
-- Pass 1: Lexical Analysis (Tokenize)
while pos <= #source do
local c = source:sub(pos, pos)
if c == "\n" then
lineNum += 1
pos += 1
elseif c == "-" and source:sub(pos + 1, pos + 1) == "-" then
local nextPos = source:find("\n", pos)
pos = nextPos and nextPos + 1 or #source + 1
elseif c == "[" and source:sub(pos + 1, pos + 1) == "[" then
local endPos = source:find("]]", pos, true)
pos = endPos and endPos + 2 or #source + 1
elseif c == '"' or c == "'" then
local endPos = source:find(c, pos + 1)
local strVal = ""
if endPos then
strVal = source:sub(pos + 1, endPos - 1)
pos = endPos + 1
else
pos = #source + 1
end
-- Entropy Check for Obfuscation
if #strVal > 100 then
local entropy = CalculateEntropy(strVal)
if entropy > 4.5 then
table.insert(threats, {
Category = "Obfuscation",
Severity = "MEDIUM",
Confidence = "High",
Description = "High entropy string detected (possible encrypted payload).",
Pattern = "HighEntropyString",
Target = "Source Code",
ExploitImpact = "Hide malicious behavior from developers and automated scanners.",
LineNumber = lineNum,
Evidence = "Entropy: " .. string.format("%.2f", entropy) .. " | Len: " .. #strVal,
BenignReason = "Sometimes used in legitimate crypto/hashing libraries.",
SuggestedAction = "If this is a free model, remove it. Obfuscation is the #1 red flag.",
})
end
end
elseif c:match("[%w_]") then
local match = source:match("^[%w_]+", pos)
table.insert(tokens, { type = "ident", value = match, line = lineNum })
pos += #match
elseif c == "=" then
-- Emit assignment ops so alias tracking (local a = getgenv) works; skip "=="
if source:sub(pos + 1, pos + 1) == "=" then
pos += 2
else
table.insert(tokens, { type = "op", value = "=", line = lineNum })
pos += 1
end
else
pos += 1
end
SafeYield()
end
-- Pass 2: Variable Alias Mapping
local varMap = {}
local DANGEROUS_GLOBALS = {
["getgenv"] = true,
["getrawmetatable"] = true,
["setrawmetatable"] = true,
["hookfunction"] = true,
["hookmetamethod"] = true,
["getfenv"] = true,
["setfenv"] = true,
["loadstring"] = true,
["decompile"] = true,
["getscriptbytecode"] = true,
["getcustomasset"] = true,
["request"] = true,
["http_request"] = true,
["fireclickdetector"] = true,
["fireproximityprompt"] = true,
}
for i = 1, #tokens - 3 do
local t1, t2, t3, t4 = tokens[i], tokens[i + 1], tokens[i + 2], tokens[i + 3]
if t1.type == "ident" and t1.value == "local" and t2.type == "ident" and t3.type == "op" and t3.value == "=" then
if t4.type == "ident" and DANGEROUS_GLOBALS[t4.value] then
varMap[t2.value] = t4.value
end
end
end
-- Pass 3: Semantic Evaluation (Check aliases and context)
local hasFireServer = false
local hasWait = false
local hasDebounce = false
local hasLoadstring = false
local hasHttp = false
for i, t in ipairs(tokens) do
if t.type == "ident" then
local resolved = varMap[t.value] or t.value
if
DANGEROUS_GLOBALS[resolved]
and resolved ~= "loadstring"
and resolved ~= "request"
and resolved ~= "http_request"
and resolved ~= "HttpService"
then
table.insert(threats, {
Category = "ExecutorFunctions",
Severity = "CRITICAL",
Confidence = "High",
Description = "Executor/Exploit API detected (or aliased).",
Pattern = resolved,
Target = "Game Client / Environment",
ExploitImpact = "Run arbitrary code, bypass anti-cheats, and modify game memory.",
LineNumber = t.line,
Evidence = "Identifier: " .. t.value .. " (Resolved: " .. resolved .. ")",
BenignReason = "Very rarely used in legitimate development.",
SuggestedAction = "Remove immediately.",
})
end
if resolved == "FireServer" or resolved == "InvokeServer" then
hasFireServer = true
end
if resolved == "wait" or resolved == "task.wait" then
hasWait = true
end
if resolved == "debounce" or resolved == "cooldown" then
hasDebounce = true
end
if resolved == "loadstring" then
hasLoadstring = true
end
if resolved == "HttpService" or resolved == "request" then
hasHttp = true
end
end
end
-- Context-Aware Logic: Weak Cooldown
if hasFireServer and hasWait and hasDebounce then
table.insert(threats, {
Category = "WeakCooldown",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "Client-sided cooldown/debounce detected with Remote event.",
Target = "Server Remotes",
ExploitImpact = "Exploiters can delete the LocalScript or bypass the wait() to spam the remote.",
Pattern = "debounce + wait() + FireServer",
LineNumber = 1,
Evidence = "Script contains debounce, wait, and FireServer tokens.",
BenignReason = "Sometimes used for UI button press animations.",
SuggestedAction = "Move the cooldown logic (os.clock() checks) to the server-side.",
})
end
-- Context-Aware Logic: Fetch and Execute
if hasLoadstring and hasHttp then
table.insert(threats, {
Category = "FetchAndExecute",
Severity = "CRITICAL",
Confidence = "High",
Description = "Remote code execution chain detected (loadstring + HTTP).",
Target = "Server / Client",
ExploitImpact = "Download and execute malicious code on the fly.",
Pattern = "loadstring + HttpService",
LineNumber = 1,
Evidence = "Script contains both loadstring and HTTP request tokens.",
BenignReason = "Very rarely used in legitimate sandbox environments.",
SuggestedAction = "Remove immediately.",
})
end
return threats
end
-- ============================================================
-- STARTUP INTRO: "Radar Lock-On" (~5 seconds, skippable)
-- 0.0s backdrop + grid fade in, radar scales up
-- 0.3s sweep arm spins; threat blips ping as the beam passes
-- 0.4s title decrypts from scrambled glyphs
-- 3.2s lock-on: blips collapse to the center, "ARMED"
-- 3.6s shockwave rings, radar implodes
-- 4.3s white flash, intro dissolves into the scanner
-- ============================================================
local INTRO_DURATION = 5
local function PlayIntro(shouldSkip: () -> boolean)
local playerGui = Player:WaitForChild("PlayerGui")
local existingIntro = playerGui:FindFirstChild("DetectorIntro")
if existingIntro then
existingIntro:Destroy()
end
local ACCENT = Color3.fromRGB(0, 200, 255)
local ARMED = Color3.fromRGB(60, 255, 140)
local RADIUS = 140
local TRAIL = 10
local SWEEP_SPEED = 300 -- degrees per second
local TITLE = "MALICIOUS SCRIPT DETECTOR"
local GLYPHS = "!<>-_/\\[]{}=+*^?#01ABCDEF"
local BLIP_COLORS = {
Color3.fromRGB(255, 70, 70),
Color3.fromRGB(255, 160, 50),
Color3.fromRGB(255, 230, 60),
Color3.fromRGB(80, 255, 140),
}
local introGui = Instance.new("ScreenGui")
introGui.Name = "DetectorIntro"
introGui.IgnoreGuiInset = true
introGui.ResetOnSpawn = false
introGui.DisplayOrder = 9999
introGui.Parent = playerGui
-- Everything except the final flash lives on the stage, so it can be removed in one go
local stage = Instance.new("Frame")
stage.Name = "Stage"
stage.Size = UDim2.fromScale(1, 1)
stage.BackgroundColor3 = Color3.fromRGB(6, 8, 12)
stage.BackgroundTransparency = 1
stage.BorderSizePixel = 0
stage.Parent = introGui
local function circle(
parent: Instance,
diameter: number,
strokeColor: Color3?,
strokeThickness: number?,
strokeTransparency: number?
): Frame
local f = Instance.new("Frame")
f.AnchorPoint = Vector2.new(0.5, 0.5)
f.Position = UDim2.fromScale(0.5, 0.5)
f.Size = UDim2.fromOffset(diameter, diameter)
f.BackgroundTransparency = 1
f.BorderSizePixel = 0
f.Parent = parent
local c = Instance.new("UICorner")
c.CornerRadius = UDim.new(1, 0)
c.Parent = f
if strokeColor then
local s = Instance.new("UIStroke")
s.Color = strokeColor
s.Thickness = strokeThickness or 1
s.Transparency = strokeTransparency or 0
s.Parent = f
end
return f
end
-- Background grid
local grid = Instance.new("CanvasGroup")
grid.Size = UDim2.fromScale(1, 1)
grid.BackgroundTransparency = 1
grid.GroupTransparency = 1
grid.Parent = stage
local GRID_STEP = 48
for i = 0, 60 do
local v = Instance.new("Frame")
v.Size = UDim2.new(0, 1, 1, 0)
v.Position = UDim2.fromOffset(i * GRID_STEP, 0)
v.BackgroundColor3 = ACCENT
v.BackgroundTransparency = 0.93
v.BorderSizePixel = 0
v.Parent = grid
if i <= 35 then
local h = Instance.new("Frame")
h.Size = UDim2.new(1, 0, 0, 1)
h.Position = UDim2.fromOffset(0, i * GRID_STEP)
h.BackgroundColor3 = ACCENT
h.BackgroundTransparency = 0.93
h.BorderSizePixel = 0
h.Parent = grid
end
end
-- Radar
local radar = Instance.new("Frame")
radar.AnchorPoint = Vector2.new(0.5, 0.5)
radar.Position = UDim2.fromScale(0.5, 0.5)
radar.Size = UDim2.fromOffset(RADIUS * 2, RADIUS * 2)
radar.BackgroundTransparency = 1
radar.Parent = stage
local radarScale = Instance.new("UIScale")
radarScale.Scale = 0
radarScale.Parent = radar
local disc = circle(radar, RADIUS * 2)
disc.BackgroundColor3 = ACCENT
disc.BackgroundTransparency = 0.94
local outerRing = circle(radar, RADIUS * 2, ACCENT, 2, 0.1)
circle(radar, RADIUS * 1.33, ACCENT, 1, 0.55)
circle(radar, RADIUS * 0.66, ACCENT, 1, 0.55)
for _, horizontal in ipairs({ true, false }) do
local line = Instance.new("Frame")
line.AnchorPoint = Vector2.new(0.5, 0.5)
line.Position = UDim2.fromScale(0.5, 0.5)
line.Size = horizontal and UDim2.fromOffset(RADIUS * 2, 1) or UDim2.fromOffset(1, RADIUS * 2)
line.BackgroundColor3 = ACCENT
line.BackgroundTransparency = 0.6
line.BorderSizePixel = 0
line.Parent = radar
end
-- Sweep arm + fading trail. Each arm spans the full diameter, but a gradient hides the
-- left half, so rotating around the frame's center pivots the beam around the radar center.
local arms: { Frame } = {}
for k = 0, TRAIL do
local arm = Instance.new("Frame")
arm.AnchorPoint = Vector2.new(0.5, 0.5)
arm.Position = UDim2.fromScale(0.5, 0.5)
arm.Size = UDim2.fromOffset(RADIUS * 2, k == 0 and 3 or 2)
arm.BackgroundColor3 = k == 0 and Color3.new(1, 1, 1) or ACCENT
arm.BackgroundTransparency = k == 0 and 0 or (0.35 + 0.6 * k / TRAIL)
arm.BorderSizePixel = 0
arm.ZIndex = 3
arm.Parent = radar
local g = Instance.new("UIGradient")
g.Transparency = NumberSequence.new({
NumberSequenceKeypoint.new(0, 1),
NumberSequenceKeypoint.new(0.5, 1),
NumberSequenceKeypoint.new(0.501, 0.7),
NumberSequenceKeypoint.new(1, 0),
})
g.Parent = arm
arms[k + 1] = arm
end
local core = circle(radar, 10)
core.BackgroundColor3 = Color3.new(1, 1, 1)
core.BackgroundTransparency = 0
core.ZIndex = 4
-- Blips (fake "threat signatures" the beam discovers)
type Blip = { frame: Frame, scale: UIScale, angle: number, shown: boolean }
local blips: { Blip } = {}
for _ = 1, 14 do
local angle = math.random() * 360
local dist = (0.2 + math.random() * 0.7) * RADIUS
local rad = math.rad(angle)
local b = circle(radar, 9)
b.Position = UDim2.new(0.5, math.cos(rad) * dist, 0.5, math.sin(rad) * dist)
b.BackgroundColor3 = BLIP_COLORS[math.random(1, #BLIP_COLORS)]
b.BackgroundTransparency = 0
b.ZIndex = 5
local s = Instance.new("UIScale")
s.Scale = 0
s.Parent = b
table.insert(blips, { frame = b, scale = s, angle = angle, shown = false })
end
-- Text
local title = Instance.new("TextLabel")
title.AnchorPoint = Vector2.new(0.5, 1)
title.Position = UDim2.new(0.5, 0, 0.5, -RADIUS - 28)
title.Size = UDim2.fromOffset(700, 40)
title.BackgroundTransparency = 1
title.Font = Enum.Font.GothamBlack
title.TextSize = 30
title.TextColor3 = Color3.new(1, 1, 1)
title.Text = ""
title.Parent = stage
local status = Instance.new("TextLabel")
status.AnchorPoint = Vector2.new(0.5, 0)
status.Position = UDim2.new(0.5, 0, 0.5, RADIUS + 26)
status.Size = UDim2.fromOffset(500, 20)
status.BackgroundTransparency = 1
status.Font = Enum.Font.Code
status.TextSize = 15
status.TextColor3 = ACCENT
status.Text = ""
status.Parent = stage
local flash = Instance.new("Frame")
flash.Size = UDim2.fromScale(1, 1)
flash.BackgroundColor3 = Color3.new(1, 1, 1)
flash.BackgroundTransparency = 1
flash.BorderSizePixel = 0
flash.ZIndex = 50
flash.Parent = introGui
-- Ping sound from the built-in client content (silent if unavailable)
local ping = Instance.new("Sound")
ping.SoundId = "rbxasset://sounds/electronicpingshort.wav"
ping.Volume = 0.25
ping.Parent = introGui
local function playPing(pitch: number)
pcall(function()
local s = ping:Clone()
s.PlaybackSpeed = pitch
s.Parent = introGui
s.Ended:Connect(function()
s:Destroy()
end)
s:Play()
end)
end
local function popBlip(blip: Blip)
blip.shown = true
tween(blip.scale, TweenInfo.new(0.35, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
-- echo ring
local echo = circle(radar, 9, blip.frame.BackgroundColor3, 2, 0)
echo.Position = blip.frame.Position
echo.ZIndex = 5
local echoStroke = echo:FindFirstChildOfClass("UIStroke") :: UIStroke
tween(echo, TweenInfo.new(0.6, Enum.EasingStyle.Quad), { Size = UDim2.fromOffset(46, 46) })
tween(echoStroke, TweenInfo.new(0.6, Enum.EasingStyle.Quad), { Transparency = 1 }).Completed:Connect(function()
echo:Destroy()
end)
playPing(0.9 + math.random() * 0.4)
end
-- Continuous animation: sweep, blip discovery, title decrypt
local startTime = os.clock()
local sweepActive = true
local lastDecrypt = 0
local decryptDone = false
local conn = RunService.Heartbeat:Connect(function()
local t = os.clock() - startTime
if sweepActive and t >= 0.3 then
local sweepTotal = (t - 0.3) * SWEEP_SPEED
for k, arm in ipairs(arms) do
arm.Rotation = (sweepTotal - (k - 1) * 3.5) % 360
end
for _, blip in ipairs(blips) do
if not blip.shown and sweepTotal >= blip.angle then
popBlip(blip)
end
end
end
if not decryptDone and t >= 0.4 and t - lastDecrypt >= 0.04 then
lastDecrypt = t
local revealed = math.floor(math.clamp((t - 0.4) / 1.8, 0, 1) * #TITLE)
local chars = table.create(#TITLE)
for i = 1, #TITLE do
local ch = TITLE:sub(i, i)
if i <= revealed or ch == " " then
chars[i] = ch
else
local r = math.random(1, #GLYPHS)
chars[i] = GLYPHS:sub(r, r)
end
end
title.Text = table.concat(chars)
if revealed >= #TITLE then
decryptDone = true
end
end
end)
local function hold(seconds: number): boolean
local t0 = os.clock()
while os.clock() - t0 < seconds do
if shouldSkip() then
return true
end
task.wait()
end
return false
end
local function setStatus(text: string)
status.Text = "> " .. text
FX.Pop(status)
end
repeat
tween(stage, TweenInfo.new(0.4), { BackgroundTransparency = 0 })
tween(grid, TweenInfo.new(0.8), { GroupTransparency = 0 })
tween(radarScale, TweenInfo.new(0.6, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
if hold(0.5) then
break
end
setStatus("INITIALIZING SENSORS...")
if hold(0.7) then
break
end
setStatus("LOADING THREAT SIGNATURES...")
if hold(0.7) then
break
end
setStatus("CALIBRATING HEURISTICS...")
if hold(0.7) then
break
end
setStatus("LOCKING ON...")
if hold(0.6) then
break
end
-- 3.2s: lock-on
sweepActive = false
for _, arm in ipairs(arms) do
tween(arm, TweenInfo.new(0.3), { BackgroundTransparency = 1 })
end
for _, blip in ipairs(blips) do
tween(blip.frame, TweenInfo.new(0.35, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {
Position = UDim2.fromScale(0.5, 0.5),
BackgroundTransparency = 1,
})
end
local ringStroke = outerRing:FindFirstChildOfClass("UIStroke") :: UIStroke
tween(ringStroke, TweenInfo.new(0.3), { Color = ARMED, Thickness = 4 })
tween(core, TweenInfo.new(0.3), { BackgroundColor3 = ARMED, Size = UDim2.fromOffset(18, 18) })
status.TextColor3 = ARMED
setStatus("SYSTEM ARMED")
playPing(0.6)
if hold(0.4) then
break
end
-- 3.6s: shockwave + implode
FX.Ring(stage, ACCENT)
task.delay(0.12, function()
if stage.Parent then
FX.Ring(stage, ARMED)
end
end)
FX.Shake(radar, 5, 0.3)
tween(radarScale, TweenInfo.new(0.6, Enum.EasingStyle.Back, Enum.EasingDirection.In), { Scale = 0 })
if hold(0.7) then
break
end
until true
-- 4.3s (or on skip): flash and dissolve
conn:Disconnect()
tween(flash, TweenInfo.new(0.12), { BackgroundTransparency = 0 })
task.wait(0.15)
stage:Destroy()
tween(flash, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), { BackgroundTransparency = 1 })
task.wait(0.5)
introGui:Destroy()
end
-- Decompiler & Bytecode
local function GetDecompiler(): any?
local env = getfenv()
if type(getgenvFn) == "function" then
local s, g = pcall(getgenvFn)
if s and type(g) == "table" then
if type(g.decompile) == "function" then
return g.decompile
end
if type(g.Decompile) == "function" then
return g.Decompile
end
if type(g.decompileScript) == "function" then
return g.decompileScript
end
end
end
if type(RAW_ENV.decompile) == "function" then
return RAW_ENV.decompile
end
if type(env.decompile) == "function" then
return env.decompile
end
return nil
end
local Decompiler = GetDecompiler()
local function GetClipboardFunc(): any?
local funcs = { "setclipboard", "toclipboard", "writeclipboard" }
local env = getfenv()
for _, name in ipairs(funcs) do
if type(env[name]) == "function" then
return env[name]
end
if type(getgenvFn) == "function" then
local s, g = pcall(getgenvFn)
if s and type(g) == "table" and type(g[name]) == "function" then
return g[name]
end
end
end
return nil
end
local ClipboardFunc = GetClipboardFunc()
local function GetScriptBytecode(script: LuaSourceContainer): string?
local env = getfenv()
if type(getgenvFn) == "function" then
local s, g = pcall(getgenvFn)
if s and type(g) == "table" and type(g.getscriptbytecode) == "function" then
local bs, b = pcall(g.getscriptbytecode, script)
if bs and type(b) == "string" and #b > 0 then
return b
end
end
end
if type(env.getscriptbytecode) == "function" then
local bs, b = pcall(env.getscriptbytecode, script)
if bs and type(b) == "string" and #b > 0 then
return b
end
end
if type(RAW_ENV.getscriptbytecode) == "function" then
-- executor signature wants Script|LocalScript|ModuleScript|CoreScript
local bs, b = pcall(RAW_ENV.getscriptbytecode, script :: any) -- <<< THE FIX
if bs and type(b) == "string" and #b > 0 then
return b
end
end
return nil
end
local MALICIOUS_PATTERNS: { [string]: PatternData } = {
ExecutorFunctions = {
patterns = {
"getrawmetatable%s*%(",
"setrawmetatable%s*%(",
"hookfunction%s*%(",
"hookmetamethod%s*%(",
"replaceclosure%s*%(",
"checkcaller%s*%(",
"islclosure%s*%(",
"iscclosure%s*%(",
"getgenv%s*%(",
"setgenv%s*%(",
"getconsenv%s*%(",
"clonefunction%s*%(",
"cloneref%s*%(",
"cloneclosure%s*%(",
"newcclosure%s*%(",
"getcallingscript%s*%(",
"getloadedmodules%s*%(",
"getconnections%s*%(",
"rconsolename%s*%(",
"rconsoleprint%s*%(",
"rconsoleclear%s*%(",
"WriteFile%s*%(",
"ReadFile%s*%(",
"listfiles%s*%(",
"isfile%s*%(",
"isfolder%s*%(",
"makefolder%s*%(",
"delfolder%s*%(",
"delfile%s*%(",
"loadfile%s*%(",
"dumpgame%s*%(",
"gethui%s*%(",
"getcustomasset%s*%(",
"queue_on_teleport%s*%(",
"downloadfile%s*%(",
"setidentity%s*%(",
"getidentity%s*%(",
"setthreadidentity%s*%(",
"getthreadidentity%s*%(",
"identifyexecutor%s*%(",
"getinstances%s*%(",
"getnilinstances%s*%(",
"getreg%s*%(",
"getrenv%s*%(",
"getsenv%s*%(",
"getscriptclosure%s*%(",
"getscriptbytecode%s*%(",
"getscripthash%s*%(",
"isourgame%s*%(",
"saveinstance%s*%(",
"getsingleton%s*%(",
"setcapability%s*%(",
"getcapability%s*%(",
"protectgui%s*%(",
"fireclickdetector%s*%(",
"fireproximityprompt%s*%(",
"firetouchinterest%s*%(",
"sethiddenproperty%s*%(",
"gethiddenproperty%s*%(",
"setsimulationradius%s*%(",
"messagebox%s*%(",
-- Restored from the original edition (frontier-guarded to cut false positives)
"%f[%w_]setclipboard%s*%(",
"%f[%w_]httpget%s*%(",
"%f[%w_]http_post%s*%(",
"%f[%w_]http_request%s*%(",
"%f[%w_]request%s*%(",
"%f[%w_]Drawing%s*%.%s*new",
},
severity = "CRITICAL",
description = "Executor/Exploit API detected in code",
target = "Game Client / Environment",
exploit_impact = "Run arbitrary code, bypass anti-cheats, and modify game memory.",
benign_reason = "Very rarely used in legitimate development. Sometimes falsely flagged in custom admin systems or anti-exploit modules if they attempt to detect these themselves.",
suggested_action = "Remove immediately. If this is an anti-exploit script, ensure it is only checking for the existence of these functions and not executing them.",
},
DynamicExecution = {
patterns = {
"Lua%s*:%s*Compile%s*%(",
"CompileString%s*%(",
"Instance%s*%.%s*new%s*%(%s*['\"]LuaSourceContainer",
},
severity = "HIGH",
description = "Dynamic code execution detected",
target = "Lua Runtime",
exploit_impact = "Execute external or hidden code, bypassing Roblox security restrictions.",
benign_reason = "Sometimes used in highly specific sandbox or coding game environments.",
suggested_action = "Verify the source of the string being compiled. If it originates from a remote or user input, remove it.",
},
BackdoorPatterns = {
patterns = {
"Require%s*%(%s*[%d]+%s*%)",
"game%s*:%s*HttpGet%s*%(",
"game%s*:%s*HttpGetAsync%s*%(",
"HttpGet%s*%(%s*['\"]http[s]?://",
"HttpGetAsync%s*%(%s*['\"]http[s]?://",
},
severity = "HIGH",
description = "Potential backdoor pattern detected",
target = "Server / Game",
exploit_impact = "Run arbitrary code remotely, taking full control of the server.",
benign_reason = "Can occasionally be used for legitimate auto-updating systems or fetching public API data.",
suggested_action = "Check the URL or Asset ID. If unknown or hosted on a personal site/pastebin, remove it.",
},
Obfuscation = {
patterns = {
"\\x%x%x\\x%x%x\\x%x%x\\x%x%x\\x%x%x",
"string%s*%.%s*char%s*%(.{50,}",
"local%s+%w+%s*=%s*string%s*%.%s*reverse",
"table%s*%.%s*concat%s*%(.{30,}",
"[A-Za-z0-9+/=]{60,}",
},
severity = "MEDIUM",
description = "Code obfuscation detected",
target = "Source Code",
exploit_impact = "Hide malicious behavior from developers and automated scanners.",
benign_reason = "Sometimes used to protect proprietary algorithms or anti-cheat measures.",
suggested_action = "If you do not recognize the script or if it's a free model, remove it. Obfuscation is the #1 red flag for free model backdoors.",
},
SuspiciousHTTP = {
patterns = {
'http[s]?://[^"]*webhook',
'http[s]?://[^"]*discord',
'http[s]?://[^"]*pastebin',
'http[s]?://[^"]*gist',
'http[s]?://[^"]*github[^"]*raw',
'http[s]?://[^"]*tinyurl',
'http[s]?://[^"]*bit[^"]*ly',
},
severity = "HIGH",
description = "Suspicious HTTP endpoint detected",
target = "External Servers",
exploit_impact = "Send game data or player info to unauthorized third parties.",
benign_reason = "Could be a legitimate Discord webhook for server logging, but highly suspicious if combined with data collection.",
suggested_action = "Verify the URL. Ensure no sensitive player data (UserID, IP, etc.) is being sent to this endpoint.",
},
ClientSideAntiCheat = {
patterns = { "WalkSpeed%s*>%s*%d%d%d", "JumpPower%s*>%s*%d%d%d", "LocalPlayer%s*:%s*Kick" },
severity = "LOW",
description = "Client-Sided Anti-Cheat detected",
target = "Anti-Cheat System",
exploit_impact = "Easily bypassed by exploiters to use speed, fly, or noclip hacks.",
benign_reason = "Often used by inexperienced developers as a quick fix for exploiting.",
suggested_action = "Move anti-cheat checks to the server. Client checks are easily bypassed.",
},
ClientExploitReporter = {
patterns = {
"PlayerGui%.DescendantAdded",
"CoreGui%.DescendantAdded",
":FireServer%s*%(.-[Ee]xploit",
":FireServer%s*%(.-[Cc]heat",
":FireServer%s*%(.-[Bb]anned",
":FireServer%s*%(.-[Kk]ick",
"[Ee]xploit%s*detect",
"Suspicious%s*GUI",
"GuiMain",
"ReportExploit",
"DetectExploit",
"CheatDetect",
},
severity = "MEDIUM",
description = "Client-Sided Anti-Cheat/Exploit Reporter detected",
target = "Moderation System",
exploit_impact = "Spoofed by exploiters to false-ban innocent players or bypass detection.",
benign_reason = "Common in custom anti-cheat systems.",
suggested_action = "Ensure server-side validation accompanies these client checks.",
},
ExecutorBrands = {
patterns = { "Script%-Ware", "SW_executor", "identifyexecutor" },
severity = "HIGH",
description = "Reference to a known exploit/executor brand detected",
target = "Environment Fingerprint",
exploit_impact = "Target specific executor features or bypass anti-exploit measures.",
benign_reason = "None in standard game code.",
suggested_action = "Remove the script. It is explicitly checking for or interacting with exploit software.",
},
InsecureGlobals = {
patterns = {
"%f[%w_]_G%f[^%w_]",
"%f[%w_]_ENV%f[^%w_]",
"%f[%w_]shared%f[^%w_]",
"getfenv%s*%(%s*0%s*%)",
"setfenv%s*%(%s*0",
"rawset%s*%(.+_G",
"rawset%s*%(.+shared",
},
severity = "MEDIUM",
description = "Use of global environment manipulation detected",
target = "Global Environment (_G/shared)",
exploit_impact = "Hijack other scripts or modify core game functions.",
benign_reason = "_G and shared are sometimes used for cross-script communication, though it's bad practice.",
suggested_action = "Use BindableEvents or ModuleScripts instead of global variables.",
},
DebugLibraryAbuse = {
patterns = {
"debug%s*%.%s*getinfo",
"debug%s*%.%s*getlocal",
"debug%s*%.%s*setlocal",
"debug%s*%.%s*getupvalue",
"debug%s*%.%s*setupvalue",
"debug%s*%.%s*getregistry",
"debug%s*%.%s*getconstant",
"debug%s*%.%s*setconstant",
},
severity = "HIGH",
description = "Use of the Lua debug library detected",
target = "Lua Debug Library",
exploit_impact = "Read/write local variables and upvalues to bypass anti-cheats.",
benign_reason = "Rarely used in production game code, sometimes used in advanced profiling tools.",
suggested_action = "Remove if not part of a verified profiling suite.",
},
FreeModelBackdoor = {
patterns = { "Require%s*%(%s*7467125784%s*%)", "Require%s*%(%s*1382749228%s*%)" },
severity = "CRITICAL",
description = "Known free-model backdoor signature detected",
target = "Server",
exploit_impact = "Give the free model creator remote control over your game.",
benign_reason = "None.",
suggested_action = "Delete the script immediately. This is a confirmed malicious backdoor.",
},
MissingTextFilter = {
patterns = { "BroadcastMessage%s*%(", ":FireServer%s*%(.+GetMessage" },
severity = "MEDIUM",
description = "Potential unfiltered user input being sent",
target = "Chat / Text Input",
exploit_impact = "Bypass Roblox filters, display inappropriate or offensive text.",
benign_reason = "Could be broadcasting system messages generated by the server.",
suggested_action = "Ensure `TextService:FilterStringAsync` is used if broadcasting user-generated text.",
},
PredictableRNG = {
patterns = {
"math%s*%.%s*randomseed%s*%(.+tick",
"math%s*%.%s*randomseed%s*%(.+os%s*%.%s*time",
"math%s*%.%s*randomseed%s*%(.+time%s*%(",
"Random%s*%.%s*new%s*%(.+tick",
},
severity = "LOW",
description = "Seeding math.random with time-based values is predictable",
target = "Random Number Generation",
exploit_impact = "Predict loot drops or gacha rolls to cheat the economy.",
benign_reason = "Common naive implementation for random seeds.",
suggested_action = "Use `Random.new()` without a seed, or use `os.time()` combined with other variables.",
},
NetworkOwnership = {
patterns = {
"networkOwner%s*=",
"NetworkOwnership%s*=",
},
severity = "MEDIUM",
description = "Network ownership manipulation detected",
target = "Physics Server",
exploit_impact = "Teleport, fling, or replicate arbitrary physics objects.",
benign_reason = "Sometimes used legitimately to assign ownership of projectiles or vehicles.",
suggested_action = "Ensure this is not used on player characters or critical unanchored parts.",
},
ClipboardAndExfil = {
patterns = {
"setclipboard%s*%(.+game%s*%.%s*GetService",
"setclipboard%s*%(.+HttpService",
"toskype%s*%(",
"request%s*%(.+webhook",
"request%s*%(.+discord",
"writefile%s*%(.+rolio",
"writefile%s*%(.+cookie",
},
severity = "HIGH",
description = "Clipboard/file write with sensitive data or webhook exfiltration detected",
target = "Clipboard / Local Files",
exploit_impact = "Steal clipboard data or write malicious files to the user's PC.",
benign_reason = "None.",
suggested_action = "Remove immediately. This is explicit data theft.",
},
}
local SUSPICIOUS_NAMES = {
"backdoor",
"inject",
"exploit",
"payload",
"shell",
"stealer",
"grabber",
"logger",
"webhook",
"exfil",
"token",
"cookie",
"malware",
"ratel",
"rce",
"spoofer",
"bypass",
"rootkit",
"keylogger",
"ransomware",
}
local HIGH_RISK_REMOTE_NAMES = { "admin", "kick", "ban", "unban", "god", "kill", "noclip", "fly", "command", "cmd" }
local MEDIUM_RISK_REMOTE_NAMES = {
"give",
"reward",
"money",
"cash",
"teleport",
"tp",
"setrank",
"promote",
"refund",
"freemoney",
"currency",
"coins",
"gems",
"win",
"setdata",
"loaddata",
"deletedata",
}
-- Matched against GetFullName(). (The old "Players.LocalPlayer..." entries never matched,
-- because GetFullName() uses the player's real name.)
local WHITELIST_PATHS = {
"PlayerScripts.RbxCharacter",
"PlayerScripts.RbxCore",
"PlayerScripts.PlayerModule",
"PlayerScripts.ChatScript",
"PlayerScripts.BubbleChat",
"CoreGui",
"RobloxGui",
"ChatScripts",
}
local DEFAULT_SAFE_SCRIPT_NAMES = {
["Health"] = true,
["Animate"] = true,
["Sound"] = true,
["RbxCharacter"] = true,
["RbxCore"] = true,
["FallDamage"] = true,
["GetPoses"] = true,
["DistributedPhysics"] = true,
["PlayerModule"] = true,
}
local CLICK_PATTERNS = {
"MouseClick%s*:%s*Connect",
"RightMouseClick%s*:%s*Connect",
"MouseHoverEnter%s*:%s*Connect",
"MouseHoverLeave%s*:%s*Connect",
"MouseClick%s*:%s*[Ww]ait",
}
local DANGEROUS_CLICK_PATTERNS = {
{
pattern = "while%s+true%s+do",
desc = "triggers an infinite loop without cooldown",
sev = "HIGH",
action = "Add a break condition or cooldown to the loop.",
},
{
pattern = "while%s+wait",
desc = "triggers an infinite loop without cooldown",
sev = "HIGH",
action = "Add a break condition or cooldown to the loop.",
},
{
pattern = "while%s+task%.wait",
desc = "triggers an infinite loop without cooldown",
sev = "HIGH",
action = "Add a break condition or cooldown to the loop.",
},
{
pattern = "Instance%.new%s*%(",
desc = "triggers instance creation",
sev = "MEDIUM",
action = "Limit instance creation per click and clean up old instances.",
},
{
pattern = ":Destroy%s*%(",
desc = "triggers instance destruction",
sev = "LOW",
action = "Ensure destruction is safe and not spammable.",
},
{
pattern = "FireServer%s*%(",
desc = "triggers a RemoteEvent",
sev = "MEDIUM",
action = "Ensure server validates click frequency and remote arguments.",
},
{
pattern = "InvokeServer%s*%(",
desc = "triggers a RemoteFunction",
sev = "MEDIUM",
action = "Ensure server validates click frequency and remote arguments.",
},
}
-- The detector itself contains every pattern string, so never scan it
local SELF_SCRIPT = (typeof(script) == "Instance") and script or nil
-- Exact subtrees to skip entirely (the instance itself and everything under it)
local SKIP_SUBTREES = {
"ReplicatedStorage.DataService",
"ReplicatedStorage.PurchaseNotifications",
}
local function IsSkippedSubtree(instance: Instance): boolean
local path = instance:GetFullName()
for _, skip in ipairs(SKIP_SUBTREES) do
if path == skip or string.sub(path, 1, #skip + 1) == skip .. "." then
return true
end
end
return false
end
local function IsWhitelisted(instance: Instance): boolean
if SELF_SCRIPT and instance == SELF_SCRIPT then
return true
end
if IsSkippedSubtree(instance) then
return true
end
local path = instance:GetFullName()
for _, pattern in ipairs(WHITELIST_PATHS) do
if string.find(path, pattern, 1, true) then
return true
end
end
return false
end
local function HasSuspiciousName(instance: Instance): boolean
local nameLower = string.lower(instance.Name)
for _, suspicious in ipairs(SUSPICIOUS_NAMES) do
if string.find(nameLower, "%f[%a]" .. suspicious .. "%f[%A]") then
return true
end
end
return false
end
-- Per-script result cache: a string is the source, false means "no usable source".
-- Guarantees each script is read/decompiled at most once per scan.
local SOURCE_CACHE: { [LuaSourceContainer]: string | false } = setmetatable({}, { __mode = "k" }) :: any
local function GetScriptSource(script: LuaSourceContainer): string?
local cached = SOURCE_CACHE[script]
if cached ~= nil then
return if cached then cached else nil
end
local source = ReadScriptProp(script, "Source")
if typeof(source) == "string" and #source > 0 then
SOURCE_CACHE[script] = source
return source
end
if Decompiler then
-- Decompiling huge/obfuscated bytecode stalls the main thread; skip it
local bytecode = GetScriptBytecode(script)
if bytecode and #bytecode > CONFIG.MaxBytecodeSize then
SOURCE_CACHE[script] = false
return nil
end
-- Let the UI render the current file name before the blocking decompile call
task.wait()
local dSuccess, dSource = pcall(Decompiler, script)
if dSuccess and typeof(dSource) == "string" and #dSource > 0 then
local lowerSource = string.lower(dSource)
if #lowerSource < 50 and (string.find(lowerSource, "error") or string.find(lowerSource, "fail")) then
SOURCE_CACHE[script] = false
return nil
end
SOURCE_CACHE[script] = dSource
return dSource
end
end
SOURCE_CACHE[script] = false
return nil
end
local function BuildContext(source: string): ScanContext
local ctx: ScanContext = {
hasHttp = false,
hasWebhook = false,
hasRemote = false,
hasLoadstring = false,
hasExecutor = false,
hasDataCollection = false,
hasTeleport = false,
}
if
string.find(source, "HttpService")
or string.find(source, "request%s*%(")
or string.find(source, "http_request")
or string.find(source, "game:HttpGet")
then
ctx.hasHttp = true
end
if string.find(source, "[Ww]ebhook") or string.find(source, "[Dd]iscord") then
ctx.hasWebhook = true
end
if string.find(source, "FireServer") or string.find(source, "InvokeServer") then
ctx.hasRemote = true
end
if string.find(source, "loadstring") then
ctx.hasLoadstring = true
end
if string.find(source, "getfenv") or string.find(source, "getrawmetatable") or string.find(source, "hookfunction") then
ctx.hasExecutor = true
end
if
string.find(source, "GetFriendsOnline")
or string.find(source, "GetUserIdFromNameAsync")
or string.find(source, "GetGroupsAsync")
or string.find(source, "GetRankInGroup")
then
ctx.hasDataCollection = true
end
if string.find(source, "TeleportService") then
ctx.hasTeleport = true
end
return ctx
end
local function CheckPurchaseVulnerability(script: LuaSourceContainer, source: string): Threat?
if not source or #source == 0 then
return nil
end
local isClientScript = false
if script:IsA("LocalScript") then
isClientScript = true
else
-- Cast to `any` to bypass Luau's strict type checking on the abstract LuaSourceContainer class
local s, r = pcall(function()
return (script :: any).RunContext
end)
if s and r == Enum.RunContext.Client then
isClientScript = true
end
end
if not isClientScript then
return nil
end
local hasPurchaseEvent = string.find(source, "PromptProductPurchaseFinished")
or string.find(source, "PromptGamepassPurchaseFinished")
or string.find(source, "PromptPurchaseFinished")
local hasRewardLogic = string.find(source, "leaderstats")
if hasPurchaseEvent and hasRewardLogic then
local lineNumber = 1
local lines = string.split(source, "\n")
for i, line in ipairs(lines) do
if string.find(line, "leaderstats") then
lineNumber = i
break
end
end
return {
Category = "PurchaseVulnerability",
Severity = "HIGH",
Confidence = "High",
Description = "Purchase validation or reward-granting logic detected inside a LocalScript.",
Target = "Monetization System",
ExploitImpact = "Spoof purchase success to get free items or gamepass rewards.",
Pattern = "Client-Side Purchase Reward",
LineNumber = lineNumber,
Evidence = "LocalScript handling both purchase events and reward logic.",
BenignReason = "Sometimes developers mistakenly put UI purchase handling and reward logic in the same client script.",
SuggestedAction = "Move all reward granting (leaderstats updates) to the server.",
}
end
return nil
end
local function AnalyzeScript(script: LuaSourceContainer, source: string?): { Threat }
local scriptThreats: { Threat } = {}
if IsWhitelisted(script) then
return scriptThreats
end
if HasSuspiciousName(script) then
table.insert(scriptThreats, {
Category = "SuspiciousName",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "Script has a suspicious name.",
Pattern = script.Name,
Target = "Script Identity",
ExploitImpact = "Disguise malicious scripts as harmless ones.",
LineNumber = 1,
Evidence = script.Name,
BenignReason = "Could be an anti-exploit script named defensively (e.g., 'AntiExploit').",
SuggestedAction = "Review the script source to ensure it is not malicious.",
})
end
if source and #source > 0 then
local ctx = BuildContext(source)
local lines = string.split(source, "\n")
-- Pattern matching with several wildcards is super-linear in line length, and one string.find
-- can't be interrupted, so a huge line would freeze the client. Long lines are therefore cut into
-- overlapping chunks and each chunk is matched separately (cost stays bounded, detection stays).
local segText: { string } = {}
local segLine: { number } = {}
for idx, ln in ipairs(lines) do
if #ln > CONFIG.MaxLineLength then
table.insert(scriptThreats, {
Category = "Obfuscation",
Severity = "MEDIUM",
Confidence = "High",
Description = "Extremely long line detected (" .. #ln .. " chars)",
Pattern = "LongLine",
Target = "Source Code",
ExploitImpact = "Hide malicious behavior from developers and automated scanners.",
LineNumber = idx,
Evidence = "Line length: " .. #ln,
BenignReason = "Could be a minified library or large data table.",
SuggestedAction = "If this is a free model, remove it. If it's a library, ensure it comes from a trusted source.",
})
end
if #ln <= CONFIG.MaxRegexChunk then
table.insert(segText, ln)
table.insert(segLine, idx)
else
local step = CONFIG.MaxRegexChunk - CONFIG.ChunkOverlap
local start = 1
while start <= #ln do
table.insert(segText, string.sub(ln, start, start + CONFIG.MaxRegexChunk - 1))
table.insert(segLine, idx)
if start + CONFIG.MaxRegexChunk - 1 >= #ln then
break
end
start += step
end
end
end
for k, line in ipairs(segText) do
local i = segLine[k]
local trimmedLine = line:match("^%s*(.-)$") or line
if #trimmedLine == 0 or trimmedLine:sub(1, 2) == "--" then
continue
end
if #trimmedLine > 200 then
trimmedLine = string.sub(trimmedLine, 1, 200) .. "..."
end
-- GetService(...HttpService...).GetAsync on one line: three plain searches, no backtracking
local gs = string.find(line, "GetService", 1, true)
if gs then
local hs = string.find(line, "HttpService", gs, true)
if hs and string.find(line, "GetAsync", hs, true) then
table.insert(scriptThreats, {
Category = "BackdoorPatterns",
Severity = "HIGH",
Confidence = "High",
Description = "Potential backdoor pattern detected",
Target = "Server / Game",
ExploitImpact = "Run arbitrary code remotely, taking full control of the server.",
Pattern = "GetService(HttpService) ... GetAsync",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Can occasionally be used for legitimate auto-updating systems or fetching public API data.",
SuggestedAction = "Check the URL or Asset ID. If unknown or hosted on a personal site/pastebin, remove it.",
})
end
end
if
string.find(line, "GetFriendsOnline")
or string.find(line, "GetFriendsAsync")
or string.find(line, "GetUserIdFromNameAsync")
or string.find(line, "GetNameFromUserIdAsync")
or string.find(line, "GetRankInGroup")
or string.find(line, "GetRoleInGroup")
or string.find(line, "GetGroupsAsync")
then
if ctx.hasHttp or ctx.hasWebhook then
table.insert(scriptThreats, {
Category = "DataExfiltration",
Severity = "HIGH",
Confidence = "High",
Description = "Player data collection combined with external HTTP transmission.",
Target = "Player Data",
ExploitImpact = "Steal sensitive user information (IP, friends, inventory) and send it externally.",
Pattern = "Data Collection API",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Could be a legitimate third-party service integration, but highly suspicious for data theft.",
SuggestedAction = "Verify the destination URL and ensure no sensitive PII is being sent without consent.",
})
else
table.insert(scriptThreats, {
Category = "DataCollection",
Severity = "LOW",
Confidence = "Medium",
Description = "Player data collection API used.",
Target = "Player Data",
ExploitImpact = "Gather information about players.",
Pattern = "Data Collection API",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Common in group management, friend lists, or admin systems.",
SuggestedAction = "Ensure this data is not later passed to an external HTTP request.",
})
end
end
-- Outbound POST/Request in a script that also collects player data (restored DataExfiltration patterns, context-gated)
if
(
string.find(line, "HttpService%s*:%s*PostAsync")
or string.find(line, "HttpService%s*:%s*RequestAsync")
or string.find(line, ":%s*PostAsync%s*%(")
or string.find(line, ":%s*RequestAsync%s*%(")
) and (ctx.hasDataCollection or ctx.hasWebhook)
then
table.insert(scriptThreats, {
Category = "DataExfiltration",
Severity = "HIGH",
Confidence = "High",
Description = "Outbound HTTP POST/request in a script that also collects player data or references webhooks.",
Target = "Player Data",
ExploitImpact = "Steal sensitive user information (IP, friends, inventory) and send it externally.",
Pattern = "PostAsync/RequestAsync + data collection",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Could be legitimate analytics or logging to your own server.",
SuggestedAction = "Verify the destination URL and what data is in the request body.",
})
end
if
string.find(line, "TeleportService%s*:%s*Teleport")
or string.find(line, "TeleportService%s*:%s*TeleportToPlaceInstance")
or string.find(line, "TeleportService%s*:%s*TeleportPartyAsync")
then
if string.find(line, "game%.PlaceId") or string.find(line, "game%.JobId") or string.find(line, "PlaceId") then
table.insert(scriptThreats, {
Category = "InsecureTeleport",
Severity = "LOW",
Confidence = "Low",
Description = "TeleportService used targeting the current PlaceId/JobId.",
Target = "TeleportService",
ExploitImpact = "None directly, likely reconnect logic.",
Pattern = "TeleportService:Teleport(game.PlaceId)",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "This is standard practice for auto-rejoin or place-instance teleportation.",
SuggestedAction = "No action required if this is used for reconnecting players.",
})
elseif ctx.hasHttp or ctx.hasRemote or ctx.hasExecutor then
table.insert(scriptThreats, {
Category = "InsecureTeleport",
Severity = "HIGH",
Confidence = "High",
Description = "TeleportService destination derived from external/remote source.",
Target = "TeleportService",
ExploitImpact = "Teleport players to malicious games to steal account information.",
Pattern = "TeleportService:Teleport(ExternalVariable)",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Could be a dynamic server browser, but often used to redirect to malicious games.",
SuggestedAction = "Check where the destination PlaceId comes from. Ensure it is hardcoded or from a trusted source.",
})
else
table.insert(scriptThreats, {
Category = "InsecureTeleport",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "TeleportService used with a dynamic destination.",
Target = "TeleportService",
ExploitImpact = "Teleport players to untrusted experiences.",
Pattern = "TeleportService Usage",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Could be legitimate fast-travel or game hub system.",
SuggestedAction = "Verify the destination PlaceId is trusted and hardcoded.",
})
end
end
if string.find(line, ":FireServer") or string.find(line, ":InvokeServer") then
local lowerLine = string.lower(line)
local isPrivileged = false
local matchedPriv = ""
for _, p in ipairs(HIGH_RISK_REMOTE_NAMES) do
if string.find(lowerLine, p) then
isPrivileged = true
matchedPriv = p
break
end
end
local isVararg = string.find(line, "%.%.%.%s*%)") or string.find(line, "unpack")
if isPrivileged then
table.insert(scriptThreats, {
Category = "ClientAuthBypass",
Severity = "HIGH",
Confidence = "High",
Description = "Client-driven privileged action detected via Remote.",
Target = "Server Authority",
ExploitImpact = "Gain admin rights, kick/ban players, or spawn items directly from the client.",
Pattern = "FireServer(... " .. matchedPriv .. " ...)",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Could be a client UI button sending a request to the server, but the server must validate it.",
SuggestedAction = "Ensure the server strictly checks player permissions and arguments for this remote.",
})
elseif isVararg then
table.insert(scriptThreats, {
Category = "VarargRemoteFire",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "Vararg Remote Firing detected.",
Target = "Server Remotes",
ExploitImpact = "Pass unexpected arguments to crash or exploit server logic.",
Pattern = "FireServer(...)",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Sometimes used for generic chat or event remotes.",
SuggestedAction = "Ensure the server uses `typeof()` checks on all arguments received.",
})
end
end
if string.find(line, "loadstring%s*%(") then
if ctx.hasHttp then
table.insert(scriptThreats, {
Category = "FetchAndExecute",
Severity = "CRITICAL",
Confidence = "High",
Description = "Remote code execution chain detected (loadstring + HTTP).",
Target = "Server / Client",
ExploitImpact = "Download and execute malicious code on the fly.",
Pattern = "loadstring(HttpGet(...))",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Very rarely used in legitimate sandbox environments.",
SuggestedAction = "Remove immediately. Do not use loadstring with external content.",
})
else
table.insert(scriptThreats, {
Category = "DynamicExecution",
Severity = "HIGH",
Confidence = "Medium",
Description = "Dynamic code execution detected (loadstring).",
Target = "Lua Runtime",
ExploitImpact = "Execute hidden code, bypassing Roblox security restrictions.",
Pattern = "loadstring(...)",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Can be used for custom command bars or in-game scripting features.",
SuggestedAction = "Ensure `ServerScriptService.LoadStringEnabled` is false unless explicitly required.",
})
end
end
if string.find(line, "getfenv%s*%(") or string.find(line, "setfenv%s*%(") then
table.insert(scriptThreats, {
Category = "DynamicExecution",
Severity = "HIGH",
Confidence = "High",
Description = "Environment manipulation detected.",
Target = "Lua Runtime",
ExploitImpact = "Hijack global functions, modify script environments, or hide malicious code.",
Pattern = "getfenv/setfenv",
LineNumber = i,
Evidence = trimmedLine,
BenignReason = "Legacy code might use this for OOP or sandboxing, but it's bad practice.",
SuggestedAction = "Remove and replace with modern Luau practices.",
})
end
for category, data in pairs(MALICIOUS_PATTERNS) do
if category ~= "DynamicExecution" and category ~= "ClientAuthBypass" and category ~= "VarargRemoteFire" then
for _, pattern in ipairs(data.patterns) do
if string.find(line, pattern) then
table.insert(scriptThreats, {
Category = category,
Severity = data.severity,
Confidence = "High",
Description = data.description,
Target = data.target,
ExploitImpact = data.exploit_impact,
Pattern = pattern,
LineNumber = i,
Evidence = trimmedLine,
BenignReason = data.benign_reason or "None.",
SuggestedAction = data.suggested_action or "Review the context of this line.",
})
break
end
end
end
end
SafeYield()
end
-- Chunk overlap can report the same hit twice
local seenKeys: { [string]: boolean } = {}
local unique: { Threat } = {}
for _, t in ipairs(scriptThreats) do
local key = t.Category .. ":" .. tostring(t.LineNumber) .. ":" .. tostring(t.Pattern)
if not seenKeys[key] then
seenKeys[key] = true
table.insert(unique, t)
end
end
scriptThreats = unique
local purchaseThreat = CheckPurchaseVulnerability(script, source)
if purchaseThreat then
table.insert(scriptThreats, purchaseThreat)
end
-- Deep Tokenizer Pass
local deepThreats = TokenizeAndAnalyze(source, script)
-- Skip tokenizer hits the line scanner already reported (same category + line)
local seenHits = {}
for _, t in ipairs(scriptThreats) do
seenHits[t.Category .. ":" .. tostring(t.LineNumber)] = true
end
for _, t in ipairs(deepThreats) do
local key = t.Category .. ":" .. tostring(t.LineNumber)
if not seenHits[key] then
seenHits[key] = true
table.insert(scriptThreats, t)
end
end
end
return scriptThreats
end
local function CheckPlayerCollisions(): { Threat }
local physicsThreats: { Threat } = {}
local PhysicsService = game:GetService("PhysicsService")
local success, collisionGroups = pcall(function()
return PhysicsService:GetCollisionGroups()
end)
if not success or not collisionGroups then
return physicsThreats
end
if #collisionGroups == 0 then
table.insert(physicsThreats, {
Category = "PlayerCollisionEnabled",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "No custom collision groups found. Default player-to-player collisions are likely enabled.",
Pattern = "Default",
Target = "Physics Service",
ExploitImpact = "Exploiters can fling other players across the map.",
Instance = nil,
InstancePath = "PhysicsService (Default)",
LineNumber = 1,
Evidence = "No collision groups defined.",
BenignReason = "Some games might not need collision groups if players cannot interact physically.",
SuggestedAction = "Create a collision group for players and disable self-collision.",
})
return physicsThreats
end
local playerGroups = {}
for _, group in ipairs(collisionGroups) do
local lowerName = string.lower(group.name)
if string.find(lowerName, "player") or string.find(lowerName, "character") or string.find(lowerName, "humanoid") then
table.insert(playerGroups, group.name)
end
end
if #playerGroups == 0 then
table.insert(physicsThreats, {
Category = "PlayerCollisionEnabled",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "No specific collision group found for players.",
Pattern = "Default",
Target = "Physics Service",
ExploitImpact = "Exploiters can fling other players across the map.",
Instance = nil,
InstancePath = "PhysicsService (Default)",
LineNumber = 1,
Evidence = "No player-specific collision groups.",
BenignReason = "Might be handled via custom physics or constraints.",
SuggestedAction = "Create a collision group for players and disable self-collision.",
})
else
for _, groupName in ipairs(playerGroups) do
local collidableSuccess, isCollidable = pcall(function()
return PhysicsService:CollisionGroupsAreCollidable(groupName, groupName)
end)
if collidableSuccess and isCollidable then
table.insert(physicsThreats, {
Category = "PlayerCollisionEnabled",
Severity = "MEDIUM",
Confidence = "High",
Description = "Player-to-player collisions are enabled in PhysicsService (" .. groupName .. ").",
Pattern = groupName,
Target = "Physics Service",
ExploitImpact = "Exploiters can fling other players across the map.",
Instance = nil,
InstancePath = "PhysicsService (" .. groupName .. ")",
LineNumber = 1,
Evidence = 'CollisionGroupsAreCollidable("' .. groupName .. '", "' .. groupName .. '") == true',
BenignReason = "Required for certain combat or physical interaction games.",
SuggestedAction = "If not strictly necessary, disable self-collision for this group.",
})
end
end
end
return physicsThreats
end
local function CheckSuspiciousRemotes(): { Threat }
local remoteThreats: { Threat } = {}
local servicesToScan = { game:GetService("ReplicatedStorage"), game:GetService("Workspace") }
for _, service in ipairs(servicesToScan) do
for _, descendant in ipairs(service:GetDescendants()) do
if (descendant:IsA("RemoteEvent") or descendant:IsA("RemoteFunction")) and not IsSkippedSubtree(descendant) then
local nameLower = string.lower(descendant.Name)
local matchedHigh = nil
for _, p in ipairs(HIGH_RISK_REMOTE_NAMES) do
if string.find(nameLower, p) then
matchedHigh = p
break
end
end
local matchedMedium = nil
for _, p in ipairs(MEDIUM_RISK_REMOTE_NAMES) do
if string.find(nameLower, p) then
matchedMedium = p
break
end
end
if matchedHigh then
table.insert(remoteThreats, {
Category = "SuspiciousRemote",
Severity = "HIGH",
Confidence = "Medium",
Description = "High-risk remote name detected. Ensure strict server-side validation.",
Pattern = descendant.Name,
Target = "Server Remotes",
ExploitImpact = "Exploiters can fire this directly to gain unauthorized privileges.",
Instance = descendant,
InstancePath = descendant:GetFullName(),
LineNumber = 1,
Evidence = "Remote Name: " .. descendant.Name,
BenignReason = "Could be a legitimate admin remote, but dangerous if exposed.",
SuggestedAction = "Verify server-side checks. Ensure exploiter cannot grant themselves privileges.",
})
elseif matchedMedium then
table.insert(remoteThreats, {
Category = "SuspiciousRemote",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "Medium-risk remote name detected. Verify server-side sanity checks.",
Pattern = descendant.Name,
Target = "Server Remotes",
ExploitImpact = "Exploiters can fire this to duplicate items or manipulate data.",
Instance = descendant,
InstancePath = descendant:GetFullName(),
LineNumber = 1,
Evidence = "Remote Name: " .. descendant.Name,
BenignReason = "Common in standard game logic.",
SuggestedAction = "Ensure the server validates purchases, cooldowns, and data integrity.",
})
end
end
SafeYield()
end
end
return remoteThreats
end
local function CheckUnanchoredParts(): { Threat }
local partThreats: { Threat } = {}
local workspace = game:GetService("Workspace")
local count = 0
local flagged = false
for _, part in ipairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and not part.Anchored and not part.CanCollide then
local ancestorModel = part:FindFirstAncestorWhichIsA("Model")
if not ancestorModel or not ancestorModel:FindFirstChild("Humanoid") then
count += 1
end
end
if count > 20 and not flagged then
table.insert(partThreats, {
Category = "UnanchoredParts",
Severity = "MEDIUM",
Confidence = "Medium",
Description = "Found many unanchored, non-colliding parts in Workspace.",
Pattern = "NetworkOwnership Exploit",
Target = "Physics Server",
ExploitImpact = "Exploiters can use NetworkOwnership to fling players across the map or cause lag.",
Instance = nil,
InstancePath = "Workspace",
LineNumber = 1,
Evidence = "Count: " .. count .. " unanchored non-colliding parts.",
BenignReason = "Could be debris, particles, or physical projectiles.",
SuggestedAction = "Anchor these parts or set their NetworkOwnership to nil/server.",
})
flagged = true
break
end
SafeYield()
end
return partThreats
end
local REPLICATION_PATTERNS = {
"Instance%s*%.%s*new%s*%(%s*['\"]Script",
"Instance%s*%.%s*new%s*%(%s*['\"]LocalScript",
"Source%s*=%s*loadstring",
"Source%s*=%s*readfile",
}
local function CheckFreeModelReplication(): { Threat }
local replThreats: { Threat } = {}
local servicesToScan = {
game:GetService("Workspace"),
game:GetService("ReplicatedStorage"),
game:GetService("ReplicatedFirst"),
game:GetService("StarterGui"),
game:GetService("StarterPack"),
game:GetService("StarterPlayer"),
}
for _, service in ipairs(servicesToScan) do -- (1)
for _, descendant in ipairs(service:GetDescendants()) do -- (2)
if descendant:IsA("LuaSourceContainer") and not IsWhitelisted(descendant) then -- (3)
local source = GetScriptSource(descendant)
if source and #source > 0 then -- (4)
local lines = string.split(source, "\n")
for i, line in ipairs(lines) do -- (5)
for _, pattern in ipairs(REPLICATION_PATTERNS) do -- (6)
if string.find(line, pattern) then -- (7)
table.insert(replThreats, {
Category = "FreeModelReplication",
Severity = "HIGH",
Confidence = "High",
Description = "Script appears to clone itself or create new scripts at runtime.",
Pattern = pattern,
Target = "Server / Game",
ExploitImpact = "Self-replicating malware can spread through the game and infect other scripts.",
Instance = descendant,
InstancePath = descendant:GetFullName(),
LineNumber = i,
Evidence = line:match("^%s*(.-)$") or line,
BenignReason = "Very rarely used for legitimate dynamic loading systems.",
SuggestedAction = "Remove the script. Runtime script creation is highly dangerous.",
})
break
end -- /(7)
end -- /(6)
end -- /(5)
end -- /(4)
end -- /(3)
SafeYield()
end -- /(2)
end -- /(1) <-- THIS WAS MISSING
return replThreats
end
local CLIENT_ACCESSIBLE_SERVICES = {
["ReplicatedStorage"] = true,
["ReplicatedFirst"] = true,
["StarterGui"] = true,
["StarterPack"] = true,
["StarterPlayer"] = true,
}
local function CheckExposedServerScripts(): { Threat }
local exposedThreats: { Threat } = {}
local seen: { [Instance]: boolean } = {}
for _, service in ipairs(game:GetChildren()) do
if CLIENT_ACCESSIBLE_SERVICES[service.Name] then
for _, descendant in ipairs(service:GetDescendants()) do
if
descendant:IsA("Script")
and not descendant:IsA("LocalScript")
and not seen[descendant]
and not IsWhitelisted(descendant)
and not descendant:FindFirstAncestorWhichIsA("Tool")
then
local runContext = ReadScriptProp(descendant :: any, "RunContext")
local isServer = (runContext == Enum.RunContext.Server)
local isSafeDefault = DEFAULT_SAFE_SCRIPT_NAMES[descendant.Name]
if isServer and not isSafeDefault then
seen[descendant] = true
table.insert(exposedThreats, {
Category = "ExposedServerScript",
Severity = "MEDIUM",
Confidence = "High",
Description = "A server 'Script' (RunContext: Server) was found in a client-accessible service.",
Pattern = "ServerScript in " .. service.Name,
Target = "Server Source Code",
ExploitImpact = "Clients can view the structure and logic of server scripts, making it easier to find exploits.",
Instance = descendant,
InstancePath = descendant:GetFullName(),
LineNumber = 1,
Evidence = "Instance: " .. descendant:GetFullName(),
BenignReason = "If the script's Source is empty (compiled), clients cannot read the logic, only the structure.",
SuggestedAction = "Move server scripts to `ServerScriptService` or `ServerStorage`.",
})
end
end
SafeYield()
end
end
end
return exposedThreats
end
local function CheckClickDetectors(): { Threat }
local threats: { Threat } = {}
local clickDetectors: { ClickDetector } = {}
for _, service in ipairs(game:GetChildren()) do
for _, desc in ipairs(service:GetDescendants()) do
if desc:IsA("ClickDetector") then
table.insert(clickDetectors, desc)
end
SafeYield()
end
end
if #clickDetectors == 0 then
return threats
end
local scriptsToScan: { LuaSourceContainer } = {}
for _, service in ipairs(game:GetChildren()) do
for _, desc in ipairs(service:GetDescendants()) do
if desc:IsA("LuaSourceContainer") then
table.insert(scriptsToScan, desc)
end
SafeYield()
end
end
for _, script in ipairs(scriptsToScan) do
if IsWhitelisted(script) then
continue
end
local source = GetScriptSource(script)
if not source then
continue
end
local hasClickHandler = false
for _, p in ipairs(CLICK_PATTERNS) do
if string.find(source, p) then
hasClickHandler = true
break
end
end
if not hasClickHandler then
continue
end
local matchedClickDetector: ClickDetector? = nil
for _, cd in ipairs(clickDetectors) do
if string.find(source, cd.Name, 1, true) then
matchedClickDetector = cd
break
end
end
if not matchedClickDetector then
for _, cd in ipairs(clickDetectors) do
if script:IsDescendantOf(cd.Parent) or script == cd.Parent then
matchedClickDetector = cd
break
end
end
end
if not matchedClickDetector and #clickDetectors > 0 then
matchedClickDetector = clickDetectors[1]
end
local cdPath = matchedClickDetector and matchedClickDetector:GetFullName() or "Unknown ClickDetector"
local scriptType = "Script"
if script:IsA("LocalScript") then
scriptType = "LocalScript"
elseif script:IsA("ModuleScript") then
scriptType = "ModuleScript"
end
local foundDangerous = false
local lines = string.split(source, "\n")
for i, line in ipairs(lines) do
for _, data in ipairs(DANGEROUS_CLICK_PATTERNS) do
if string.find(line, data.pattern) then
foundDangerous = true
table.insert(threats, {
Category = "ClickDetectorAbuse",
Severity = data.sev,
Confidence = "High",
Description = "ClickDetector Server Spam Vulnerability",
Target = "Server Performance / Remotes",
ExploitImpact = "Exploiters could spam clicks to overload the server, create instances, or fire remotes excessively.",
Pattern = data.pattern,
Instance = script,
InstancePath = script:GetFullName(),
LineNumber = i,
Evidence = string.format(
"Path: %s\nScript: %s (%s)\nReason: ClickDetector.MouseClick %s.\nExploiters could spam clicks to impact server.",
cdPath,
script:GetFullName(),
scriptType,
data.desc
),
BenignReason = "Could be a legitimate one-time action, but dangerous if no cooldown exists.",
SuggestedAction = data.action,
})
break
end
end
if foundDangerous then
break
end
SafeYield()
end
if not foundDangerous then
table.insert(threats, {
Category = "ClickDetectorAbuse",
Severity = "LOW",
Confidence = "Medium",
Description = "ClickDetector Handler with Bytecode Detected",
Target = "Server Performance",
ExploitImpact = "Script handles ClickDetector events. No immediate dangerous patterns found, but manual review of cooldowns is recommended.",
Pattern = "MouseClick Handler",
Instance = script,
InstancePath = script:GetFullName(),
LineNumber = 1,
Evidence = string.format(
"Path: %s\nScript: %s (%s)\nReason: Script has bytecode and handles click events.",
cdPath,
script:GetFullName(),
scriptType
),
BenignReason = "Script might have safe internal cooldowns already.",
SuggestedAction = "Verify manually that click frequency is limited server-side.",
})
end
SafeYield()
end
return threats
end
function MaliciousDetector.Log(message: string)
if CONFIG.LogToOutput then
print("[MaliciousDetector] " .. message)
end
end
local function GroupThreats(threats: { Threat }): { GroupedThreat }
local grouped: { [string]: GroupedThreat } = {}
local orderedList: { GroupedThreat } = {}
for _, threat in ipairs(threats) do
if not grouped[threat.Category] then
local newGroup: GroupedThreat = {
Category = threat.Category,
Severity = threat.Severity,
Description = threat.Description,
Instances = {},
}
grouped[threat.Category] = newGroup
table.insert(orderedList, newGroup)
end
table.insert(grouped[threat.Category].Instances, threat)
end
return orderedList
end
local function FormatThreatsForClipboard(threats: { Threat }): string
local grouped = GroupThreats(threats)
local lines = { "=== Malicious Script Detector Report ===", "Total Threats: " .. #threats, "" }
for _, group in ipairs(grouped) do
table.insert(lines, string.format("[%s] %s (%d found)", group.Severity, group.Category, #group.Instances))
table.insert(lines, group.Description)
for _, t in ipairs(group.Instances) do
table.insert(
lines,
string.format(
" - Path: %s | Location: %s",
t.InstancePath or "N/A",
t.LineNumber and ("Line " .. t.LineNumber) or "Instance Level"
)
)
table.insert(lines, string.format(" Target: %s", t.Target or "N/A"))
table.insert(lines, string.format(" Exploiter Capability: %s", t.ExploitImpact or "N/A"))
table.insert(lines, string.format(" Confidence: %s", t.Confidence or "N/A"))
table.insert(lines, string.format(" Pattern: %s", t.Pattern or "N/A"))
table.insert(lines, string.format(" Evidence: %s", t.Evidence or t.Pattern))
if t.BenignReason then
table.insert(lines, string.format(" Benign Reason: %s", t.BenignReason))
end
table.insert(lines, string.format(" Suggested Action: %s", t.SuggestedAction or "N/A"))
end
table.insert(lines, "")
end
return table.concat(lines, "\n")
end
local function CreateThreatCard(groupedThreat: GroupedThreat, parent: Instance)
local count = #groupedThreat.Instances
local card = Instance.new("Frame")
card.Name = "ThreatCard_" .. groupedThreat.Category
card.Size = UDim2.new(1, 0, 0, 0)
card.AutomaticSize = Enum.AutomaticSize.Y
card.BackgroundColor3 = Color3.fromRGB(30, 30, 35)
card.BorderSizePixel = 0
card.Parent = parent
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = card
local stroke = Instance.new("UIStroke")
stroke.Thickness = 1
stroke.Transparency = 0.2
stroke.Parent = card
if groupedThreat.Severity == "CRITICAL" then
stroke.Color = Color3.fromRGB(220, 50, 50)
elseif groupedThreat.Severity == "HIGH" then
stroke.Color = Color3.fromRGB(220, 150, 50)
elseif groupedThreat.Severity == "MEDIUM" then
stroke.Color = Color3.fromRGB(220, 220, 50)
else
stroke.Color = Color3.fromRGB(150, 150, 150)
end
local padding = Instance.new("UIPadding")
padding.PaddingTop = UDim.new(0, 8)
padding.PaddingBottom = UDim.new(0, 8)
padding.PaddingLeft = UDim.new(0, 10)
padding.PaddingRight = UDim.new(0, 10)
padding.Parent = card
local layout = Instance.new("UIListLayout")
layout.Padding = UDim.new(0, 4)
layout.SortOrder = Enum.SortOrder.LayoutOrder
layout.Parent = card
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, 0, 0, 18)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = string.format("[%s] %s (%d found)", groupedThreat.Severity, groupedThreat.Category, count)
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextSize = 14
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.LayoutOrder = 1
titleLabel.Parent = card
local descLabel = Instance.new("TextLabel")
descLabel.Size = UDim2.new(1, 0, 0, 0)
descLabel.AutomaticSize = Enum.AutomaticSize.Y
descLabel.BackgroundTransparency = 1
descLabel.Text = groupedThreat.Description
descLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
descLabel.Font = Enum.Font.Gotham
descLabel.TextSize = 13
descLabel.TextWrapped = true
descLabel.TextXAlignment = Enum.TextXAlignment.Left
descLabel.TextYAlignment = Enum.TextYAlignment.Top
descLabel.LayoutOrder = 2
descLabel.Parent = card
for i, threat in ipairs(groupedThreat.Instances) do
local instanceLabel = Instance.new("TextLabel")
instanceLabel.Size = UDim2.new(1, 0, 0, 0)
instanceLabel.AutomaticSize = Enum.AutomaticSize.Y
instanceLabel.BackgroundTransparency = 1
instanceLabel.Text = string.format(
"• Path: %s\n Location: %s\n Target: %s\n Exploiter Capability: %s\n Confidence: %s\n Evidence: %s\n Benign Reason: %s\n Action: %s",
threat.InstancePath or "N/A",
threat.LineNumber and ("Line " .. threat.LineNumber) or "Instance Level",
threat.Target or "N/A",
threat.ExploitImpact or "N/A",
threat.Confidence or "N/A",
threat.Evidence or threat.Pattern,
threat.BenignReason or "None.",
threat.SuggestedAction or "Review manually."
)
instanceLabel.TextColor3 = Color3.fromRGB(180, 180, 180)
instanceLabel.Font = Enum.Font.Gotham
instanceLabel.TextSize = 12
instanceLabel.TextWrapped = true
instanceLabel.TextXAlignment = Enum.TextXAlignment.Left
instanceLabel.TextYAlignment = Enum.TextYAlignment.Top
instanceLabel.LayoutOrder = i + 2
local leftPad = Instance.new("UIPadding")
leftPad.PaddingLeft = UDim.new(0, 10)
leftPad.Parent = instanceLabel
instanceLabel.Parent = card
end
if groupedThreat.Severity == "CRITICAL" then
FX.PulseStroke(stroke)
end
FX.FadeInCard(card, #parent:GetChildren() * 0.08, stroke)
end
local function CreateScanUI()
local playerGui = Player:WaitForChild("PlayerGui")
local existingGui = playerGui:FindFirstChild("MaliciousDetectorUI")
if existingGui then
existingGui:Destroy()
end
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "MaliciousDetectorUI"
screenGui.ResetOnSpawn = false
screenGui.IgnoreGuiInset = true
screenGui.Parent = playerGui
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 500, 0, 0)
mainFrame.Position = UDim2.new(0.5, 0, 1, 300)
mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
mainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 30)
mainFrame.BorderSizePixel = 0
mainFrame.Parent = screenGui
local uiCorner = Instance.new("UICorner")
uiCorner.CornerRadius = UDim.new(0, 10)
uiCorner.Parent = mainFrame
ApplyRainbowStroke(mainFrame, 1.5, 0.4)
local dragBar = Instance.new("Frame")
dragBar.Name = "DragBar"
dragBar.Size = UDim2.new(1, 0, 0, 40)
dragBar.BackgroundTransparency = 1
dragBar.Parent = mainFrame
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -20, 0, 40)
titleLabel.Position = UDim2.new(0, 20, 0, 10)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "Malicious Script Detector"
titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
titleLabel.TextSize = 20
titleLabel.Font = Enum.Font.GothamBold
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.Parent = dragBar
local statusLabel = Instance.new("TextLabel")
statusLabel.Size = UDim2.new(1, -20, 0, 20)
statusLabel.Position = UDim2.new(0, 20, 0, 45)
statusLabel.BackgroundTransparency = 1
statusLabel.Text = "Initializing scan..."
statusLabel.TextColor3 = Color3.fromRGB(180, 180, 180)
statusLabel.TextSize = 14
statusLabel.Font = Enum.Font.Gotham
statusLabel.TextXAlignment = Enum.TextXAlignment.Left
statusLabel.Parent = mainFrame
local currentFileLabel = Instance.new("TextLabel")
currentFileLabel.Size = UDim2.new(1, -20, 0, 20)
currentFileLabel.Position = UDim2.new(0, 20, 0, 65)
currentFileLabel.BackgroundTransparency = 1
currentFileLabel.Text = "Gathering scripts..."
currentFileLabel.TextColor3 = Color3.fromRGB(140, 140, 140)
currentFileLabel.TextSize = 12
currentFileLabel.Font = Enum.Font.Gotham
currentFileLabel.TextXAlignment = Enum.TextXAlignment.Left
currentFileLabel.TextTruncate = Enum.TextTruncate.AtEnd
currentFileLabel.Parent = mainFrame
local barBackground = Instance.new("Frame")
barBackground.Size = UDim2.new(1, -40, 0, 15)
barBackground.Position = UDim2.new(0, 20, 0, 100)
barBackground.BackgroundColor3 = Color3.fromRGB(40, 40, 45)
barBackground.BorderSizePixel = 0
barBackground.Parent = mainFrame
local barCorner = Instance.new("UICorner")
barCorner.CornerRadius = UDim.new(1, 0)
barCorner.Parent = barBackground
local barFill = Instance.new("Frame")
barFill.Size = UDim2.new(0, 0, 1, 0)
barFill.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
barFill.BorderSizePixel = 0
barFill.Parent = barBackground
local fillCorner = Instance.new("UICorner")
fillCorner.CornerRadius = UDim.new(1, 0)
fillCorner.Parent = barFill
local statsLabel = Instance.new("TextLabel")
statsLabel.Size = UDim2.new(1, -40, 0, 20)
statsLabel.Position = UDim2.new(0, 20, 0, 125)
statsLabel.BackgroundTransparency = 1
statsLabel.Text = "Scanned: 0 | Skipped: 0 | Threats: 0"
statsLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
statsLabel.TextSize = 13
statsLabel.Font = Enum.Font.Gotham
statsLabel.TextXAlignment = Enum.TextXAlignment.Left
statsLabel.Parent = mainFrame
local reportList = Instance.new("ScrollingFrame")
reportList.Name = "ReportList"
reportList.Size = UDim2.new(1, -40, 1, -120)
reportList.Position = UDim2.new(0, 20, 0, 55)
reportList.BackgroundTransparency = 1
reportList.ScrollBarThickness = 4
reportList.Visible = false
reportList.Parent = mainFrame
local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 8)
listLayout.SortOrder = Enum.SortOrder.LayoutOrder
listLayout.Parent = reportList
listLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
reportList.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y + 10)
end)
local buttonHolder = Instance.new("Frame")
buttonHolder.Size = UDim2.new(1, -40, 0, 40)
buttonHolder.Position = UDim2.new(0, 20, 1, -50)
buttonHolder.BackgroundTransparency = 1
buttonHolder.Visible = false
buttonHolder.Parent = mainFrame
local showReportButton = Instance.new("TextButton")
showReportButton.Size = UDim2.new(0.5, -5, 1, 0)
showReportButton.Position = UDim2.new(0, 0, 0, 0)
showReportButton.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
showReportButton.Text = "Show Reports"
showReportButton.TextColor3 = Color3.fromRGB(255, 255, 255)
showReportButton.TextSize = 14
showReportButton.Font = Enum.Font.GothamBold
showReportButton.Parent = buttonHolder
local reportCorner = Instance.new("UICorner")
reportCorner.CornerRadius = UDim.new(0, 6)
reportCorner.Parent = showReportButton
local dismissButton = Instance.new("TextButton")
dismissButton.Size = UDim2.new(0.5, -5, 1, 0)
dismissButton.Position = UDim2.new(0.5, 5, 0, 0)
dismissButton.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
dismissButton.Text = "Dismiss"
dismissButton.TextColor3 = Color3.fromRGB(255, 255, 255)
dismissButton.TextSize = 14
dismissButton.Font = Enum.Font.GothamBold
dismissButton.Parent = buttonHolder
local dismissCorner = Instance.new("UICorner")
dismissCorner.CornerRadius = UDim.new(0, 6)
dismissCorner.Parent = dismissButton
-- Resize handle: invisible hit area + a small arc that follows the window's rounded corner
-- (window corner radius 10; arc radius ~6, concentric with it, like the iPadOS grabber)
local resizeHandle = Instance.new("Frame")
resizeHandle.Name = "ResizeHandle"
resizeHandle.Size = UDim2.fromOffset(24, 24)
resizeHandle.AnchorPoint = Vector2.new(1, 1)
resizeHandle.Position = UDim2.fromScale(1, 1)
resizeHandle.BackgroundTransparency = 1
resizeHandle.Parent = mainFrame
local arcClip = Instance.new("Frame")
arcClip.Name = "ArcClip"
arcClip.AnchorPoint = Vector2.new(1, 1)
arcClip.Position = UDim2.new(1, -2, 1, -2)
arcClip.Size = UDim2.fromOffset(8, 8)
arcClip.BackgroundTransparency = 1
arcClip.ClipsDescendants = true
arcClip.Parent = resizeHandle
local arcRing = Instance.new("Frame")
arcRing.Position = UDim2.fromOffset(-5, -5)
arcRing.Size = UDim2.fromOffset(10, 10)
arcRing.BackgroundTransparency = 1
arcRing.Parent = arcClip
local arcCorner = Instance.new("UICorner")
arcCorner.CornerRadius = UDim.new(1, 0)
arcCorner.Parent = arcRing
local arcStroke = Instance.new("UIStroke")
arcStroke.Color = Color3.fromRGB(150, 150, 158)
arcStroke.Thickness = 2
arcStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
arcStroke.Parent = arcRing
local dragging = false
local dragInput, mousePos, framePos
dragBar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
mousePos = input.Position
framePos = mainFrame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
dragBar.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if input == dragInput and dragging then
local delta = input.Position - mousePos
mainFrame.Position = UDim2.new(framePos.X.Scale, framePos.X.Offset + delta.X, framePos.Y.Scale, framePos.Y.Offset + delta.Y)
end
end)
-- The window is anchored at its center, so changing Size alone moves the corner by only half the
-- change. Resize from the top-left instead: shift Position by half the size change, so the
-- bottom-right corner stays exactly under the cursor.
local resizing = false
local resizeStartMousePos = Vector2.zero
local resizeStartSize = Vector2.zero
local resizeStartPos = mainFrame.Position
resizeHandle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
resizing = true
resizeStartMousePos = UserInputService:GetMouseLocation()
resizeStartSize = mainFrame.AbsoluteSize
resizeStartPos = mainFrame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
resizing = false
end
end)
end
end)
UserInputService.InputChanged:Connect(function(input)
if resizing and input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = UserInputService:GetMouseLocation() - resizeStartMousePos
local newWidth = math.clamp(resizeStartSize.X + delta.X, 400, 1200)
local newHeight = math.clamp(resizeStartSize.Y + delta.Y, 250, 800)
mainFrame.Size = UDim2.fromOffset(newWidth, newHeight)
mainFrame.Position = UDim2.new(
resizeStartPos.X.Scale,
resizeStartPos.X.Offset + (newWidth - resizeStartSize.X) / 2,
resizeStartPos.Y.Scale,
resizeStartPos.Y.Offset + (newHeight - resizeStartSize.Y) / 2
)
end
end)
TweenService:Create(
mainFrame,
TweenInfo.new(0.6, Enum.EasingStyle.Quint, Enum.EasingDirection.Out),
{ Position = UDim2.new(0.5, 0, 0.5, 0), Size = UDim2.new(0, 500, 0, 250) }
):Play()
-- Three result buttons: Reports | Node Map | Dismiss
showReportButton.Size = UDim2.new(1 / 3, -6, 1, 0)
local mapButton = showReportButton:Clone()
mapButton.Name = "MapButton"
mapButton.Text = "Node Map"
mapButton.BackgroundColor3 = Color3.fromRGB(0, 120, 190)
mapButton.Position = UDim2.new(1 / 3, 3, 0, 0)
mapButton.Parent = buttonHolder
dismissButton.Size = UDim2.new(1 / 3, -6, 1, 0)
dismissButton.Position = UDim2.new(2 / 3, 6, 0, 0)
FX.Hover(showReportButton)
FX.Hover(mapButton)
FX.Hover(dismissButton)
FX.GlowBar(barFill)
return {
ScreenGui = screenGui,
MainFrame = mainFrame,
StatusLabel = statusLabel,
CurrentFileLabel = currentFileLabel,
BarBackground = barBackground,
BarFill = barFill,
StatsLabel = statsLabel,
ReportList = reportList,
ButtonHolder = buttonHolder,
ShowReportButton = showReportButton,
MapButton = mapButton,
DismissButton = dismissButton,
}
end
-- Top-level container an instance lives in: "Workspace", "CoreGui", "gethui()", "Nil Instances", ...
local function GetRootName(instance: Instance?): string
if not instance then
return "Environment"
end
local ok, name = pcall(function(): string
local cur: Instance = instance
while cur.Parent and cur.Parent ~= game do
cur = cur.Parent :: Instance
end
if cur.Parent == game then
return cur.Name
end
return "Nil Instances"
end)
return if ok then name else "Unknown"
end
type ScanResult = {
Threats: { Threat },
Scanned: number,
Total: number,
Skipped: number,
RootNames: { string },
}
-- ============================================================
-- SHARED UI HELPERS
-- ============================================================
local UI = {
Panel = Color3.fromRGB(25, 25, 30),
Row = Color3.fromRGB(36, 36, 44),
RowHover = Color3.fromRGB(46, 46, 56),
Accent = Color3.fromRGB(0, 170, 255),
Text = Color3.fromRGB(235, 235, 240),
Dim = Color3.fromRGB(140, 140, 150),
Good = Color3.fromRGB(60, 200, 110),
Warn = Color3.fromRGB(230, 170, 60),
}
local SEVERITY_ORDER = { CRITICAL = 4, HIGH = 3, MEDIUM = 2, LOW = 1 }
local SEVERITY_COLORS = {
CRITICAL = Color3.fromRGB(220, 50, 50),
HIGH = Color3.fromRGB(220, 150, 50),
MEDIUM = Color3.fromRGB(220, 220, 50),
LOW = Color3.fromRGB(150, 150, 150),
}
local SEVERITY_HEX = { CRITICAL = "#DC3232", HIGH = "#DC9632", MEDIUM = "#DCDC32", LOW = "#969696" }
local function Corner(parent: Instance, radius: number)
local c = Instance.new("UICorner")
c.CornerRadius = UDim.new(0, radius)
c.Parent = parent
end
local function Label(parent: Instance, text: string, size: number, font: Enum.Font, color: Color3): TextLabel
local l = Instance.new("TextLabel")
l.BackgroundTransparency = 1
l.Text = text
l.TextSize = size
l.Font = font
l.TextColor3 = color
l.TextXAlignment = Enum.TextXAlignment.Left
l.Parent = parent
return l
end
local function MakeDraggable(handle: GuiObject, frame: GuiObject)
local dragging = false
local dragStart: Vector3? = nil
local startPos: UDim2? = nil
handle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
local conn = UserInputService.InputChanged:Connect(function(input)
if
dragging
and dragStart
and startPos
and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch)
then
local delta = input.Position - dragStart
frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end
end)
frame.Destroying:Connect(function()
conn:Disconnect()
end)
end
local function EscapeRich(s: string): string
local out = s:gsub("&", "&"):gsub("<", "<"):gsub(">", ">"):gsub('"', """)
return out
end
-- ============================================================
-- NODE MAP WINDOW (game -> containers -> flagged instances)
-- ============================================================
type MapNode = {
Key: string,
Label: string,
Threats: { Threat },
Severity: string,
}
type MapRoot = { Name: string, Nodes: { MapNode }, ByKey: { [string]: MapNode }, Severity: string? }
local function BuildMapData(result: ScanResult): { MapRoot }
local order: { MapRoot } = {}
local byName: { [string]: MapRoot } = {}
local function getRoot(name: string): MapRoot
local r = byName[name]
if not r then
r = { Name = name, Nodes = {}, ByKey = {}, Severity = nil }
byName[name] = r
table.insert(order, r)
end
return r
end
for _, name in ipairs(result.RootNames) do
getRoot(name)
end
for _, t in ipairs(result.Threats) do
local r = getRoot(GetRootName(t.Instance))
local key = t.InstancePath or t.Category
local node = r.ByKey[key]
if not node then
local nodeLabel = if t.Instance then t.Instance.Name else (t.InstancePath or t.Category)
node = { Key = key, Label = nodeLabel, Threats = {}, Severity = t.Severity }
r.ByKey[key] = node
table.insert(r.Nodes, node)
end
local n = node :: MapNode
table.insert(n.Threats, t)
if (SEVERITY_ORDER[t.Severity] or 0) > (SEVERITY_ORDER[n.Severity] or 0) then
n.Severity = t.Severity
end
if not r.Severity or (SEVERITY_ORDER[t.Severity] or 0) > (SEVERITY_ORDER[r.Severity :: string] or 0) then
r.Severity = t.Severity
end
end
for _, r in ipairs(order) do
table.sort(r.Nodes, function(a, b)
local sa, sb = SEVERITY_ORDER[a.Severity] or 0, SEVERITY_ORDER[b.Severity] or 0
if sa ~= sb then
return sa > sb
end
return a.Label < b.Label
end)
end
return order
end
local function DescribeNode(node: MapNode): string
local first = node.Threats[1]
local parts = {
string.format('%s', EscapeRich(node.Label)),
string.format('%s', EscapeRich(first.InstancePath or node.Key)),
string.format(
'%d finding%s | worst: %s',
#node.Threats,
if #node.Threats == 1 then "" else "s",
SEVERITY_HEX[node.Severity] or "#FFFFFF",
node.Severity
),
}
for _, t in ipairs(node.Threats) do
table.insert(parts, "")
table.insert(
parts,
string.format(
'[%s] %s (%s confidence)',
SEVERITY_HEX[t.Severity] or "#FFFFFF",
t.Severity,
EscapeRich(t.Category),
EscapeRich(t.Confidence or "?")
)
)
table.insert(parts, EscapeRich(t.Description))
local fields = {
{ "Location", if t.LineNumber then "Line " .. t.LineNumber else "Instance Level" },
{ "Target", t.Target or "N/A" },
{ "Exploiter Capability", t.ExploitImpact or "N/A" },
{ "Pattern", t.Pattern or "N/A" },
{ "Evidence", t.Evidence or "N/A" },
{ "Benign Reason", t.BenignReason or "None." },
{ "Action", t.SuggestedAction or "Review manually." },
}
for _, f in ipairs(fields) do
table.insert(parts, string.format('%s: %s', f[1], EscapeRich(tostring(f[2]))))
end
end
return table.concat(parts, "\n")
end
local function DescribeRoot(root: MapRoot): string
local counts = { CRITICAL = 0, HIGH = 0, MEDIUM = 0, LOW = 0 }
local findings = 0
for _, n in ipairs(root.Nodes) do
for _, t in ipairs(n.Threats) do
counts[t.Severity] = (counts[t.Severity] or 0) + 1
findings += 1
end
end
local parts = {
string.format('%s', EscapeRich(root.Name)),
string.format("%d flagged instance%s | %d findings", #root.Nodes, if #root.Nodes == 1 then "" else "s", findings),
"",
}
if findings == 0 then
table.insert(parts, 'Clean: nothing flagged in this container.')
else
for _, sev in ipairs({ "CRITICAL", "HIGH", "MEDIUM", "LOW" }) do
table.insert(parts, string.format('%s: %d', SEVERITY_HEX[sev], sev, counts[sev]))
end
table.insert(parts, "")
table.insert(parts, "Hover a node on the right for its details.")
end
return table.concat(parts, "\n")
end
local function OpenNodeMap(screenGui: ScreenGui, result: ScanResult)
local existing = screenGui:FindFirstChild("NodeMapWindow")
if existing then
existing:Destroy()
end
local WIN_W, WIN_H = 820, 520
local window = Instance.new("Frame")
window.Name = "NodeMapWindow"
window.AnchorPoint = Vector2.new(0.5, 0.5)
window.Position = UDim2.new(0.5, 40, 0.5, 30)
window.Size = UDim2.fromOffset(WIN_W, WIN_H)
window.BackgroundColor3 = UI.Panel
window.BorderSizePixel = 0
window.ZIndex = 10
window.Parent = screenGui
Corner(window, 12)
ApplyRainbowStroke(window, 1.5, 0.4)
local winScale = Instance.new("UIScale")
winScale.Scale = 0.85
winScale.Parent = window
tween(winScale, TweenInfo.new(0.35, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
local titleBar = Instance.new("Frame")
titleBar.BackgroundTransparency = 1
titleBar.Size = UDim2.new(1, 0, 0, 40)
titleBar.ZIndex = 11
titleBar.Parent = window
local title = Label(titleBar, "Threat Map", 18, Enum.Font.GothamBold, UI.Text)
title.Position = UDim2.fromOffset(16, 0)
title.Size = UDim2.new(0.5, 0, 1, 0)
title.ZIndex = 11
local subtitle =
Label(titleBar, string.format("%d findings | %d containers", #result.Threats, #result.RootNames), 12, Enum.Font.Gotham, UI.Dim)
subtitle.Position = UDim2.fromOffset(130, 2)
subtitle.Size = UDim2.new(0.5, 0, 1, 0)
subtitle.ZIndex = 11
MakeDraggable(titleBar, window)
local closeBtn = Instance.new("TextButton")
closeBtn.AnchorPoint = Vector2.new(1, 0.5)
closeBtn.Position = UDim2.new(1, -10, 0, 20)
closeBtn.Size = UDim2.fromOffset(28, 28)
closeBtn.BackgroundColor3 = UI.Row
closeBtn.AutoButtonColor = false
closeBtn.Text = "X"
closeBtn.Font = Enum.Font.GothamBold
closeBtn.TextSize = 14
closeBtn.TextColor3 = UI.Text
closeBtn.ZIndex = 12
closeBtn.Parent = window
Corner(closeBtn, 14)
FX.Hover(closeBtn)
closeBtn.MouseEnter:Connect(function()
tween(closeBtn, TweenInfo.new(0.12), { BackgroundColor3 = Color3.fromRGB(200, 50, 50) })
end)
closeBtn.MouseLeave:Connect(function()
tween(closeBtn, TweenInfo.new(0.12), { BackgroundColor3 = UI.Row })
end)
closeBtn.MouseButton1Click:Connect(function()
FX.Close(window, function()
window:Destroy()
end)
end)
local legend = Label(window, "", 12, Enum.Font.Gotham, UI.Dim)
legend.RichText = true
legend.Position = UDim2.new(0, 16, 1, -28)
legend.Size = UDim2.new(1, -32, 0, 20)
legend.ZIndex = 11
legend.Text = string.format(
'CRITICAL HIGH MEDIUM LOW CLEAN Hover a node for details | click to lock | drag empty space to pan',
SEVERITY_HEX.CRITICAL,
SEVERITY_HEX.HIGH,
SEVERITY_HEX.MEDIUM,
SEVERITY_HEX.LOW
)
local canvas = Instance.new("ScrollingFrame")
canvas.Name = "Canvas"
canvas.Position = UDim2.fromOffset(12, 44)
canvas.Size = UDim2.new(1, -24, 1, -80)
canvas.BackgroundColor3 = Color3.fromRGB(18, 18, 22)
canvas.BorderSizePixel = 0
canvas.ScrollingDirection = Enum.ScrollingDirection.XY
canvas.ScrollBarThickness = 6
canvas.ZIndex = 11
canvas.Parent = window
Corner(canvas, 8)
-- Layout: three columns, elbow connectors (no rotated frames, so clipping stays correct)
local GAME_X, GAME_W = 20, 110
local ROOT_X, ROOT_W = 190, 170
local LEAF_X, LEAF_W = 430, 250
local NODE_H, LEAF_GAP, ROOT_GAP = 28, 8, 22
local roots = BuildMapData(result)
local y = 20
type Placed = { Root: MapRoot, CenterY: number, Leaves: { { Node: MapNode, Y: number } } }
local placed: { Placed } = {}
for _, r in ipairs(roots) do
local count = math.max(1, #r.Nodes)
local blockH = count * NODE_H + (count - 1) * LEAF_GAP
local entry: Placed = { Root = r, CenterY = y + blockH / 2, Leaves = {} }
for i, n in ipairs(r.Nodes) do
table.insert(entry.Leaves, { Node = n, Y = y + (i - 1) * (NODE_H + LEAF_GAP) + NODE_H / 2 })
end
table.insert(placed, entry)
y += blockH + ROOT_GAP
end
local contentH = math.max(y, 200)
local gameCenterY = if #placed > 0 then (placed[1].CenterY + placed[#placed].CenterY) / 2 else contentH / 2
canvas.CanvasSize = UDim2.fromOffset(LEAF_X + LEAF_W + 30, contentH + 10)
-- Pan surface: drag empty space to scroll
local pan = Instance.new("Frame")
pan.BackgroundTransparency = 1
pan.Size = UDim2.fromOffset(LEAF_X + LEAF_W + 30, contentH + 10)
pan.ZIndex = 11
pan.Parent = canvas
local panning = false
local panStart: Vector3? = nil
local panCanvasStart = Vector2.zero
pan.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
panning = true
panStart = input.Position
panCanvasStart = canvas.CanvasPosition
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
panning = false
end
end)
end
end)
local panConn = UserInputService.InputChanged:Connect(function(input)
if panning and panStart and input.UserInputType == Enum.UserInputType.MouseMovement then
local d = input.Position - panStart
canvas.CanvasPosition = panCanvasStart - Vector2.new(d.X, d.Y)
end
end)
window.Destroying:Connect(function()
panConn:Disconnect()
end)
local lineIndex = 0
local function segment(x: number, yPos: number, w: number, h: number, color: Color3)
lineIndex += 1
local f = Instance.new("Frame")
f.Position = UDim2.fromOffset(x, yPos)
f.Size = UDim2.fromOffset(math.max(w, 2), math.max(h, 2))
f.BackgroundColor3 = color
f.BackgroundTransparency = 1
f.BorderSizePixel = 0
f.ZIndex = 12
f.Parent = canvas
task.delay(math.min(lineIndex * 0.004, 0.5), function()
if f.Parent then
tween(f, TweenInfo.new(0.3), { BackgroundTransparency = 0.45 })
end
end)
end
local function elbow(x1: number, y1: number, x2: number, y2: number, color: Color3)
local midX = math.floor((x1 + x2) / 2)
segment(x1, y1 - 1, midX - x1, 2, color)
segment(midX - 1, math.min(y1, y2) - 1, 2, math.abs(y2 - y1) + 2, color)
segment(midX, y2 - 1, x2 - midX, 2, color)
end
-- Tooltip (child of the window, so it isn't clipped by the canvas)
local TIP_W, TIP_MAX_H = 360, 300
local tip = Instance.new("Frame")
tip.Name = "Tooltip"
tip.Size = UDim2.fromOffset(TIP_W, 120)
tip.BackgroundColor3 = Color3.fromRGB(14, 14, 18)
tip.BackgroundTransparency = 0.03
tip.Visible = false
tip.ZIndex = 30
tip.Parent = window
Corner(tip, 8)
local tipStroke = Instance.new("UIStroke")
tipStroke.Thickness = 1.5
tipStroke.Color = UI.Accent
tipStroke.Parent = tip
local tipHeader = Label(tip, "", 11, Enum.Font.GothamBold, UI.Dim)
tipHeader.Position = UDim2.fromOffset(10, 4)
tipHeader.Size = UDim2.new(1, -20, 0, 18)
tipHeader.ZIndex = 31
local tipBody = Instance.new("ScrollingFrame")
tipBody.BackgroundTransparency = 1
tipBody.BorderSizePixel = 0
tipBody.Position = UDim2.fromOffset(10, 24)
tipBody.Size = UDim2.new(1, -14, 1, -30)
tipBody.CanvasSize = UDim2.new()
tipBody.AutomaticCanvasSize = Enum.AutomaticSize.Y
tipBody.ScrollBarThickness = 4
tipBody.ZIndex = 31
tipBody.Parent = tip
local tipText = Label(tipBody, "", 12, Enum.Font.Gotham, UI.Text)
tipText.RichText = true
tipText.TextWrapped = true
tipText.TextYAlignment = Enum.TextYAlignment.Top
tipText.Size = UDim2.new(1, -8, 0, 0)
tipText.AutomaticSize = Enum.AutomaticSize.Y
tipText.ZIndex = 31
tipText:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
tip.Size = UDim2.fromOffset(TIP_W, math.min(TIP_MAX_H, tipText.AbsoluteSize.Y + 36))
end)
local hovered: GuiObject? = nil
local locked: GuiObject? = nil
local shownFor: GuiObject? = nil
local nodeText: { [GuiObject]: string } = {}
local nodeStroke: { [GuiObject]: UIStroke } = {}
local function placeTip()
local anchor = shownFor
if not anchor then
return
end
local rel = anchor.AbsolutePosition - window.AbsolutePosition
local winSize = window.AbsoluteSize
local tipSize = tip.AbsoluteSize
local x = rel.X + anchor.AbsoluteSize.X + 10
if x + tipSize.X > winSize.X - 8 then
x = rel.X - tipSize.X - 10
end
x = math.clamp(x, 8, math.max(8, winSize.X - tipSize.X - 8))
local yPos = math.clamp(rel.Y - 6, 44, math.max(44, winSize.Y - tipSize.Y - 8))
tip.Position = UDim2.fromOffset(x, yPos)
end
local function refreshHeader()
if locked then
tipHeader.Text = "LOCKED | scroll here | click the node again to unlock"
tipHeader.TextColor3 = UI.Accent
tipStroke.Thickness = 2.5
else
tipHeader.Text = "Click the node to lock this panel"
tipHeader.TextColor3 = UI.Dim
tipStroke.Thickness = 1.5
end
end
local function showFor(node: GuiObject)
shownFor = node
tipText.Text = nodeText[node] or ""
tipStroke.Color = (nodeStroke[node] and nodeStroke[node].Color) or UI.Accent
tipBody.CanvasPosition = Vector2.zero
refreshHeader()
if not tip.Visible then
tip.Visible = true
tip.BackgroundTransparency = 1
tween(tip, TweenInfo.new(0.12), { BackgroundTransparency = 0.03 })
end
task.defer(placeTip)
placeTip()
end
local function hideTip()
shownFor = nil
tip.Visible = false
end
canvas:GetPropertyChangedSignal("CanvasPosition"):Connect(placeTip)
window:GetPropertyChangedSignal("AbsolutePosition"):Connect(placeTip)
local nodeIndex = 0
local function makeNode(x: number, centerY: number, w: number, text: string, color: Color3, badge: string?, column: number): TextButton
nodeIndex += 1
local b = Instance.new("TextButton")
b.AutoButtonColor = false
b.Text = ""
b.Position = UDim2.fromOffset(x, centerY - NODE_H / 2)
b.Size = UDim2.fromOffset(w, NODE_H)
b.BackgroundColor3 = Color3.fromRGB(30, 30, 36)
b.ZIndex = 13
b.Parent = canvas
Corner(b, 7)
local s = Instance.new("UIStroke")
s.Color = color
s.Thickness = 1.5
s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
s.Parent = b
nodeStroke[b] = s
local dot = Instance.new("Frame")
dot.AnchorPoint = Vector2.new(0, 0.5)
dot.Position = UDim2.new(0, 9, 0.5, 0)
dot.Size = UDim2.fromOffset(8, 8)
dot.BackgroundColor3 = color
dot.ZIndex = 14
dot.Parent = b
Corner(dot, 4)
local l = Label(b, text, 12, Enum.Font.GothamMedium, UI.Text)
l.Position = UDim2.fromOffset(24, 0)
l.Size = UDim2.new(1, if badge then -60 else -30, 1, 0)
l.TextTruncate = Enum.TextTruncate.AtEnd
l.ZIndex = 14
if badge then
local bl = Label(b, badge, 11, Enum.Font.GothamBold, color)
bl.AnchorPoint = Vector2.new(1, 0)
bl.Position = UDim2.new(1, -8, 0, 0)
bl.Size = UDim2.fromOffset(34, NODE_H)
bl.TextXAlignment = Enum.TextXAlignment.Right
bl.ZIndex = 14
end
-- staggered pop-in, column by column
local scale = Instance.new("UIScale")
scale.Scale = 0
scale.Parent = b
task.delay(column * 0.12 + math.min(nodeIndex * 0.015, 0.6), function()
if b.Parent then
tween(scale, TweenInfo.new(0.35, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
end
end)
b.MouseEnter:Connect(function()
hovered = b
tween(s, TweenInfo.new(0.12), { Thickness = 3 })
tween(b, TweenInfo.new(0.12), { BackgroundColor3 = Color3.fromRGB(42, 42, 50) })
if not locked then
showFor(b)
end
end)
b.MouseLeave:Connect(function()
if hovered == b then
hovered = nil
end
if locked ~= b then
tween(s, TweenInfo.new(0.12), { Thickness = 1.5 })
end
tween(b, TweenInfo.new(0.12), { BackgroundColor3 = Color3.fromRGB(30, 30, 36) })
if not locked then
hideTip()
end
end)
b.MouseButton1Click:Connect(function()
if locked == b then
-- unlock; the panel goes away once the mouse leaves the node
locked = nil
refreshHeader()
if hovered ~= b then
tween(s, TweenInfo.new(0.12), { Thickness = 1.5 })
hideTip()
end
else
local previous = locked
locked = b
if previous and nodeStroke[previous] then
tween(nodeStroke[previous], TweenInfo.new(0.12), { Thickness = 1.5 })
end
tween(s, TweenInfo.new(0.12), { Thickness = 3 })
showFor(b)
end
end)
return b
end
-- game node
local totalFindings = #result.Threats
local gameNode = makeNode(GAME_X, gameCenterY, GAME_W, "game", UI.Accent, nil, 0)
nodeText[gameNode] = table.concat({
'game',
string.format("Containers scanned: %d", #result.RootNames),
string.format("Scripts scanned: %d (no source: %d)", result.Scanned, result.Skipped),
string.format("Findings: %d", totalFindings),
"",
'' .. EscapeRich(table.concat(result.RootNames, ", ")) .. "",
}, "\n")
for _, p in ipairs(placed) do
local r = p.Root
local rootColor = if r.Severity then SEVERITY_COLORS[r.Severity] else UI.Good
local badge = if #r.Nodes > 0 then tostring(#r.Nodes) else nil
local rootNode = makeNode(ROOT_X, p.CenterY, ROOT_W, r.Name, rootColor, badge, 1)
nodeText[rootNode] = DescribeRoot(r)
elbow(GAME_X + GAME_W, gameCenterY, ROOT_X, p.CenterY, rootColor)
for _, leaf in ipairs(p.Leaves) do
local n = leaf.Node
local color = SEVERITY_COLORS[n.Severity] or UI.Dim
local leafBadge = if #n.Threats > 1 then "x" .. #n.Threats else nil
local leafNode = makeNode(LEAF_X, leaf.Y, LEAF_W, n.Label, color, leafBadge, 2)
nodeText[leafNode] = DescribeNode(n)
elbow(ROOT_X + ROOT_W, p.CenterY, LEAF_X, leaf.Y, color)
end
end
end
function MaliciousDetector.Scan()
local ui = CreateScanUI()
local allThreats: { Threat } = {}
local sweep, sweepTween = FX.CreateSweep(ui.MainFrame)
local lastThreatCount = 0
MaliciousDetector.Log("Starting deep security scan...")
if Decompiler then
MaliciousDetector.Log("Decompiler support detected. Bytecode scripts will be analyzed.")
else
MaliciousDetector.Log("No decompiler detected. Compiled bytecode scripts will be skipped.")
end
ui.StatusLabel.Text = "Gathering all scripts..."
local servicesToScan = {
game:GetService("Workspace"),
game:GetService("ReplicatedStorage"),
game:GetService("ReplicatedFirst"),
game:GetService("StarterGui"),
game:GetService("StarterPack"),
game:GetService("StarterPlayer"),
game:GetService("Lighting"),
game:GetService("Teams"),
}
local scriptsToScan: { LuaSourceContainer } = {}
for _, service in ipairs(servicesToScan) do
for _, descendant in ipairs(service:GetDescendants()) do
if descendant:IsA("LuaSourceContainer") and not IsWhitelisted(descendant) then
table.insert(scriptsToScan, descendant)
end
SafeYield()
end
end
local totalScripts = #scriptsToScan
local scannedCount = 0
local skippedCount = 0
local threatCount = 0
ui.StatusLabel.Text = "Scanning " .. totalScripts .. " scripts..."
local lastUIUpdate = os.clock()
local lastFileLabelUpdate = 0
for i, script in ipairs(scriptsToScan) do
if not ui.ScreenGui or not ui.ScreenGui.Parent then
return allThreats
end
scannedCount += 1
local instanceThreats: { Threat } = {}
local isServerScript = script:IsA("Script") and not script:IsA("LocalScript")
-- Show the path before reading/decompiling, so a slow script is visible on screen
if os.clock() - lastFileLabelUpdate > 0.1 then
ui.CurrentFileLabel.Text = "File: " .. script:GetFullName()
lastFileLabelUpdate = os.clock()
end
local source = GetScriptSource(script)
if isServerScript and not source then
skippedCount += 1
if HasSuspiciousName(script) then
table.insert(instanceThreats, {
Category = "SuspiciousName",
Severity = "LOW",
Confidence = "Low",
Description = "Server script with suspicious name (Source locked).",
Pattern = script.Name,
Target = "Script Identity",
ExploitImpact = "Disguise malicious scripts.",
LineNumber = 1,
Evidence = script.Name,
BenignReason = "Source is locked.",
SuggestedAction = "Check the script manually in Studio.",
})
end
else
instanceThreats = AnalyzeScript(script, source)
end
for _, threat in ipairs(instanceThreats) do
threat.Instance = script
threat.InstancePath = script:GetFullName()
table.insert(allThreats, threat)
threatCount += 1
end
if os.clock() - lastUIUpdate > 0.1 then
tween(
ui.BarFill,
TweenInfo.new(0.2, Enum.EasingStyle.Quad),
{ Size = UDim2.new(totalScripts > 0 and (scannedCount / totalScripts) or 0, 0, 1, 0) }
)
ui.StatsLabel.Text =
string.format("Scanned: %d/%d | Skipped: %d | Threats: %d", scannedCount, totalScripts, skippedCount, threatCount)
if threatCount ~= lastThreatCount then
lastThreatCount = threatCount
FX.Pop(ui.StatsLabel)
end
lastUIUpdate = os.clock()
end
SafeYield()
end
ui.CurrentFileLabel.Text = "Checking physics configurations..."
local physicsThreats = CheckPlayerCollisions()
for _, threat in ipairs(physicsThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.CurrentFileLabel.Text = "Checking remote events..."
local remoteThreats = CheckSuspiciousRemotes()
for _, threat in ipairs(remoteThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.CurrentFileLabel.Text = "Checking workspace vulnerabilities..."
local partThreats = CheckUnanchoredParts()
for _, threat in ipairs(partThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.CurrentFileLabel.Text = "Checking for self-replicating scripts..."
local replThreats = CheckFreeModelReplication()
for _, threat in ipairs(replThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.CurrentFileLabel.Text = "Checking trust boundaries..."
local exposedThreats = CheckExposedServerScripts()
for _, threat in ipairs(exposedThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.CurrentFileLabel.Text = "Checking for ClickDetector abuse..."
local clickThreats = CheckClickDetectors()
for _, threat in ipairs(clickThreats) do
table.insert(allThreats, threat)
threatCount += 1
end
ui.StatsLabel.Text = string.format("Scanned: %d/%d | Skipped: %d | Threats: %d", scannedCount, totalScripts, skippedCount, threatCount)
ui.CurrentFileLabel.Text = "Scan complete."
sweepTween:Cancel()
sweep:Destroy()
tween(ui.BarFill, TweenInfo.new(0.3), { Size = UDim2.new(1, 0, 1, 0) })
MaliciousDetector.Log("Scan complete. Found " .. #allThreats .. " potential threats.")
local hasCritical = false
for _, threat in ipairs(allThreats) do
if threat.Severity == "CRITICAL" then
hasCritical = true
break
end
end
local rootNames: { string } = {}
for _, service in ipairs(servicesToScan) do
table.insert(rootNames, service.Name)
end
local result: ScanResult = {
Threats = allThreats,
Scanned = scannedCount,
Total = totalScripts,
Skipped = skippedCount,
RootNames = rootNames,
}
if threatCount > 0 then
FX.Typewrite(ui.StatusLabel, threatCount .. " threats detected!", 0.04)
local alertColor = hasCritical and Color3.fromRGB(220, 50, 50) or Color3.fromRGB(220, 150, 50)
FX.Ring(ui.MainFrame, alertColor)
if hasCritical then
FX.Shake(ui.MainFrame, 6, 0.4)
end
ui.BarFill.BackgroundColor3 = alertColor
ui.ButtonHolder.Visible = true
local reportsShown = false
ui.ShowReportButton.MouseButton1Click:Connect(function()
if not reportsShown then
reportsShown = true
ui.StatusLabel.Visible = false
ui.CurrentFileLabel.Visible = false
ui.BarBackground.Visible = false
ui.StatsLabel.Visible = false
ui.ReportList.Visible = true
TweenService:Create(
ui.MainFrame,
TweenInfo.new(0.4, Enum.EasingStyle.Quint, Enum.EasingDirection.Out),
{ Size = UDim2.new(0, 600, 0, 450) }
):Play()
local groupedThreats = GroupThreats(allThreats)
for _, groupedThreat in ipairs(groupedThreats) do
CreateThreatCard(groupedThreat, ui.ReportList)
end
if ClipboardFunc then
ui.ShowReportButton.Text = "Copy Reports"
ui.ShowReportButton.BackgroundColor3 = Color3.fromRGB(40, 80, 120)
else
ui.ShowReportButton.Text = "Reports Shown"
ui.ShowReportButton.BackgroundColor3 = Color3.fromRGB(30, 100, 30)
end
else
if ClipboardFunc then
local reportText = FormatThreatsForClipboard(allThreats)
local success = pcall(ClipboardFunc, reportText)
ui.ShowReportButton.Text = success and "Copied!" or "Copy Failed"
task.delay(2, function()
if ui.ScreenGui and ui.ScreenGui.Parent then
ui.ShowReportButton.Text = "Copy Reports"
end
end)
end
end
end)
ui.MapButton.MouseButton1Click:Connect(function()
OpenNodeMap(ui.ScreenGui, result)
end)
ui.DismissButton.MouseButton1Click:Connect(function()
local mapWindow = ui.ScreenGui:FindFirstChild("NodeMapWindow")
if mapWindow and mapWindow:IsA("GuiObject") then
FX.Close(mapWindow)
end
FX.Close(ui.MainFrame, function()
ui.ScreenGui:Destroy()
end)
end)
else
FX.Typewrite(ui.StatusLabel, "No threats detected. Game is clean!", 0.03)
FX.Ring(ui.MainFrame, Color3.fromRGB(50, 200, 50))
ui.BarFill.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
task.delay(3, function()
if ui.ScreenGui and ui.ScreenGui.Parent then
FX.Close(ui.MainFrame, function()
ui.ScreenGui:Destroy()
end)
end
end)
end
return allThreats
end
local function Initialize()
MaliciousDetector.Log("Malicious Script Detector initialized.")
if not game:IsLoaded() then
game.Loaded:Wait()
end
task.wait(1)
-- Intro starts right away; the notification's button skips it
local skipIntro = false
local skipCallback = Instance.new("BindableFunction")
skipCallback.OnInvoke = function()
skipIntro = true
end
pcall(function()
StarterGui:SetCore("SendNotification", {
Title = "Malicious Script Detector",
Text = "Booting scanner...",
Duration = INTRO_DURATION,
Callback = skipCallback,
Button1 = "Skip Intro",
})
end)
PlayIntro(function()
return skipIntro
end)
skipCallback:Destroy()
MaliciousDetector.Scan()
end
Initialize()