i was wondering if this could be modified to count the total text length per line to some up a total within a time frame and set ban if threshold is reached:
i found this somewhere not sure where tho wether forum or archives
most tcls available use per line checking text length unlike multiple lines we
look for
like for example 300:3 300 chars within 3 sec
Last edited by simo on Fri Jun 19, 2020 6:19 pm, edited 4 times in total.
set byte_flood 300
bind pubm - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global byte_flood
# if the bots not opped, we dont do anything
if {![botisop $chan]} {return}
# if its a channel op exempt them
if {[isop $nick $chan]} {return}
# if its a validuser and they have +b or +fmo|fmo flags exempt them
if {([validuser $hand]) && ([matchattr $hand bfmo|fmo $chan])} {return}
if {([string bytelength $string] == $::byte_flood)} {
putserv "MODE $chan +b [maskhost "$nick!$host" 2]"
return
}
}
this works but it doesnt count total used chars from multiple lines to get end result and compare against threshold for example 300:5 300 or more chars used within 5 secs
set byte_flood 300
bind pubm - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global byte_flood
# if the bots not opped, we dont do anything
if {![botisop $chan]} {return}
# if its a channel op exempt them
if {[isop $nick $chan]} {return}
# if its a validuser and they have +b or +fmo|fmo flags exempt them
if {([validuser $hand]) && ([matchattr $hand bfmo|fmo $chan])} {return}
if {([string bytelength $text] >= $::byte_flood)} {
if {[isvoice $nick $chan]} { pushmode $chan -v $nick }
pushmode $chan +b [maskhost "$nick!$host" 2]
}
}
this is somewhat the same as i posted in the first post
[13:21:00] <+afk-dead> this is going to be over 200 lines of text hopefully? thought am not sure how long the line needs to be to trigger a bytes flood or not. Maybe just keep typing and see what happends? thats usually the best way?
[13:21:01] <@eggie> Bytes Count. 210
[13:21:23] <+afk-dead> thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?
[ didn't trigger without spaces ]
[ note i set it trigger on over 200 bytes ]
[13:21:37] <+afk-dead> thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?thisisgoingtobeover200linesoftexthopefully?thoughtamnotsurehowlongthelineneedstobetotriggerabytesfloodornot.Maybejustkeeptypingandsee whathappends?thatsusuallythebestway?
[13:21:38] <@eggie> Bytes Count. 340
[13:24:21] <+afk-dead> .tcl info patchlevel
[13:24:21] <@eggie> OK: 8.6.9 - 0.115 ms
set bflood(maxlength) 300
set bflood(unsettime) 5
bind pub - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global bflood
# ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}
# get the length of the text
set length [llength $text]
# ban mask
set bmask [maskhost "$nick!$host" 2]
# look up if we have them already
set nick [string tolower $nick]
set chan [string tolower $chan]
if {[info exists ::bflood($chan:$nick)]} {
# increase the count by current length of text
set ::bflood($chan:$nick) [expr {$::bflood($chan:$nick) + $length}]
# check they haven't gone over the limit
if {($::bflood($chan:$nick) > $::bflood(maxlength))} {
# they have gone over the 'maxlength'
# devoice them if they are +v
if {[isvoice $nick $chan]} {pushmode $chan -v $nick}
# set the ban
putquick "MODE $chan +b $bmask"
# unset from array
unset ::bflood($chan:$nick)
# finished
return
}
# they haven't gone over the limit, lets set a timer
utimer $::bflood(unsettime) "unset ::bflood($chan:$nick)"
# finished
return
# they are within the time limit
# we start again
} else {
# add them
set ::bflood($chan:$nick) $length
# set a time limit on them
utimer $::bflood(unsettime) "unset ::bflood($chan:$nick)"
# finished
return
}
}
This will keep a line count going for them per channel against each nickname,
if they go over 'bflood(maxlength)' total text length in 'bflood(unsettime)' seconds.
They will be banned/an devoiced if they are +v i put comments on for you,
you should really play around it with and find out what works for you
set bflood(maxlength) 300
set bflood(unsettime) 5
bind pub - * pubm:byteflood
proc pubm:byteflood {nick host hand chan text} {
global bflood
# ignore if bot not opped, ignore if its a chanop, ignore if the user has +bfmo globally or +fmo for the channel
if {(![botisop $chan]) || ([isop $nick $chan]) || ([validuser $hand]) && ([matchattr $hand +bfmo|fmo $chan])} {return}
# get the length of the text
set length [llength $text]
# ban mask
set bmask [maskhost "$nick!$host" 2]
# look up if we have them already
set nick [string tolower $nick]
set chan [string tolower $chan]
if {[info exists bflood($chan:$nick)]} {
# increase the count by current length of text
set bflood($chan:$nick) [expr {$bflood($chan:$nick) + $length}]
# check they haven't gone over the limit
if {($bflood($chan:$nick) > $::bflood(maxlength))} {
# they have gone over the 'maxlength'
# devoice them if they are +v
if {[isvoice $nick $chan]} {pushmode $chan -v $nick}
# set the ban
putquick "MODE $chan +b $bmask"
# unset from array
unset bflood($chan:$nick)
# finished
return
}
# they haven't gone over the limit, lets set a timer
utimer $::bflood(unsettime) [list unset bflood($chan:$nick)]
# finished
return
# they are within the time limit
# we start again
} else {
# add them
set bflood($chan:$nick) $length
# set a time limit on them
utimer $::bflood(unsettime) [list unset bflood($chan:$nick)]
# finished
return
}
}