PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: LiqUiD~TrolL on 22 March, 2005, 18:32:27

Title: i was on the rus to tell it was ok !!!
Post by: LiqUiD~TrolL on 22 March, 2005, 18:32:27
my antiflood script doesn t works. plop,can you help maybe???? here is the script i guess it s in LUA 4

/CODE
_____________________________________________
---------------------------------------------------------------------
--                 Config part.
----------------------------------------------------------------------

----------------------------------------------------------------------
---- name of the bot.
Bot = "-ProTeCtoR-"
----------------------------------------------------------------------

----------------------------------------------------------------------
---- maximum msg's stored from the user.
iMaxStored = 6
----------------------------------------------------------------------

----------------------------------------------------------------------
---- maximum amount of warnings before it bans for chat flooding.
iMaxWarn = 5
----------------------------------------------------------------------

----------------------------------------------------------------------
---- location/name of the math.log file.
fFile = "flood.log"
fFolder = "logs"
----------------------------------------------------------------------

----------------------------------------------------------------------
---- 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 = 20
---- 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 your opchat/logs).
iConnect = 8
----------------------------------------------------------------------

----------------------------------------------------------------------
---- maximum amount of times an ip can connect per xx seconds (table io.flush timer).
iMaxCon = 5
----------------------------------------------------------------------

----------------------------------------------------------------------
---- the table for banning by description (["search string"] = number).
tDesc = {
["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,
["HaX0R"]=11,
["HaXOR"]=12,
["Anime&Music"]=13
}
----------------------------------------------------------------------

----------------------------------------------------------------------
---- 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).
sOpchat = "OpChat"  -- fill in the name here if you use a scripted opchat.
--sOpchat = frmHub:GetOpChatName()     -- uncomment this and make the above a comment if you use the ptokax build-in opchat.
--sOpchat = nil    ---- uncomment this if you want deflood to show the notification in it's own window.
----------------------------------------------------------------------

----------------------------------------------------------------------
---- table with user levels or names of seperate users which should see the notifications from defloods kicks/bans.
--tNotUs = nil -- uncomment this for the old style (all op's)
tNotUs = {
   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.." - "..os.date().." - time banned for a wrong ip in the $ConnectToMe, but this could be a hub flooder!! (bad/fake ConnectToMe)"
   StoreLog(user.sName, msg)
   if CheckLevel(user) then
if iKill then
   user:TimeBan(iConnect)
else
   user:Disconnect()
end
   else
user:Disconnect()
   end
else
   user:SendPM(Bot, "An IP contains 4 numbers seperated by 3 dots. Your correct IP is "..user.sIP.."|")
   user:Disconnect()
end
return 1
   end
end

   -- MyInfo filter.
   elseif string.sub(data, 1, 7) == "$MyINFO" then
if tMyInfo[user.sName] then
   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.." - "..os.date().." - banned for using a hub flooder!! (myInfo flood)"
StoreLog(user.sName, msg)
return ByeBye(user)
   end
else
   tMyInfo[user.sName] = 1
end

-- bad share filter (same ending size).
local i,j,temp = string.find(data, "$(%d+)%$")
if temp then
   if string.len(temp) >= 11 then
temp = string.sub(temp, -11, -1)
if tonumber(temp) ==  99511627776 then
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (share version)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end
   end
end

-- bad tag filter.
local _,_,tmp = string.find(data, "%b<>(%d+)%$")
if tmp then
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (tag version)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end

 -- fake MyInfo flooder.
local _,_,nick = string.find(data,"^%$MyINFO %$ALL (%S+)")
if nick and (nick ~= user.sName) then
   msg = user.sName.." - "..user.sIP.." - "..os.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

-- nil/counting nick filter.
local name = string.gsub(user.sName, "%d", "")
if string.len(name) == 0 then
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (banned on nickname)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end

-- description filter.
s,e,data = string.find(data, "%$ALL%s+%S+(.*)%b<>%$")
if data then
   data = string.lower(data)
   data = string.gsub(string.gsub(string.gsub(data, "-", ""), " ", ""), " ", "")
   for i,v in tDesc2 do
local s,e,no = string.find(data, ".*("..i..").*")
if no then
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (banned on description)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end
   end

   -- share match filter (also solves clones).
   local s,e,share = string.find(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.." - "..os.date().." - banned for using a hub flooder!! (banned on share match)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end
   end
end
   end
end
----------------------------------------------------------------------

----------------------------------------------------------------------
-- the repeating msg filter.
function ChatCheck(user, data, Table)
   data = string.gsub(data, "[%s%d]", "")
   -- filter away msg's or not.
   if AWAY then
s,e,away = string.find(data,"(%b<>)$")
if away then
   return
end
   end
   -- back to normal.
   local name = user.sName
   local count = 0
   if Table[name] == nil then
Table[name] = {}
Table[name][1]=data
return
   else
for i=1,iMaxStored do
   if Table[name] then
if data == Table[name] then
   if Table[name]["count"] == nil then
user:SendPM(Bot, "Stop flooding you fool : "..data.."|")
user:SendPM(Bot, "This is your 1st warning. After "..iMaxWarn.." you will be banned!!|")
Table[name]["count"]=1
msg = user.sName.." - "..user.sIP.." - "..os.date().." - flood warning number: 1. msg was: "..data
StoreLog(user.sName, msg)
count = 1
return 1
   else
Table[name]["count"]=Table[name]["count"] +1
if Table[name]["count"] >= iMaxWarn then
   what = "You have been warned!! You are now banned for flooding the hub!!"
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - now banned for flooding. msg was: "..data
   StoreLog(user.sName, msg)
   Table[name] = nil
   user:SendPM(Bot, what.."|")
   return ByeBye(user)
else
   user:SendPM(Bot, "This is warning number "..Table[name]["count"]..". After "..iMaxWarn.." you will be banned!!|")
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - flood warning number: "..Table[name]["count"]..". msg was: "..data
   StoreLog(user.sName, msg)
   return 1
end
   end
end
   end
end
   end
   -- cleaning the table.
   if count == 0 then
local count2 = 0
for i=1,iMaxStored do
   if Table[name] then
count2 = count2 +1
   else
break
   end
end
if count2 >= iMaxStored then
   for i=1,iMaxStored do
if Table[name] ~= nil then
   local tmp = i+1
   if Table[name][tmp] then
Table[name] = Table[name][tmp]
   else
Table[name]=data
break
   end
end
   end
else
   count2 = count2 +1
   Table[name][count2]=data
end
   end
end
----------------------------------------------------------------------

function NotOps(msg)
   if tNotUs then
for a,b in tNotUs do
   if tonumber(a) then
for c,d in GetUsersByProfile(GetProfileName(a)) do
   local usr = GetItemByName(d)
   if usr then
if sOpchat then
   usr:SendPM(sOpchat, msg.."|")
else
   usr:SendPM(Bot, msg.."|")
end
   end
end
   else
if GetItemByName(a) then
   local usr = GetItemByName(a)
   if sOpchat then
usr:SendPM(sOpchat, msg.."|")
   else
usr:SendPM(Bot, msg.."|")
   end
end
   end
end
   else
if sOpchat then
   SendPmToOps(sOpchat, msg.."|")
else
   SendPmToOps(Bot, msg.."|")
end
   end
end

----------------------------------------------------------------------
-- write the math.log file.
function StoreLog(nick, msg)
   local sDate = string.gsub(os.date("%x"), "%D", "-")
   appendto(fFolder.."/"..sDate.."-"..fFile)
   NotOps(msg)
   write(msg.."\n")
   writeto()
   msg = nil
end
----------------------------------------------------------------------

----------------------------------------------------------------------
-- check's done on entry.
function NewUserConnected(user)
   -- bad share filter.
   if CheckShare(user) then
msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (badshare table)"
StoreLog(user.sName, msg)
return ByeBye(user)
   end
   -- hammer filter.
   if tUIPs[user.sIP] then
tUIPs[user.sIP] = tUIPs[user.sIP] +1
if tUIPs[user.sIP] >= iMaxCon then
   msg = user.sName.." - "..user.sIP.." - "..os.date().." - banned for using a hub flooder!! (IP connected more then "..iMaxCon.."x within "..(iFlushTime / 1000).." seconds)"
   StoreLog(user.sName, msg)
   return ByeBye(user)
end
   else
tUIPs[user.sIP] = 1
   end
end
----------------------------------------------------------------------

----------------------------------------------------------------------
--                 all done.
----------------------------------------------------------------------
_____________________________________________





Title:
Post by: jiten on 22 March, 2005, 18:43:57
With PtokaX 16.x, there no need for the deflood script, because it's inbuilt on it.
Anyway, u can get the Lua 5 version here (http://www.plop.nl/ptokaxbots/Plop/deflood_5.0_rc1.rar).

Cheers.
Title:
Post by: LiqUiD~TrolL on 22 March, 2005, 18:50:35
m8 i already have this version of antiflood but it s not working =/
Title:
Post by: imby on 22 March, 2005, 23:47:54
It's not written in LUA5, it's VERSION 5 of the script.

Please note this: "With PtokaX 16.x, there no need for the deflood script, because it's inbuilt on it. "
Title:
Post by: LiqUiD~TrolL on 23 March, 2005, 15:45:12
ok m8 i have already noticed it that there is and anitflooder in the ptoka x

but the antflood it haves it s not so good as plops

;-) if a user have diffrend IP in settings than his true IP the ptokax can t find him.and this is a good way to attack the hub ;-)
Title:
Post by: plop on 23 March, 2005, 17:51:56
QuoteOriginally posted by LiqUiD~TrolL
ok m8 i have already noticed it that there is and anitflooder in the ptoka x

but the antflood it haves it s not so good as plops

;-) if a user have diffrend IP in settings than his true IP the ptokax can t find him.and this is a good way to attack the hub ;-)
so basicly you want a standalone ctm/rctm filter for lua 5?

plop
Title: plooop
Post by: LiqUiD~TrolL on 28 March, 2005, 11:35:02
hehehe my friend i m not the specialist here you are the one =)

what do you suggest for me??
 well even with robo new antiflood protection do you thikn i m very good protected ??? or you have a script to suggest ????
Title:
Post by: LiqUiD~TrolL on 29 March, 2005, 15:20:11
anyone can answer??

plop??
Title: still waiting for a help here
Post by: LiqUiD~TrolL on 31 March, 2005, 09:42:48
PLOOOOOP
Title:
Post by: The_Fox on 31 March, 2005, 14:37:54
I don't want to throw dirt at plop in any way, his Deflood is great, but I wouldn't say it's better than PtokaX's built-in deflood interface. In my opinion it was made obsolete by new PtokaX versions and is not needed anymore. Bult-in security should be faster and more effective than scripted one
Title:
Post by: LiqUiD~TrolL on 02 April, 2005, 04:45:10
Quoteok m8 i have already noticed it that there is and anitflooder in the ptoka x     but the antflood it haves it s not so good as plops     ;-) if a user have diffrend IP in settings than his true IP the ptokax can t find him.and this is a good way to attack the hub ;-)

read the forum next time before posting ;-)
Title:
Post by: plop on 03 April, 2005, 21:43:25
QuoteOriginally posted by LiqUiD~TrolL
anyone can answer??

plop??
i have a private life 2, and pretty busy as i'm moving 2 my own flat.
gotta paint and more boring things like that. lol

the way ppk made the deflood into ptokax is precily the same as deflood 5.0.
in fact he helped me 2 get started.
and he has the source of deflood 5.
just on some points we differ a bit, i'm more paranoid then he is. lol
but stay calm (i sure do), i'm gone make a standalone version of the ctm/rctm in lua 5.
i personaly find this a must have, just like you.

plop