egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Anti mass join floods from multi Hosts/IP's
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Sun Feb 07, 2016 11:24 am    Post subject: Anti mass join floods from multi Hosts/IP's Reply with quote

i was wondering if there is a way to use AP (allprotection) (i dont want to use AP no more since it crashes Bot when doing a restart)

ap:cjoin: {5:2 10 kb 4}


it starts kick banning if mass join flood is detected
and it temp locks channel wich is rather effective

perhaps this script made by SpiKe^^ can be modified to meet the description

Code:
## remove-damn-spam-bots.tcl v1.4 (13May2015) by SpiKe^^ ##


# Spam bots joins, kick-ban on joins:seconds #
set rdsb(flood) 3:10

# Spam bots joins kick-ban reason #
set rdsb(reasn) "Damn Spam Bot!"

# Max number of bans to stack in one mode command #
set rdsb(maxb) 6

# Length of time in minutes to ban damn spam bots #
# - set 0 to disable this script removing bans (ex. set rdsb(btime) 0) #
set rdsb(btime) 10

# After a valid damn spam bot join flood, script will continue #
# to kick-ban offenders for an additional 'x' seconds #
set rdsb(xpire) 10

# Set channel mode(s) on flood detected. #
# - set empty to disable setting channel modes (ex. set rdsb(mode) "") #
set rdsb(mode) "im"

# Remove these channel modes after how many seconds? #
set rdsb(mrem) 20

# END OF SETTINGS # Don't edit below unless you know what you're doing #

bind join - * rdsb_bindjoin

proc rdsb_bindjoin {nick uhost hand chan} {
  global rdsb rdsc rdsq

  if {[isbotnick $nick]} { return 0 }
  if {[matchattr $hand f|f $chan]} { return 0 }
  if {![string match "~*" $uhost]} { return 0 }

  set user [string range [lindex [split $uhost @] 0] 1 9]
  if {$user ne [string range $nick 0 8]} { return 0 }

  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set utnow [unixtime]
  set target [lindex $rdsb(flood) 0]

  if {[info exists rdsc($chan)]} {
    set uhlist [lassign $rdsc($chan) cnt ut]
    set utend [expr {$ut + [lindex $rdsb(flood) 1]}]
    set expire [expr {$utend + $rdsb(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset rdsc($chan) }
    } elseif {$utnow > $expire} { unset rdsc($chan) }
  }
  if {![info exists rdsc($chan)]} {
    set rdsc($chan) [list 1 $utnow $uhost]
    return 0
  }

  incr cnt
  if {$cnt <= $target} {
    if {[lsearch $uhlist $uhost] == -1} { lappend uhlist $uhost }
    if {$cnt < $target} {
      set rdsc($chan) [linsert $uhlist 0 $cnt $ut]
    } else {
      set rdsc($chan) [list $cnt $ut]
      if {$rdsb(mode) ne "" && [string is digit -strict $rdsb(mrem)]} {
        putquick "MODE $chan +$rdsb(mode)"
        utimer $rdsb(mrem) [list putquick "MODE $chan -$rdsb(mode)"]
      }
      rdsb_dobans $chan $uhlist
    }
    return 0
  }

  if {![info exists rdsq($chan)]} {
    utimer 2 [list rdsb_bque $chan]
    set rdsq($chan) [list $uhost]
  } elseif {[lsearch $rdsq($chan) $uhost] == -1} {
    lappend rdsq($chan) $uhost
  }

  if {[llength $rdsq($chan)] >= $rdsb(maxb)} {
    rdsb_dobans $chan $rdsq($chan)
    set rdsq($chan) ""
  } elseif {[botisop $chan]} { putquick "KICK $chan $nick :$rdsb(reasn)" }
  return 0
}

proc rdsb_dobans {chan uhlist} {
  global rdsb
  if {![botisop $chan]} return
  set banList ""
  set nickList ""
  foreach ele $uhlist {
    scan $ele {%[^!]!%[^@]@%s} nick user host
    set bmask "*!*@$host"
    if {[lsearch $banList $bmask] == -1} { lappend banList $bmask }
    if {[lsearch $nickList $nick] == -1} { lappend nickList $nick }
  }
  stack_bans $chan $rdsb(maxb) $banList
  foreach nk $nickList {
    if {[onchan $nk $chan]} { putquick "KICK $chan $nk :$rdsb(reasn)" }
  }


  if {$rdsb(btime) > 0} {
    set expire [expr {[unixtime] + $rdsb(btime)}]
    lappend rdsb(rmls) [list $expire $chan $banList]
  }

}

proc stack_bans {chan max banlist {opt +} } {
  set len [llength $banlist]
  while {$len > 0} {
    if {$len > $max} {
      set mode [string repeat "b" $max]
      set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
      set banlist [lrange $banlist $max end]
      incr len -$max
    } else {
      set mode [string repeat "b" $len]
      set masks [join $banlist]
      set len 0
    }
    putquick "MODE $chan ${opt}$mode $masks"
  }
}

proc rdsb_bque {chan} {
  global rdsq
  if {![info exists rdsq($chan)]} { return }
  if {$rdsq($chan) eq ""} { unset rdsq($chan) ; return }
  rdsb_dobans $chan $rdsq($chan)
  unset rdsq($chan)
}

proc rdsb_breset {} {
  global rdsc rdsb
  set utnow [unixtime]
  set target [lindex $rdsb(flood) 0]
  foreach {key val} [array get rdsc] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $rdsb(flood) 1]}]
    set expire [expr {$utend + $rdsb(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset rdsc($key) }
    } elseif {$utnow > $expire} { unset rdsc($key) }
  }


  if {[info exists rdsb(rmls)]} {
    while {[llength $rdsb(rmls)]} {
      set next [lindex $rdsb(rmls) 0]
      lassign $next expire chan banList
      if {$expire > $utnow} {  break  }
      set rdsb(rmls) [lreplace $rdsb(rmls) 0 0]
      if {![info exists rmAra($chan)]} {  set rmAra($chan) $banList
      } else {  set rmAra($chan) [concat $rmAra($chan) $banList]  }
    }
    foreach {key val} [array get rmAra] {
      set banList ""
      foreach mask $val {
        if {![ischanban $mask $key]} {  continue  }
        lappend banList $mask
      }
      if {$banList eq ""} {  continue  }
      if {![botisop $key]} {
        set rdsb(rmls) [linsert $rdsb(rmls) 0 [list $utnow $key $banList]]
      } else {  stack_bans $key $rdsb(maxb) $banList -  }
    }
    if {![llength $rdsb(rmls)]} {  unset rdsb(rmls)  }
  }


  utimer 30 [list rdsb_breset]
}

if {![info exists rdsb_running]} {
  utimer 20 [list rdsb_breset]
  set rdsb_running 1
}

set rdsb(flood) [split $rdsb(flood) :]
set rdsb(btime) [expr {$rdsb(btime) * 60}]
if {$rdsb(btime)==0 && [info exists rdsb(rmls)]} {  unset rdsb(rmls)  }

putlog "Loaded remove-damn-spam-bots.tcl v1.4 by SpiKe^^"
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Mon Feb 08, 2016 1:59 am    Post subject: Reply with quote

Have a look here where Spike^^ is updating his script and suggest this maybe he adds it up to his script.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Thu Feb 25, 2016 3:01 pm    Post subject: mass-join-protection.tcl v1.5.1 (25Feb2016) by SpiKe^^ Reply with quote

Try this more generic version mass join protection script.
It does not check for specific nicks/usernames...
Code:

## mass-join-protection.tcl v1.5.1 (25Feb2016) by SpiKe^^ ##


# Mass joins, kick-ban on joins:seconds #
set mjp(flood) 5:2

# Mass joins kick-ban reason #
set mjp(reasn) "Mass Join Flood!"

# Max number of bans to stack in one mode command #
set mjp(maxb) 6

# Length of time in minutes to ban mass join flooders #
# - set 0 to disable this script removing bans (ex. set mjp(btime) 0) #
set mjp(btime) 10

# After a valid mass join flood, script will continue #
# to kick-ban offenders for an additional 'x' seconds #
set mjp(xpire) 10

# Set the type of ban masks to use #
#  1 = use host/ip specific bans (ex. *!*@some.host.com) #
#  2 = use wide masked host/ip bans (ex. *!*@*.host.com) #
#      note: setting 2 requires eggdrop 1.6.20 or newer. #
set mjp(btype) 2

# Set protected host(s) that should not be wide masked #
# - Example:  set mjp(phost) "*.undernet.org"
#  Note: this setting only applies to ban type 2 above! #
#  Note: set empty to not protect any hosts (ex. set mjp(phost) "") #
#  Note: space separated if listing more than one protected host #
set mjp(phost) ""

# Set channel mode(s) on flood detected. #
# - set empty to disable setting channel modes (ex. set mjp(mode) "") #
set mjp(mode) "im"

# Remove these channel modes after how many seconds? #
set mjp(mrem) 20

# END OF SETTINGS # Don't edit below unless you know what you're doing #

bind join - * mjp_bindjoin

proc mjp_bindjoin {nick uhost hand chan} {
  global mjp mjpc mjpq

  if {[isbotnick $nick]} { return 0 }
  if {[matchattr $hand f|f $chan]} { return 0 }

  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set utnow [unixtime]
  set target [lindex $mjp(flood) 0]

  if {[info exists mjpc($chan)]} {
    set uhlist [lassign $mjpc($chan) cnt ut]
    set utend [expr {$ut + [lindex $mjp(flood) 1]}]
    set expire [expr {$utend + $mjp(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset mjpc($chan) }
    } elseif {$utnow > $expire} { unset mjpc($chan) }
  }
  if {![info exists mjpc($chan)]} {
    set mjpc($chan) [list 1 $utnow $uhost]
    return 0
  }

  incr cnt
  if {$cnt <= $target} {
    if {[lsearch $uhlist $uhost] == -1} { lappend uhlist $uhost }
    if {$cnt < $target} {
      set mjpc($chan) [linsert $uhlist 0 $cnt $ut]
    } else {
      set mjpc($chan) [list $cnt $ut]
      if {$mjp(mode) ne "" && [string is digit -strict $mjp(mrem)]} {
        putquick "MODE $chan +$mjp(mode)"
        utimer $mjp(mrem) [list putquick "MODE $chan -$mjp(mode)"]
      }
      mjp_dobans $chan $uhlist
    }
    return 0
  }

  if {![info exists mjpq($chan)]} {
    utimer 2 [list mjp_bque $chan]
    set mjpq($chan) [list $uhost]
  } elseif {[lsearch $mjpq($chan) $uhost] == -1} {
    lappend mjpq($chan) $uhost
  }

  if {[llength $mjpq($chan)] >= $mjp(maxb)} {
    mjp_dobans $chan $mjpq($chan)
    set mjpq($chan) ""
  } elseif {[botisop $chan]} { putquick "KICK $chan $nick :$mjp(reasn)" }
  return 0
}

proc mjp_dobans {chan uhlist} {
  global mjp
  if {![botisop $chan]} return
  set banList ""
  set nickList ""
  foreach ele $uhlist {
    scan $ele {%[^!]!%[^@]@%s} nick user host


    if {$mjp(btype) == 2} {
      set type 4

      foreach ph $mjp(phost) {
        if {[string match -nocase $ph $host]} {
          set type 2  ;  break
        }
      }

      set bmask [maskhost $ele $type]

    } else {  set bmask "*!*@$host"  }


    if {[lsearch $banList $bmask] == -1} { lappend banList $bmask }
    if {[lsearch $nickList $nick] == -1} { lappend nickList $nick }
  }
  stack_bans $chan $mjp(maxb) $banList
  foreach nk $nickList {
    if {[onchan $nk $chan]} { putquick "KICK $chan $nk :$mjp(reasn)" }
  }

  if {$mjp(btime) > 0} {
    set expire [expr {[unixtime] + $mjp(btime)}]
    lappend mjp(rmls) [list $expire $chan $banList]
  }
}

proc stack_bans {chan max banlist {opt +} } {
  set len [llength $banlist]
  while {$len > 0} {
    if {$len > $max} {
      set mode [string repeat "b" $max]
      set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
      set banlist [lrange $banlist $max end]
      incr len -$max
    } else {
      set mode [string repeat "b" $len]
      set masks [join $banlist]
      set len 0
    }
    putquick "MODE $chan ${opt}$mode $masks"
  }
}

proc mjp_bque {chan} {
  global mjpq
  if {![info exists mjpq($chan)]} { return }
  if {$mjpq($chan) eq ""} { unset mjpq($chan) ; return }
  mjp_dobans $chan $mjpq($chan)
  unset mjpq($chan)
}

proc mjp_breset {} {
  global mjpc mjp
  set utnow [unixtime]
  set target [lindex $mjp(flood) 0]
  foreach {key val} [array get mjpc] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $mjp(flood) 1]}]
    set expire [expr {$utend + $mjp(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset mjpc($key) }
    } elseif {$utnow > $expire} { unset mjpc($key) }
  }

  if {[info exists mjp(rmls)]} {
    while {[llength $mjp(rmls)]} {
      set next [lindex $mjp(rmls) 0]
      lassign $next expire chan banList
      if {$expire > $utnow} {  break  }
      set mjp(rmls) [lreplace $mjp(rmls) 0 0]
      if {![info exists rmAra($chan)]} {  set rmAra($chan) $banList
      } else {  set rmAra($chan) [concat $rmAra($chan) $banList]  }
    }
    foreach {key val} [array get rmAra] {
      set banList ""
      foreach mask $val {
        if {![ischanban $mask $key]} {  continue  }
        lappend banList $mask
      }
      if {$banList eq ""} {  continue  }
      if {![botisop $key]} {
        set mjp(rmls) [linsert $mjp(rmls) 0 [list $utnow $key $banList]]
      } else {  stack_bans $key $mjp(maxb) $banList -  }
    }
    if {![llength $mjp(rmls)]} {  unset mjp(rmls)  }
  }

  utimer 30 [list mjp_breset]
}

if {![info exists mjp_running]} {
  utimer 20 [list mjp_breset]
  set mjp_running 1
}

set mjp(flood) [split $mjp(flood) :]
set mjp(btime) [expr {$mjp(btime) * 60}]
set mjp(phost) [split [string trim $mjp(phost)]]
if {$mjp(btime)==0 && [info exists mjp(rmls)]} {  unset mjp(rmls)  }

putlog "Loaded mass-join-protection.tcl v1.5.1 by SpiKe^^"


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Thu Feb 25, 2016 3:31 pm    Post subject: Reply with quote

that works well tnx SpiKe^^
Back to top
View user's profile Send private message
gamble27
Halfop


Joined: 05 Aug 2008
Posts: 64

PostPosted: Fri Feb 26, 2016 1:57 pm    Post subject: Reply with quote

Does this exempt the netsplit users rejoining channel?
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Fri Feb 26, 2016 5:56 pm    Post subject: Reply with quote

No, this script does not try to "exempt the netsplit users rejoining channel"

I'm really not sure what would be the best plan to do such exempting.
I could use some advice on ways to pull this off, any suggestions would be much appreciated.
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Sat Feb 27, 2016 2:20 am    Post subject: Reply with quote

What's the logic behind a script to stop the join floods? Let's say 30 bots join and at the same time some innocent user. How do you differentiate between them? Or you simply just ban them all?

Won't a script that's setting an "active" channel limit put a foot on the neck of a botnet trying to join the channel and thus limit the damage?
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Sat Feb 27, 2016 2:39 am    Post subject: Reply with quote

Oh so true Caesar, on both of those points.
I would never run a mass join flood script on any of my channels.
There are other better ways of handling such problems.

I am just trying to build this script for the multiple requests...

gamble27: After more research, no further coding is required to "exempt the netsplit users rejoining channel".
Eggdrop already differentiates between joins and netsplit rejoins.
The amount of time Eggdrop waits for a user to netsplit rejoin is controlled by the Eggdrop config setting: wait-split
When using this script, or any join flood script, be sure to set wait-split to 600 seconds or larger than the longest split on your network.
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Sat Feb 27, 2016 9:55 am    Post subject: Reply with quote

most mass joins are done with botnets and depending on traffic one can adjust the config setting for it or/and make use of some sort of chanlimit and since bans are temporare innocent ones can rejoin anyway after bantime

if there are other ways of keeping botnets out im curious to know as i tested it in many configurations

regarding netsplit since netsplit shows in quit messages of the unlinked server one could use that to store with a timer and halt this script ( on detect in the quits script )

this is how i would do in an msl script i lack experience in tcl to convert

Code:
On !*:QUIT:{
  var %netsplit2 1
  while ($comchan($nick,%netsplit2)) {
    var %netsplitchan $v1
    if (*.*.* iswm $1) && (*.*.* iswm $2) && (!%Netsplit-Detected. [ $+ [ %netsplitchan ] $+ . $+ [ $network ] ])  {
      echo  %netsplitchan  $timestamp  Netsplit Detected between: $1  <-->  $2
      set -z %Netsplit-Detected. [ $+ [ %netsplitchan ] $+ . $+ [ $network ] ]  300
    }
    inc %netsplit2
  }
}

On !^*:JOIN:#: { if (%Netsplit-Detected. [ $+ [ $chan ] $+ . $+ [ $network ] ])   { halt  } }
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 502
Location: Tennessee, USA

PostPosted: Mon Feb 29, 2016 6:19 pm    Post subject: Reply with quote

I have a new setting and the new supporting code that needs testing please...

# Max number of kicks to stack in one kick command # <- NEW SETTING <-
# NOTE: many networks allow more than one nick to be kicked per command. #
# set this at or below the max for your network.

Code:

## mass-join-protection.tcl v1.6.1 (29Feb2016) by SpiKe^^ ##


# Mass joins, kick-ban on joins:seconds #
set mjp(flood) 5:2

# Mass joins kick-ban reason #
set mjp(reasn) "Mass Join Flood!"

# Max number of bans to stack in one mode command #
set mjp(maxb) 6

# Max number of kicks to stack in one kick command #          <- NEW SETTING <-
# NOTE: many networks allow more than one nick to be kicked per command. #
#       set this at or below the max for your network.
set mjp(maxk) 3

# Length of time in minutes to ban mass join flooders #
# - set 0 to disable this script removing bans (ex. set mjp(btime) 0) #
set mjp(btime) 10

# After a valid mass join flood, script will continue #
# to kick-ban offenders for an additional 'x' seconds #
set mjp(xpire) 10

# Set the type of ban masks to use #
#  1 = use host/ip specific bans (ex. *!*@some.host.com) #
#  2 = use wide masked host/ip bans (ex. *!*@*.host.com) #
#      note: setting 2 requires eggdrop 1.6.20 or newer. #
set mjp(btype) 2

# Set protected host(s) that should not be wide masked #
# - Example:  set mjp(phost) "*.undernet.org"
#  Note: this setting only applies to ban type 2 above! #
#  Note: set empty to not protect any hosts (ex. set mjp(phost) "") #
#  Note: space separated if listing more than one protected host #
set mjp(phost) ""

# Set channel mode(s) on flood detected. #
# - set empty to disable setting channel modes (ex. set mjp(mode) "") #
set mjp(mode) "im"

# Remove these channel modes after how many seconds? #
set mjp(mrem) 20

# END OF SETTINGS # Don't edit below unless you know what you're doing #

bind join - * mjp_bindjoin

proc mjp_bindjoin {nick uhost hand chan} {
  global mjp mjpc mjpq

  if {[isbotnick $nick]} { return 0 }
  if {[matchattr $hand f|f $chan]} { return 0 }

  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set utnow [unixtime]
  set target [lindex $mjp(flood) 0]

  if {[info exists mjpc($chan)]} {
    set uhlist [lassign $mjpc($chan) cnt ut]
    set utend [expr {$ut + [lindex $mjp(flood) 1]}]
    set expire [expr {$utend + $mjp(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset mjpc($chan) }
    } elseif {$utnow > $expire} { unset mjpc($chan) }
  }
  if {![info exists mjpc($chan)]} {
    set mjpc($chan) [list 1 $utnow $uhost]
    return 0
  }

  incr cnt
  if {$cnt <= $target} {
    if {[lsearch $uhlist $uhost] == -1} { lappend uhlist $uhost }
    if {$cnt < $target} {
      set mjpc($chan) [linsert $uhlist 0 $cnt $ut]
    } else {
      set mjpc($chan) [list $cnt $ut]
      if {$mjp(mode) ne "" && [string is digit -strict $mjp(mrem)]} {
        putquick "MODE $chan +$mjp(mode)"
        utimer $mjp(mrem) [list putquick "MODE $chan -$mjp(mode)"]
      }
      mjp_dobans $chan $uhlist
    }
    return 0
  }

  if {![info exists mjpq($chan)]} {
    utimer 2 [list mjp_bque $chan]
    set mjpq($chan) [list $uhost]
  } elseif {[lsearch $mjpq($chan) $uhost] == -1} {
    lappend mjpq($chan) $uhost
  }

  if {[llength $mjpq($chan)] >= $mjp(maxb)} {
    mjp_dobans $chan $mjpq($chan)
    set mjpq($chan) ""
  }

  return 0
}

proc mjp_dobans {chan uhlist} {
  global mjp
  if {![botisop $chan]} return
  set banList ""
  set nickList ""
  foreach ele $uhlist {
    scan $ele {%[^!]!%[^@]@%s} nick user host


    if {$mjp(btype) == 2} {
      set type 4

      foreach ph $mjp(phost) {
        if {[string match -nocase $ph $host]} {
          set type 2  ;  break
        }
      }

      set bmask [maskhost $ele $type]

    } else {  set bmask "*!*@$host"  }


    if {[lsearch $banList $bmask] == -1} { lappend banList $bmask }
    if {[lsearch $nickList $nick] == -1} { lappend nickList $nick }
  }
  stack_bans $chan $mjp(maxb) $banList

  # begin new kick code #
  foreach nk $nickList {
    if {[onchan $nk $chan]} {  lappend nkls $nk  } else { continue }
    if {[llength $nkls] == $mjp(maxk)} {
      putquick "KICK $chan [join $nkls ,] :$mjp(reasn)"
      unset nkls
    }
  }
  if {[info exists nkls]} {
    putquick "KICK $chan [join $nkls ,] :$mjp(reasn)"
  }
  # end new kick code #

  if {$mjp(btime) > 0} {
    set expire [expr {[unixtime] + $mjp(btime)}]
    lappend mjp(rmls) [list $expire $chan $banList]
  }
}

proc stack_bans {chan max banlist {opt +} } {
  set len [llength $banlist]
  while {$len > 0} {
    if {$len > $max} {
      set mode [string repeat "b" $max]
      set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
      set banlist [lrange $banlist $max end]
      incr len -$max
    } else {
      set mode [string repeat "b" $len]
      set masks [join $banlist]
      set len 0
    }
    putquick "MODE $chan ${opt}$mode $masks"
  }
}

proc mjp_bque {chan} {
  global mjpq
  if {![info exists mjpq($chan)]} { return }
  if {$mjpq($chan) eq ""} { unset mjpq($chan) ; return }
  mjp_dobans $chan $mjpq($chan)
  unset mjpq($chan)
}

proc mjp_breset {} {
  global mjpc mjp
  set utnow [unixtime]
  set target [lindex $mjp(flood) 0]
  foreach {key val} [array get mjpc] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $mjp(flood) 1]}]
    set expire [expr {$utend + $mjp(xpire)}]
    if {$cnt < $target} {
      if {$utnow > $utend} { unset mjpc($key) }
    } elseif {$utnow > $expire} { unset mjpc($key) }
  }

  if {[info exists mjp(rmls)]} {
    while {[llength $mjp(rmls)]} {
      set next [lindex $mjp(rmls) 0]
      lassign $next expire chan banList
      if {$expire > $utnow} {  break  }
      set mjp(rmls) [lreplace $mjp(rmls) 0 0]
      if {![info exists rmAra($chan)]} {  set rmAra($chan) $banList
      } else {  set rmAra($chan) [concat $rmAra($chan) $banList]  }
    }
    foreach {key val} [array get rmAra] {
      set banList ""
      foreach mask $val {
        if {![ischanban $mask $key]} {  continue  }
        lappend banList $mask
      }
      if {$banList eq ""} {  continue  }
      if {![botisop $key]} {
        set mjp(rmls) [linsert $mjp(rmls) 0 [list $utnow $key $banList]]
      } else {  stack_bans $key $mjp(maxb) $banList -  }
    }
    if {![llength $mjp(rmls)]} {  unset mjp(rmls)  }
  }

  utimer 30 [list mjp_breset]
}

if {![info exists mjp_running]} {
  utimer 20 [list mjp_breset]
  set mjp_running 1
}

set mjp(flood) [split $mjp(flood) :]
set mjp(btime) [expr {$mjp(btime) * 60}]
set mjp(phost) [split [string trim $mjp(phost)]]
if {$mjp(btime)==0 && [info exists mjp(rmls)]} {  unset mjp(rmls)  }

putlog "Loaded mass-join-protection.tcl v1.6.1 by SpiKe^^"


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
Back to top
View user's profile Send private message Visit poster's website
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Mon Feb 29, 2016 6:44 pm    Post subject: Reply with quote

tested it on testnet and it works like a charm insanely fast, once again excellent release SpiKe^^ thnx for the workz im sure it will benefit many if they are aware of it keep up the works
Back to top
View user's profile Send private message
Fahad
Halfop


Joined: 29 Aug 2016
Posts: 99

PostPosted: Sat Oct 22, 2016 1:24 am    Post subject: Bot should not unban after few secs Reply with quote

Bot should lock the channel untill flood stops and it should kickban not simple ban
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Sat Oct 22, 2016 10:41 am    Post subject: Re: Bot should not unban after few secs Reply with quote

fahadmehar wrote:
Bot should lock the channel untill flood stops and it should kickban not simple ban



it does both
Back to top
View user's profile Send private message
Fahad
Halfop


Joined: 29 Aug 2016
Posts: 99

PostPosted: Sat Dec 03, 2016 11:13 am    Post subject: Any New Version of this TCL ? Reply with quote

I am BIG FAN of this TCL - Very well written by Spike^^^

Any NEW Version coming ? From where I can get this TCL's?
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Sat Jan 14, 2017 5:33 am    Post subject: Reply with quote

i found this tcl from user for banmasks i was wondering if it could be integrated (and if so how) to achieve the banmask for the anti massjoin tcl to be in the form of :

http://forum.egghelp.org/viewtopic.php?t=8741&highlight=banmask


Code:
HOST -> *!*@some.host.here.net  *!*@*.here.net
IP -> *!*@1.2.3.4.5.6   *!*@1.2.3.4.5.*
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber