--------------------------------------------- -- deflood version 4.x --------------------------------------------- -- pre 4.x things ----- -- only filter chat for unreged users. -- bounch the flood msg back 2 the sender. -- now kicks after x times (user is warned). -- added phatty's ban on description. -- added chilla's script against the myInfo flooder. -- added share check thx psf8500. -- added choise on were 2 show the msg's 2 the ops (own window or opchat). -- added test by removing numbers from the msg, so chat flooders can't count in there msg. -- added detection for user flooders which show a number behind the tag. -- added filter for me mode. -- added filter so away msg don't get seen as flooding. --------------------------------------------- -- V4+ ----- -- added filter for crimson. -- added filter for omega. -- added filter for midnight. -- changed logs now also store the ip's of the banned users. -- thx to ruri_ruri for helping on this new version of deflood, --------------------------------------------- -- V4.1 ----- -- fixed strfind error. --------------------------------------------- -- V4.2 ----- -- added direct kick/ban for the pm/chat flooders. -- small optimization on the description table. --------------------------------------------- -- V4.3 ----- -- added protection against GetNickList floods (thx to psf8500). -- added protection against fake MyInfo's with random chars (thx to psf8500). -- added protection against fake IP's on ConnectToMe (thx to psf8500). -- changed removed the need for 2 versions of deflood, mode can be set from the script now. -- changed made it optional to set what to do with flooders (no need 2 mod the script anymore). --------------------------------------------- -- V4.3.1 ----- -- changed the amount of times a user can do $GetNickList can be set from the config. -- added table with imune IP's on the fake $ConnectToMe's (some hubowners need this). ---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- paybacks a biotch!! -- enjoy. plop -- http://www.plop.nl ---------------------------------------------------------------------- --- the script only kicks by default altho the message says banned. --- change this if you want it 2 really ban. ---------------------------------------------------------------------- -- name of the bot. Bot="deflood" -- maximum msg's stored from the user MaxStored = 3 -- maximum amount of warnings before it bans for chat flooding Max = 3 -- location/name of the log file file = "logs/flood.log" -- filter levels. use 1 for everything but OP's, nil for the table with level numbers. iMode = 1 tMode = { [-1] = 1 } -- do what to flooders. -- use nil for disconnect, 1 for a kick, 2 for a ban, 3 for a tempban, 4 for a timeban. iKill = nil -- if timeban then how many minutes. iTimeBan = 15 -- the table for banning by description (["search string"] = number) badTable = { ["Ruri_Ruri"]=1, ["R u r i_ R u r i "]=2, ["TEAMELITE"]=3, ["F8X0R"]=4, ["KNUCKLES"]=5, ["OPZONE"]=6,["K-N-U-C-K-L-E-S"]=7, ["Meka_Meka"]=8, ["O-M-E-G-A"]=9, ["OMEGA"]=10 } --badTable = { ["ruri_ruri"]=1, --["R u r i_ R u r i "]=2, ["TEAMELITE"]=3, ["F8X0R"]=4, ["KNUCKLES"]=5, ["OPZONE"]=6,["K-N-U-C-K-L-E-S"]=7, ["Meka_Meka"]=8, ["O-M-E-G-A"]=9, ["OMEGA"]=10 } -- name of the opchat so the output of this script shows up there instead of it's own window -- comment this for own window (aka place -- before it like this text has) opchat = "-OPChat-" -- fill in the name here if you use a scripted opchat --opchat = frmHub:GetOpChatName() -- uncomment this and make the above a comment if you use the ptokax build-in opchat -- filter away msg's (use nil to disable, 1 to enable) AWAY = 1 -- don't check the next IP's on fake $ConnectToMe's -- (for if your hub owners who are behind a NAT router) tIPs = { ["127.0.0.1"] = 1, ["127.0.0.2"] = 1 } -- max amount of times someone can do $GetNickList before deflood treads it as a flooder. iMaxGetNick = 5 -- explain the script what seconds, minutes, hours and day's are sec = 1000 min = 60 * sec hour = 60 * min day = 12 * hour -- timer between table flushes -- 10 * sec == 10 sec memory -- 2 * hour == 2 hour memory time = 10 * sec -- the tables needed msgTable= {} tShare = {} tNames = {} tMyInfo = {} tGetNick = {} function Main() frmHub:EnableFullData(1) frmHub:RegBot(Bot) SetTimer(time) StartTimer() badTable2 = {} for i,v in badTable do local a = gsub(gsub(gsub(i, "-",""), " ", ""), " ","") a = strlower(a) badTable2[a]=1 end badTable = nil end function OnTimer() msgTable= nil tShare = nil tNames = nil tMyInfo = nil tGetNick = nil msgTable= {} tShare = {} tNames = {} tMyInfo = {} tGetNick = {} end function ByeBye(user, what) if what == nil then what = "You are now banned on suspision of using a hub flooder!!|" end user:SendPM(Bot, what) if iKill == 1 then user:Kick() elseif iKill == 2 then user:Ban() elseif iKill == 3 then user:TempBan() elseif iKill == 4 then user:TimeBan(iTimeBan) else user:Disconnect() end return 1 end function CheckLevel(user) if iMode then return user.bOperator else return tMode[user.iProfile] end end function DataArrival(user, data) if( strsub(data, 1, 1) == "<" ) then if not CheckLevel(user) then data = strsub(data, 1, (strlen(data)-1)) s,e,nick, data = strfind(data, "^(%b<>)(.+)") nick = GetItemByName(strsub(nick, 2, -2)) if nick == nil then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (fake nick version)" StoreLog(user.sName, msg) return ByeBye(user, what) elseif ChatCheck(user, data) then return 1 end end elseif( strsub(data, 1, 1) == "*" ) then if not CheckLevel(user) then data = strsub(data, 1, (strlen(data)-1)) s,e,data = strfind(data, "^%*%s*(.+)") if ChatCheck(user, data) then return 1 end end elseif(strsub(data, 1, 4) == "$To:") then if not CheckLevel(user) then data = strsub(data, 1, (strlen(data)-1)) s,e,data = strfind(data, "$%b<>(.+)") local t,c = gsub(data, "xXxX", "") if c >1 then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a client flooder!!" StoreLog(user.sName, msg) return ByeBye(user, what) elseif ChatCheck(user, data) then return 1 end end elseif strsub(data, 1, 12) == "$GetNickList" then if tGetNick[user.sName] == nil then tGetNick[user.sName] = 1 else tGetNick[user.sName] = tGetNick[user.sName] +1 if tGetNick[user.sName] >= iMaxGetNick then tGetNick[user.sName] = nil msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (GetNickList flood)" StoreLog(user.sName, msg) return ByeBye(user, what) end end elseif strsub(data, 1, 12) == "$ConnectToMe" then local s,e,ip = strfind(data, "(%S+):%d+|$") if ip and tIPs[user.sIP] == nil then if ip ~= user.sIP then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (fake ConnectToMe)" StoreLog(user.sName, msg) return ByeBye(user, what) end end elseif strsub(data, 1, 7) == "$MyINFO" then if tMyInfo[user.sName] == nil then tMyInfo[user.sName] = 1 else tMyInfo[user.sName] = tMyInfo[user.sName] +1 local t =(frmHub:GetUsersCount()+10) if tMyInfo[user.sName] >= t then tMyInfo[user.sName] = nil msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (myInfo flood)" StoreLog(user.sName, msg) return ByeBye(user, what) end end local i,j,temp = strfind(data, "$(%d+)%$") if temp then if strlen(temp) >= 11 then temp = strsub(temp, -11, -1) if tonumber(temp) == 99511627776 then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (share version)" StoreLog(user.sName, msg) return ByeBye(user, what) end end end local _,_,tmp = strfind(data, "%b<>(%d+)%$") if tmp then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (tag version)" StoreLog(user.sName, msg) return ByeBye(user, what) end local _,_,nick = strfind(data,"^%$MyINFO %$ALL (%S+)") if nick and (nick ~= user.sName) then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (myInfo version)" StoreLog((nick.." -"..user.sName), msg) nick = GetItemByName(nick) if nick then ByeBye(nick, what) end return ByeBye(user, what) end local name = gsub(user.sName, "%d", "") if strlen(name) == 0 then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (banned on nickname)" StoreLog(user.sName, msg) return ByeBye(user, what) end s,e,data = strfind(data, "%$ALL%s+%S+(.*)%b<>%$") if data then data = strlower(data) data = gsub(gsub(gsub(data, "-", ""), " ", ""), " ", "") for i,v in badTable2 do local s,e,no = strfind(data, ".*("..i..").*") if no then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (banned on description)" StoreLog(user.sName, msg) return ByeBye(user, what) end end local s,e,share = strfind(data, "$(%d+)%$") if share then if tShare[share] == nil then tShare[share] = 1 tNames[user.sName] = 1 elseif tNames[user.sName] == nil then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (banned on share match)" StoreLog(user.sName, msg) return ByeBye(user, what) end end end end end function ChatCheck(user, data) local name = user.sName data = gsub(data, "%d", "") if AWAY then s,e,away = strfind(data,"(%b<>)$") if away then return end end local count = 0 if msgTable[name] == nil then msgTable[name] = {} msgTable[name][1]=data return else for i=1,MaxStored do if msgTable[name][i] then if data == msgTable[name][i] then if msgTable[name]["count"] == nil then user:SendPM(Bot, "Stop flooding you fool :"..data.."|") user:SendPM(Bot, "This is your 1st warning. After "..Max.." you will be banned!!|") msgTable[name]["count"]=1 msg = user.sName.." - "..user.sIP.." - "..date().." - flood warning number: 1. msg was: "..data StoreLog(user.sName, msg) count = 1 return 1 else msgTable[name]["count"]=msgTable[name]["count"] +1 if msgTable[name]["count"] >= Max then what = "You have been warned!! You are now banned for flooding the hub!!" msg = user.sName.." - "..user.sIP.." - "..date().." - now banned for flooding. msg was: "..data StoreLog(user.sName, msg) msgTable[name] = nil return ByeBye(user, what) else user:SendPM(Bot, "This is warning number "..msgTable[name]["count"]..". After "..Max.." you will be banned!!|") msg = user.sName.." - "..user.sIP.." - "..date().." - flood warning number: "..msgTable[name]["count"]..". msg was: "..data StoreLog(user.sName, msg) return 1 end end end end end end if count == 0 then local count2 = 0 for i=1,MaxStored do if msgTable[name][i] then count2 = count2 +1 else break end end if count2 >= MaxStored then for i=1,MaxStored do if msgTable[name][i] ~= nil then local tmp = i+1 if msgTable[name][tmp] then msgTable[name][i] = msgTable[name][tmp] else msgTable[name][i]=data break end end end else count2 = count2 +1 msgTable[name][count2]=data end end end function StoreLog(nick, msg) appendto(file) if opchat then SendPmToOps(opchat, msg.."|") else SendPmToOps(Bot, msg.."|") end write(msg.."\n") writeto() msg = nil end