return function(H)local o=H.Server local f=H.Service local Z,m,L,V,j,r,i,M,h,Y local function S()Z=o.Functions m=o.Admin L=o.Anti V=o.Core j=o.HTTP r=o.Logs i=o.Remote M=o.Process h=o.Variables Y=o.Settings r:AddLog("\083\099\114\105\112\116","\065\110\116\105\069\120\112\108\111\105\116 \077\111\100\117\108\101 \073\110\105\116\105\097\108\105\122\101\100")end o.Anti={Init=S,SpoofCheckCache={},RemovePlayer=function(H,o)o=o or"\078\111 \082\101\097\115\111\110 \071\105\118\101\110"pcall(function()(f.UnWrap(H)):Kick(tostring(o))end)wait(1)pcall(H.Destroy,H)pcall(f.Delete,H)r.AddLog("\083\099\114\105\112\116",{Text="\083\101\114\118\101\114 \114\101\109\111\118\101\100 "..tostring(H);Desc=tostring(o)})end;UserSpoofCheck=function(H)if not f.RunService:IsStudio()then local o=f.UserService local Z,m=pcall(function()local f=L.SpoofCheckCache[H.UserId]or o:GetUserInfosByUserIdsAsync({H.UserId})local Z=f and f[1]L.SpoofCheckCache[H.UserId]=f if Z and Z.Id==H.UserId then if H.Name~=Z.Username or H.DisplayName~=Z.DisplayName then return true end else for o,f in next,f do if f.Id==H.UserId then if H.Name~=f.Username or H.DisplayName~=f.DisplayName then return true end end end end end)if not Z then warn("\070\097\105\108\101\100 \116\111 \099\104\101\099\107 \118\097\108\105\100\105\116\121 \111\102 \112\108\097\121\101\114\'\115 \110\097\109\101\044 \114\101\097\115\111\110\058 "..tostring(m))end end end,Sanitize=function(H,o)if L.RLocked(H)then pcall(f.Delete,H)else for H,m in next,H:GetChildren()do if L.RLocked(m)or Z.IsClass(m,o)then pcall(f.Delete,m)else pcall(L.Sanitize,m,o)end end end end;isFake=function(H)if L.ObjRLocked(H)or not H:IsA("\080\108\097\121\101\114")then return true,1 else local o=f.Players:GetChildren()local Z=0 if f.NetworkServer then local o=false for f,Z in pairs(f.NetworkServer:GetChildren())do if Z:IsA("\078\101\116\119\111\114\107\082\101\112\108\105\099\097\116\111\114")and Z:GetPlayer()==H then o=true end end if not o then return true,1 end end for o,f in pairs(o)do if tostring(f)==tostring(H)then Z=Z+1 end end if Z>1 then return true,Z else return false end end end;RemoveIfFake=function(H)local o local f,Z=pcall(function()o=L.isFake(H)end)if o or not f then L.RemovePlayer(H)end end;FindFakePlayers=function()for H,o in pairs(f.Players:GetChildren())do if L.isFake(o)then L.RemovePlayer(o,"\070\097\107\101")end end end;GetClassName=function(H)local o=tostring(math.random()..math.random())local f,Z=pcall(function()local f=H[o]end)if Z then local H=Z:match(o.." \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 \040\046\042\041")if H then return H end end end;RLocked=function(H)return not pcall(function()return H.GetFullName(H)end)end;ObjRLocked=function(H)return not pcall(function()return H.GetFullName(H)end)end,AssignName=function()local H=math.random(100000,999999)return H end;Detected=function(H,o,Z)local m=string.gsub(tostring(Z),"\n","")if V.DebugMode or f.RunService:IsStudio()then warn("\065\078\084\073-\069\088\080\076\079\073\084\058 "..(H.Name..(" "..(o..(" "..m)))))elseif f.NetworkServer then if H then if o:lower()=="\108\111\103"then elseif o:lower()=="\107\105\099\107"then L.RemovePlayer(H,m)elseif o:lower()=="\107\105\108\108"then H.Character:BreakJoints()elseif o:lower()=="\099\114\097\115\104"then i.Send(H,"\070\117\110\099\116\105\111\110","\075\105\108\108")wait(5)pcall(function()local o=V.NewScript("\076\111\099\097\108\083\099\114\105\112\116","\119\104\105\108\101 \116\114\117\101 \100\111 \101\110\100")o.Parent=H.Backpack o.Disabled=false end)L.RemovePlayer(H,m)else L.Detected(H,"\075\105\099\107","\083\112\111\111\102\101\100 \108\111\103")return end end end r.AddLog(r.Script,{Text="\065\069 \068\101\116\101\099\116\101\100 "..tostring(H),Desc="\084\104\101 \065\110\116\105-\069\120\112\108\111\105\116 \115\121\115\116\101\109 \100\101\116\101\099\116\101\100 \115\116\114\097\110\103\101 \097\099\116\105\118\105\116\121 \102\114\111\109 "..tostring(H);Player=H})r.AddLog(r.Exploit,{Text="\091\065\099\116\105\111\110\058 "..(tostring(o)..(" \085\115\101\114\058 \040"..(tostring(H)..("\041\093 "..(tostring(m:sub(1,50)).." \040\077\111\117\115\101 \111\118\101\114 \102\117\108\108 \105\110\102\111\041"))))),Desc=tostring(m),Player=H})end;CheckNameID=function(H)if H.userId>0 and(H.userId~=game.CreatorId and H.Character)then local o=f.Players:GetUserIdFromNameAsync(H.Name)or H.userId local Z=f.Players:GetNameFromUserIdAsync(H.userId)or H.Name if Z and o then if tonumber(o)and o~=H.userId or tostring(Z)~="\110\105\108"and Z~=H.Name then L.Detected(H,"\108\111\103","\078\097\109\101\047\085\115\101\114\073\100 \100\111\101\115 \110\111\116 \109\097\116\099\104")end i.Send(H,"\076\097\117\110\099\104\065\110\116\105","\078\097\109\101\073\100",{RealID=o,RealName=Z})end end end}end
--// Anti-Exploit
return function(Vargs)
	local server = Vargs.Server
	local service = Vargs.Service

	local Functions, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Settings
	local function Init()
		Functions = server.Functions
		Admin = server.Admin
		Anti = server.Anti
		Core = server.Core
		HTTP = server.HTTP
		Logs = server.Logs
		Remote = server.Remote
		Process = server.Process
		Variables = server.Variables
		Settings = server.Settings

		Logs:AddLog("Script", "AntiExploit Module Initialized")
	end

	server.Anti = {
		Init = Init,
		SpoofCheckCache = {},
		RemovePlayer = function(p, info)
			info = info or "No Reason Given"
			pcall(function()
				service.UnWrap(p):Kick(tostring(info))
			end)
			--pcall(function() Remote.Send(p,"Function","Kill") end)
			wait(1)
			pcall(p.Destroy, p)
			pcall(service.Delete, p)
			Logs.AddLog("Script", {
				Text = "Server removed " .. tostring(p),
				Desc = tostring(info),
			})
		end,

		UserSpoofCheck = function(p)
			--// Supplied by BetterAccount
			if not service.RunService:IsStudio() then
				local userService = service.UserService
				local success, err = pcall(function()
					local userInfo = Anti.SpoofCheckCache[p.UserId]
						or userService:GetUserInfosByUserIdsAsync({ p.UserId })
					local data = userInfo and userInfo[1]

					Anti.SpoofCheckCache[p.UserId] = userInfo

					if data and data.Id == p.UserId then
						if p.Name ~= data.Username or p.DisplayName ~= data.DisplayName then
							return true
						end
					else
						for i, user in next, userInfo do
							if user.Id == p.UserId then
								if p.Name ~= user.Username or p.DisplayName ~= user.DisplayName then
									return true
								end
							end
						end
					end
				end)

				if not success then
					warn("Failed to check validity of player's name, reason: " .. tostring(err))
				end
			end
		end,

		Sanitize = function(obj, classList)
			if Anti.RLocked(obj) then
				pcall(service.Delete, obj)
			else
				for i, child in next, obj:GetChildren() do
					if Anti.RLocked(child) or Functions.IsClass(child, classList) then
						pcall(service.Delete, child)
					else
						pcall(Anti.Sanitize, child, classList)
					end
				end
			end
		end,

		isFake = function(p)
			if Anti.ObjRLocked(p) or not p:IsA("Player") then
				return true, 1
			else
				local players = service.Players:GetChildren()
				local found = 0

				if service.NetworkServer then
					local net = false
					for i, v in pairs(service.NetworkServer:GetChildren()) do
						if v:IsA("NetworkReplicator") and v:GetPlayer() == p then
							net = true
						end
					end
					if not net then
						return true, 1
					end
				end

				for i, v in pairs(players) do
					if tostring(v) == tostring(p) then
						found = found + 1
					end
				end

				if found > 1 then
					return true, found
				else
					return false
				end
			end
		end,

		RemoveIfFake = function(p)
			local isFake
			local ran, err = pcall(function()
				isFake = Anti.isFake(p)
			end)
			if isFake or not ran then
				Anti.RemovePlayer(p)
			end
		end,

		FindFakePlayers = function()
			for i, v in pairs(service.Players:GetChildren()) do
				if Anti.isFake(v) then
					Anti.RemovePlayer(v, "Fake")
				end
			end
		end,

		GetClassName = function(obj)
			local testName = tostring(math.random() .. math.random())
			local ran, err = pcall(function()
				local test = obj[testName]
			end)
			if err then
				local class = err:match(testName .. " is not a valid member of (.*)")
				if class then
					return class
				end
			end
		end,

		RLocked = function(obj)
			return not pcall(function()
				return obj.GetFullName(obj)
			end)
			--[[local ran,err = pcall(function() service.New("StringValue", obj):Destroy() end)
			if ran then
				return false
			else
				return true
			end--]]
		end,

		ObjRLocked = function(obj)
			return not pcall(function()
				return obj.GetFullName(obj)
			end)
			--[[local ran,err = pcall(function() obj.Parent = obj.Parent end)
			if ran then
				return false
			else
				return true
			end--]]
		end,

		AssignName = function()
			local name = math.random(100000, 999999)
			return name
		end,

		Detected = function(player, action, info)
			local info = string.gsub(tostring(info), "\n", "")

			if Core.DebugMode or service.RunService:IsStudio() then
				warn("ANTI-EXPLOIT: " .. player.Name .. " " .. action .. " " .. info)
			elseif service.NetworkServer then
				if player then
					if action:lower() == "log" then
						-- yay?
					elseif action:lower() == "kick" then
						Anti.RemovePlayer(player, info)
						--player:Kick("Adonis; Disconnected by server; \n"..tostring(info))
					elseif action:lower() == "kill" then
						player.Character:BreakJoints()
					elseif action:lower() == "crash" then
						Remote.Send(player, "Function", "Kill")
						wait(5)
						pcall(function()
							local scr = Core.NewScript("LocalScript", [[while true do end]])
							scr.Parent = player.Backpack
							scr.Disabled = false
						end)

						Anti.RemovePlayer(player, info)
					else
						-- fake log (thonk?)
						Anti.Detected(player, "Kick", "Spoofed log")
						return
					end
				end
			end

			Logs.AddLog(Logs.Script, {
				Text = "AE Detected " .. tostring(player),
				Desc = "The Anti-Exploit system detected strange activity from " .. tostring(player),
				Player = player,
			})

			Logs.AddLog(Logs.Exploit, {
				Text = "[Action: " .. tostring(action) .. " User: (" .. tostring(player) .. ")] " .. tostring(
					info:sub(1, 50)
				) .. " (Mouse over full info)",
				Desc = tostring(info),
				Player = player,
			})
		end,

		CheckNameID = function(p)
			if p.userId > 0 and p.userId ~= game.CreatorId and p.Character then
				local realId = service.Players:GetUserIdFromNameAsync(p.Name) or p.userId
				local realName = service.Players:GetNameFromUserIdAsync(p.userId) or p.Name

				if realName and realId then
					if
						(tonumber(realId) and realId ~= p.userId) or (
							tostring(realName) ~= "nil" and realName ~= p.Name
						)
					then
						Anti.Detected(p, "log", "Name/UserId does not match")
					end

					Remote.Send(p, "LaunchAnti", "NameId", { RealID = realId, RealName = realName })
				end
			end
		end,
	}
end
