--------------------------------------------- -- deflood version 4.x --------------------------------------------- -- pre V4.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). --------------------------------------------- -- V4.3.2 ----- -- changed the $ConnectToMe has now only the option to do a timeban of x minutes. -- instead of showing "you banned" it gives the correct IP and links to some site's -- with info about how to setup active mode while being behind a router. --------------------------------------------- -- V4.3.3 ----- -- changed the $ConnectToMe check now disconnects private ip ranges, and tells them the right IP to use -- changed reason msg send to the kicked/banned users matched the kick/ban type. --------------------------------------------- -- V4.3.4 ----- -- fixed bug on not kicking/banning (thx reefa) -- fixed bug on level checking (thx reefa) --------------------------------------------- -- V4.3.5 ----- -- quick fix for the !me flooder from TE ---------------------------------------------------------------------- ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- 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 -- time the tempban on bad IP's in the dc active setup should last -- (don't make it 2 long, mostly this check hits on bad settings but it could be a flooder -- but keep it above 5 so the automatic reconnect from dc++ doesn't make it flood you opchat/logs). iConnect = 8 -- 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 hub owners who are behind a NAT router) --tIPs = { ["127.0.0.1"] = 1, ["127.0.0.2"] = 1 } tIPs = { ["172.30.1.11"] = 1, ["172.30.1.15"] = 1 } -- don't even think about changing the next table (private ip ranges in decimal format) tPriv = { [3232235520] = 3232301055, [2886729728] = 2887778303, [167772160] = 184549375 } -- 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) if iKill == 1 then user:SendPM(Bot, "You are now kicked on suspision of using a hub flooder!!|") user:Kick() elseif iKill == 2 then user:SendPM(Bot, "You are now banned on suspision of using a hub flooder!!|") user:Ban() elseif iKill == 3 then user:SendPM(Bot, "You are now temp banned on suspision of using a hub flooder!!|") user:TempBan() elseif iKill == 4 then user:SendPM(Bot, "You are now time banned on suspision of using a hub flooder for the next "..iTimeBan.." minutes!!|") user:TimeBan(iTimeBan) else user:SendPM(Bot, "You are now disconnected on suspision of using a hub flooder!!|") user:Disconnect() end return 1 end function CheckLevel(user) if iMode then return user.bOperator else return not tMode[user.iProfile] end end function DataArrival(user, data) if strfind(data, "€AM€LiT€ OWN€D YOU") then msg = user.sName.." - "..user.sIP.." - "..date().." - banned for using a hub flooder!! (!me flooder)" StoreLog(user.sName, msg) return ByeBye(user) elseif( 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) 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) 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) 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 local s,e,dIP1,dIP2,dIP3,dIP4 = strfind(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)") dIP1 = (tonumber(dIP1) * 16777216) + (tonumber(dIP2) *65536) + (tonumber(dIP3) * 256) + (tonumber(dIP4)) for a,b in tPriv do if dIP1 >= a and dIP1 <= b then user:SendPM(Bot, "You either left the IP box from your active settings empty or you placed a private IP in there by accident!\r\n".. "IP's like this will not resolve outside your local network, change it for "..user.sIP.."|") user:Disconnect() return 1 end end user:SendPM(Bot, "You have the wrong IP in the active settings from your DC client!!\r\n".. "You have set it to "..ip..", the IP you should have set it on is: "..user.sIP..".\r\n".. "For Safety reasons you are now banned for "..iConnect.." minutes\r\n".. "For more info about how to setup active mode you should look at the next website's:\r\n".. "Default router setup manual: ---> http://www.plop.nl/lua_tools/dc-active.zip\r\n".. "Specialized router manuals: ---> http://www.portforward.com\r\n".. "Official dc++ faq: ---> http://dcplusplus.sourceforge.net/faq/faq.php?display=faq&faqnr=11&catnr=2&prog=1&lang=en&onlynewfaq=1 |") msg = user.sName.." - "..user.sIP.." - "..date().." - time banned for a wrong ip in the $ConnectToMe, but this could be a hub flooder!! (bad/fake ConnectToMe)" StoreLog(user.sName, msg) --user:TimeBan(iConnect) user:Disconnect() return 1 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) 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) 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) 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) end return ByeBye(user) 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) 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) 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) 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 user:SendPM(Bot, what.."|") return ByeBye(user) 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