PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: ?nake on 23 October, 2003, 15:29:08

Title: Anti SPam
Post by: ?nake on 23 October, 2003, 15:29:08
hmmm this script check and banns ops and vips to. and i don't know how to stopp it doing it. canb some one help?


-- SpamBan

---------------------------------------

-- version: 1.2 (06.2.2003)

-- author: DirtyFinger

-- email: [EMAIL]DirtyFinger@gmx.net[/EMAIL]

-- ICQ : 145873101

-- HomePage: [URL]http://mitglied.lycos.de/dirtyfinger01/[/URL]

-- (Yes, i know i still suck as Web Designer)

--=====================================

--This script automatically bans pm-spammers and mainchat-spammers.

--

--This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)

--For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)

--The script bans by default after 20 pms are being sent within 10 seconds.

-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.

--So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.

--For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.

--

--Don't worry, real flooders send much much more so you'll be fine.

--

-- Version Changes :

--1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.

--1.1 : removed the mainchat flooding of ban notifications

--1.0 : first version

sBotName = "(-Alexandra-)"

PMCount = {}

MainCount = {}

MaxPM = 4 -- more than 4 pms within 10 seconds cause a ban

MaxMain = 4 -- more than 4 mainchat msgs within 10 seconds cause a ban

timeslice = 10*1000 -- 10 seconds

function Main()

frmHub:RegBot(sBotName)

SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))

SetTimer(timeslice)

StartTimer()

end

--// This function is fired when a new data arrives

function DataArrival(curUser, sData)

if strfind(sData,"$To:") then

if PMCount[curUser.sIP] ~= nil then

PMCount[curUser.sIP] = PMCount[curUser.sIP] +1

--SendToAll("----",PMCount[curUser.sIP])

if PMCount[curUser.sIP] > MaxPM then

FloodDetected (curUser, sData)

PMCount[curUser.sIP] = -100

end

else

PMCount[curUser.sIP] = 1

end

elseif strfind(sData,curUser.sName,1,plain) == 2 then

if MainCount[curUser.sIP] ~= nil then

MainCount[curUser.sIP] = MainCount[curUser.sIP] +1

--SendToAll("----",PMCount[curUser.sIP])

if MainCount[curUser.sIP] > MaxMain then

FloodDetected (curUser, sData)

MainCount[curUser.sIP] = -100

end

else

MainCount[curUser.sIP] = 1

end

end

end

function OnTimer()

--for k,v in PMCount do

--SendToAll("---------",k.."\t"..v)

--end

PMCount = {}

MainCount = {}

end

function FloodDetected (curUser,sData)

local message = " -= Spam Warning =-"

local name,ip = curUser.sName,curUser.sIP

SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")

message = message .."\r\n\t\t"

.. "Violation detected by: " .. name .."\r\n\t\t"

.. "IP: " .. ip .. "\t\r\n\t\t"

.. "Last packet : \t" .. sData

SendPmToOps (sBotName,message)

curUser:Ban()

curUser:Disconnect()

end


i hope you understand :)
hehe i been banned for like 40 times i chat to much lol
 :D  8)
Title:
Post by: kepp on 26 October, 2003, 19:01:16
-- SpamBan

---------------------------------------

-- version: 1.2 (06.2.2003)

-- author: DirtyFinger

-- email: [EMAIL]DirtyFinger@gmx.net[/EMAIL]

-- ICQ : 145873101

-- HomePage: [URL]http://mitglied.lycos.de/dirtyfinger01/[/URL]

-- (Yes, i know i still suck as Web Designer)

--=====================================

--This script automatically bans pm-spammers and mainchat-spammers.

--

--This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)

--For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)

--The script bans by default after 20 pms are being sent within 10 seconds.

-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.

--So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.

--For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.

--

--Don't worry, real flooders send much much more so you'll be fine.

--

-- Version Changes :

--1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.

--1.1 : removed the mainchat flooding of ban notifications

--1.0 : first version

sBotName = "(-Alexandra-)"

PMCount = {}

MainCount = {}

MaxPM = 4 -- more than 4 pms within 10 seconds cause a ban

MaxMain = 4 -- more than 4 mainchat msgs within 10 seconds cause a ban

timeslice = 10*1000 -- 10 seconds

function Main()

frmHub:RegBot(sBotName)

SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))

SetTimer(timeslice)

StartTimer()

end

--// This function is fired when a new data arrives

function DataArrival(curUser, sData)

if strfind(sData,"$To:") then

if PMCount[curUser.sIP] ~= nil then

PMCount[curUser.sIP] = PMCount[curUser.sIP] +1

--SendToAll("----",PMCount[curUser.sIP])

if PMCount[curUser.sIP] > MaxPM then

FloodDetected (curUser, sData)

PMCount[curUser.sIP] = -100

end

else

PMCount[curUser.sIP] = 1

end

elseif strfind(sData,curUser.sName,1,plain) == 2 then

if MainCount[curUser.sIP] ~= nil then

MainCount[curUser.sIP] = MainCount[curUser.sIP] +1

--SendToAll("----",PMCount[curUser.sIP])

if MainCount[curUser.sIP] > MaxMain then

FloodDetected (curUser, sData)

MainCount[curUser.sIP] = -100

end

else

MainCount[curUser.sIP] = 1

end

end

end

function OnTimer()

--for k,v in PMCount do

--SendToAll("---------",k.."\t"..v)

--end

PMCount = {}

MainCount = {}

end

function FloodDetected (curUser,sData)

if curUser.bOperator then
return 1
else

local message = " -= Spam Warning =-"

local name,ip = curUser.sName,curUser.sIP

SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")

message = message .."\r\n\t\t"

.. "Violation detected by: " .. name .."\r\n\t\t"

.. "IP: " .. ip .. "\t\r\n\t\t"

.. "Last packet : \t" .. sData

SendPmToOps (sBotName,message)

curUser:Ban()

curUser:Disconnect()

end


Im still a newbie
if curUser.bOperator then
return 1
else

If it dosen't help don't blame me :P
Title:
Post by: ?nake on 27 January, 2004, 03:48:28
how do i put that code in there?
plz help :)

anyone plz help me with this one ;(
Title:
Post by: [NL]trucker on 27 January, 2004, 08:56:07
?nake
 


if i,m right you put it after this line

--// This function is fired when a new data arrives

function DataArrival(curUser, sData)
if curUser.bOperator then
return 1
else

now you have it this way


--// This function is fired when a new data arrives

function DataArrival(curUser, sData)

if strfind(sData,"$To:") then


dont blame me if it isnt working as i,m still trying to learn.
Title:
Post by: plop on 27 January, 2004, 17:31:07
QuoteOriginally posted by [NL]trucker
--// This function is fired when a new data arrives

function DataArrival(curUser, sData)
if curUser.bOperator then
return 1
else

now you have it this way


--// This function is fired when a new data arrives

function DataArrival(curUser, sData)

if strfind(sData,"$To:") then


dont blame me if it isnt working as i,m still trying to learn.
gone be a hub with nice quiet OP's if you do it like that. lol
the location is correct trucker, but return 1 stops all data going out.
you can guess the result. lol
now he also wanted a bypase for VIP's.
so better 2 use:
if user.iProfile==-1 or user.iProfile == 3 then up 2 you trucker 2 insert it in the script.

plop
Title:
Post by: ?nake on 28 January, 2004, 19:10:50
okej thnks for the help but .... :)
i am kind of lost hehe cold you remake it?
for me plz



:)
Title:
Post by: plop on 28 January, 2004, 23:53:15
QuoteOriginally posted by ?nake
okej thnks for the help but .... :)
i am kind of lost hehe cold you remake it?
for me plz
:)
i'm hoping trucker or maby kepp are gone fix it as they wanne learn it.
i hope you can understand this, if they don't just post here again 2morrow and i'll fix it.

plop
Title:
Post by: kepp on 29 January, 2004, 07:38:13
I will leave this one to trucker, :)
Title:
Post by: ?nake on 29 January, 2004, 20:04:48
Trucker Whanna help me with this one?
ore somebody plz :)
 :)
Title:
Post by: NightLitch on 29 January, 2004, 20:22:08
here is a solusion:

if strfind(sData,"$To:") and not curUser.bOperator then
and
elseif strfind(sData,curUser.sName,1,plain) == 2 and not curUser.bOperator then
      

play with it... but this will do what you want.
Title:
Post by: ?nake on 29 January, 2004, 20:24:39
thanks m8 but where shoul i put them in witch line?

sorry to bugg you again :)  :P
Title:
Post by: NightLitch on 29 January, 2004, 20:29:29
Well look at the lines and look in the script...

just exchange the lines with the one above.

if you not get it. I'll post the function l8r.
Title:
Post by: ?nake on 29 January, 2004, 20:38:24
ok i will give it a try thnks
 ?(
Title:
Post by: ?nake on 30 January, 2004, 03:13:58
nope i couldent figure it out.
can you help me?
ore somebody plz
Title:
Post by: plop on 30 January, 2004, 04:24:37
replace the DataArival function in the script for this 1.
--// This function is fired when a new data arrives

function DataArrival(curUser, sData)
   if strfind(sData,"$To:") then
      if user.iProfile==-1 or user.iProfile == 3 then
         if PMCount[curUser.sIP] ~= nil then
            PMCount[curUser.sIP] = PMCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if PMCount[curUser.sIP] > MaxPM then
               FloodDetected (curUser, sData)
               PMCount[curUser.sIP] = -100
            end
         else
            PMCount[curUser.sIP] = 1
         end
      end
   elseif strfind(sData,curUser.sName,1,plain) == 2 then
      if user.iProfile==-1 or user.iProfile == 3 then
         if MainCount[curUser.sIP] ~= nil then
            MainCount[curUser.sIP] = MainCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if MainCount[curUser.sIP] > MaxMain then
               FloodDetected (curUser, sData)
               MainCount[curUser.sIP] = -100
            end
         else
            MainCount[curUser.sIP] = 1
         end
      end
   end
end

plop
Title:
Post by: ?nake on 30 January, 2004, 04:30:12
thnks plop.
just in case is this right??


Quote-- SpamBan

---------------------------------------

-- version: 1.2 (06.2.2003)

-- author: DirtyFinger

-- email: DirtyFinger@gmx.net

-- ICQ : 145873101

-- HomePage: http://mitglied.lycos.de/dirtyfinger01/

-- (Yes, i know i still suck as Web Designer)

--=====================================

--This script automatically bans pm-spammers and mainchat-spammers.

--

--This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)

--For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)

--The script bans by default after 20 pms are being sent within 10 seconds.

-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.

--So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.

--For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.

--

--Don't worry, real flooders send much much more so you'll be fine.

--

-- Version Changes :

--1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.

--1.1 : removed the mainchat flooding of ban notifications

--1.0 : first version

sBotName = "(-Alexandra-)"

PMCount = {}

MainCount = {}

MaxPM = 4 -- more than 4 pms within 10 seconds cause a ban

MaxMain = 4 -- more than 4 mainchat msgs within 10 seconds cause a ban

timeslice = 10*1000 -- 10 seconds

function Main()

frmHub:RegBot(sBotName)

SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))

SetTimer(timeslice)

StartTimer()

end

--// This function is fired when a new data arrives

function DataArrival(curUser, sData)
   if strfind(sData,"$To:") then
      if user.iProfile==-1 or user.iProfile == 3 then
         if PMCount[curUser.sIP] ~= nil then
            PMCount[curUser.sIP] = PMCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if PMCount[curUser.sIP] > MaxPM then
               FloodDetected (curUser, sData)
               PMCount[curUser.sIP] = -100
            end
         else
            PMCount[curUser.sIP] = 1
         end
      end
   elseif strfind(sData,curUser.sName,1,plain) == 2 then
      if user.iProfile==-1 or user.iProfile == 3 then
         if MainCount[curUser.sIP] ~= nil then
            MainCount[curUser.sIP] = MainCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if MainCount[curUser.sIP] > MaxMain then
               FloodDetected (curUser, sData)
               MainCount[curUser.sIP] = -100
            end
         else
            MainCount[curUser.sIP] = 1
         end
      end
   end
end

--SendToAll("----",PMCount[curUser.sIP])

if MainCount[curUser.sIP] > MaxMain then

FloodDetected (curUser, sData)

MainCount[curUser.sIP] = -100

end

else

MainCount[curUser.sIP] = 1

end

end

end

function OnTimer()

--for k,v in PMCount do

--SendToAll("---------",k.."\t"..v)

--end

PMCount = {}

MainCount = {}

end

function FloodDetected (curUser,sData)

local message = " -= Spam Warning =-"

local name,ip = curUser.sName,curUser.sIP

SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")

message = message .."\r\n\t\t"

.. "Violation detected by: " .. name .."\r\n\t\t"

.. "IP: " .. ip .. "\t\r\n\t\t"

.. "Last packet : \t" .. sData

SendPmToOps (sBotName,message)

curUser:Ban()

curUser:Disconnect()

end
Title:
Post by: plop on 30 January, 2004, 04:47:37
nope, you left a piece of the old function.
-- SpamBan
---------------------------------------
-- version: 1.2 (06.2.2003)
-- author: DirtyFinger
-- email: [EMAIL]DirtyFinger@gmx.net[/EMAIL]
-- ICQ : 145873101
-- HomePage: [URL]http://mitglied.lycos.de/dirtyfinger01/[/URL]
-- (Yes, i know i still suck as Web Designer)
--=====================================
--This script automatically bans pm-spammers and mainchat-spammers.
--
--This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)
--For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)
--The script bans by default after 20 pms are being sent within 10 seconds.
-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.
--So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.
--For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.
--
--Don't worry, real flooders send much much more so you'll be fine.
--
-- Version Changes :
--1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.
--1.1 : removed the mainchat flooding of ban notifications
--1.0 : first version

sBotName = "(-Alexandra-)"
PMCount = {}
MainCount = {}
MaxPM = 4 -- more than 4 pms within 10 seconds cause a ban
MaxMain = 4 -- more than 4 mainchat msgs within 10 seconds cause a ban
timeslice = 10*1000 -- 10 seconds

function Main()
   frmHub:RegBot(sBotName)
   SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))
   SetTimer(timeslice)
   StartTimer()
end

--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
   if strfind(sData,"$To:") then
      if user.iProfile==-1 or user.iProfile == 3 then
         if PMCount[curUser.sIP] ~= nil then
            PMCount[curUser.sIP] = PMCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if PMCount[curUser.sIP] > MaxPM then
               FloodDetected (curUser, sData)
               PMCount[curUser.sIP] = -100
            end
         else
            PMCount[curUser.sIP] = 1
         end
      end
   elseif strfind(sData,curUser.sName,1,plain) == 2 then
      if user.iProfile==-1 or user.iProfile == 3 then
         if MainCount[curUser.sIP] ~= nil then
            MainCount[curUser.sIP] = MainCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if MainCount[curUser.sIP] > MaxMain then
               FloodDetected (curUser, sData)
               MainCount[curUser.sIP] = -100
            end
         else
            MainCount[curUser.sIP] = 1
         end
      end
   end
end



function OnTimer()
   --for k,v in PMCount do
   --SendToAll("---------",k.."\t"..v)
   --end
   PMCount = {}
   MainCount = {}
end

function FloodDetected (curUser,sData)
   local message = " -= Spam Warning =-"
   local name,ip = curUser.sName,curUser.sIP
   SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")
   message = message .."\r\n\t\t"
   .. "Violation detected by: " .. name .."\r\n\t\t"
   .. "IP: " .. ip .. "\t\r\n\t\t"
   .. "Last packet : \t" .. sData
   SendPmToOps (sBotName,message)
   curUser:Ban()
   curUser:Disconnect()
end

just a msg 2 every1, if you post a script place it between [ C O D E ] script here [ / C O D E ] (but without the spaces).
and try 2 leave it in tabbed state so it stays readable.
thx

plop
Title:
Post by: ?nake on 30 January, 2004, 04:55:24
ohh thanks
oki will do ;)
Title:
Post by: ?nake on 30 January, 2004, 05:08:32
sorry to bother again but i keep getting this error

Syntax error: attempt to index global `user' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 56 [file `...nistrat?r\Skrivbord\dc HUB\scripts\aspamban.lua']
 
:(
PLZ IM BEGGING YOU *CRYES* *cryes*
Title:
Post by: NightLitch on 30 January, 2004, 15:19:18
this line is wrong to what you have:

if user.iProfile==-1 or user.iProfile == 3 then

should be:

if curUser.iProfile==-1 or curUser.iProfile == 3 then


look here on dataarrival:

function DataArrival(curUser, sData)

it says curUser not user.
Title:
Post by: kepp on 30 January, 2004, 15:20:31
Called curUser with user

-- SpamBan
---------------------------------------
-- version: 1.2 (06.2.2003)
-- author: DirtyFinger
-- email: [EMAIL]DirtyFinger@gmx.net[/EMAIL]
-- ICQ : 145873101
-- HomePage: [URL]http://mitglied.lycos.de/dirtyfinger01/[/URL]
-- (Yes, i know i still suck as Web Designer)
--=====================================
--This script automatically bans pm-spammers and mainchat-spammers.
--
--This does not protect from spam, but at least the spammer can't come back (at least not with the same ip)
--For the script to work you might have to change the PtokaX flood-protection values (chat limit in the 'Rules and bots' section)
--The script bans by default after 20 pms are being sent within 10 seconds.
-- But if the hub disconnects BEFORE the script triggers, no banning is possible and the spammer can come back.
--So choose some quite generous settings, e.g. the first line of the above spam contains about 400 characters.
--For the script to trigger you have to allow the users to send 8000 characters per second so the script can trigger.
--
--Don't worry, real flooders send much much more so you'll be fine.
--
-- Version Changes :
--1.2 : bans mainchat flooder too. I didn't implement it in previous versions because i thought ptokax dealt with it.
--1.1 : removed the mainchat flooding of ban notifications
--1.0 : first version

sBotName = "(-Alexandra-)"
PMCount = {}
MainCount = {}
MaxPM = 4 -- more than 4 pms within 10 seconds cause a ban
MaxMain = 4 -- more than 4 mainchat msgs within 10 seconds cause a ban
timeslice = 10*1000 -- 10 seconds

function Main()
   frmHub:RegBot(sBotName)
   SendToAll(sBotName.." "..date(" launched at %B %d %Y %X "))
   SetTimer(timeslice)
   StartTimer()
end

--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
   if strfind(sData,"$To:") then
      if curUser.iProfile==-1 or curUser.iProfile == 3 then
         if PMCount[curUser.sIP] ~= nil then
            PMCount[curUser.sIP] = PMCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if PMCount[curUser.sIP] > MaxPM then
               FloodDetected (curUser, sData)
               PMCount[curUser.sIP] = -100
            end
         else
            PMCount[curUser.sIP] = 1
         end
      end
   elseif strfind(sData,curUser.sName,1,plain) == 2 then
      if curUser.iProfile==-1 or curUser.iProfile == 3 then
         if MainCount[curUser.sIP] ~= nil then
            MainCount[curUser.sIP] = MainCount[curUser.sIP] +1
            --SendToAll("----",PMCount[curUser.sIP])
            if MainCount[curUser.sIP] > MaxMain then
               FloodDetected (curUser, sData)
               MainCount[curUser.sIP] = -100
            end
         else
            MainCount[curUser.sIP] = 1
         end
      end
   end
end



function OnTimer()
   --for k,v in PMCount do
   --SendToAll("---------",k.."\t"..v)
   --end
   PMCount = {}
   MainCount = {}
end

function FloodDetected (curUser,sData)
   local message = " -= Spam Warning =-"
   local name,ip = curUser.sName,curUser.sIP
   SendToAll ("# "..sBotName.."-Alert #--> "..name .. " has been banned for spamming.")
   message = message .."\r\n\t\t"
   .. "Violation detected by: " .. name .."\r\n\t\t"
   .. "IP: " .. ip .. "\t\r\n\t\t"
   .. "Last packet : \t" .. sData
   SendPmToOps (sBotName,message)
   curUser:Ban()
   curUser:Disconnect()
end
Title:
Post by: NightLitch on 30 January, 2004, 15:27:14
Nice, but wanted him to learn to change it himself.
no hard feelings... :-D hehe
Title:
Post by: kepp on 30 January, 2004, 15:38:23
Oups... :(
Ah well, More trains are comming
Title:
Post by: plop on 30 January, 2004, 15:57:52
was way 2 late yesterday, stupid error i made. lol

plop
Title:
Post by: ?nake on 31 January, 2004, 02:59:16
i love you all can i kiss you?
hehe
now lets test it. thanks m8s :)
Title:
Post by: ?nake on 31 January, 2004, 03:08:09
WORKS GREAT THANKS FOLKS FOR ALL YOOURE HELP.
IM A HAPPY MAN NOW :)