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 

Detecting identical nicks within time frame
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sat Nov 20, 2021 12:27 pm    Post subject: Detecting identical nicks within time frame Reply with quote

greetz gentz,

i was messing with an msl code to detect identical nicks joining and if threshold of 2 is reached to start kicking and banning :

Quote:

17:23:05 Join: Dronedchpeekvq [ident: Mibbit] *!*@cloaked-ux3.w8z.052.145.IP
17:23:05 Join: Dronedmosktlukhp [ident: Mibbit] *!*@cloaked-zlo.fp5.405.511.IP
17:23:05 Join: Dronedfdlplkl [ident: Mibbit] *!*@cloaked-viy.7y5.823.453.IP
17:23:05 Join: Dronedrcua [ident: Mibbit] *!*@cloaked-de5.712.436.528.IP
17:23:05 Join: Dronedjhphd [ident: Mibbit] *!*@cloaked-jyt.3el.520.282.IP
17:23:06 +Simo Sets Mode on #test to: +bbbb *!*@*.fp5.405.511.IP *!*@*.7y5.823.453.IP *!*@*.712.436.528.IP *!*@*.3el.520.282.IP


unfortunatly i didnt find a way to also include the first nick (Dronedchpeekvq) that was the start of the counted idendtical nicks



this is the msl version i wondered if it could be translated into tcl :



Code:

On !^*:JOIN:#: {
  if ($nick(#,$me,@&~%)) { 
    var %clonednicks.flood = $+($left($nick,5),*!*@*)
    if (%clonesjoin. [ $+ [ # ] $+ . $+ [ %clonednicks.flood ] ] == $null) {
      set -u3 %clonesjoin. [ $+ [ # ] $+ . $+ [ %clonednicks.flood ] ] 1       
    }
    else { inc %clonesjoin. [ $+ [ # ] $+ . $+ [ %clonednicks.flood ] ] }
    if (%clonesjoin. [ $+ [ # ] $+ . $+ [ %clonednicks.flood ] ] > 1) {
      set -u3 %clnicks1 $addtok(%clnicks1,$nick,44)
      putmode $chan +b $mask($fulladdress,4) 

      if (%modechan1MR != $true) {
        .raw mode  $chan +MRb  %clonednicks.flood   
        set -u15 %modechan1MR $true
        .timermjs1RM 1 30 mode $unsafe($chan) -MR
      }
      if ($nick(#,$me,@%&~)) { var %mcln 4 | while (%clnicks1) { kick $chan $gettok(%clnicks1,1- %mcln,44) Cloned Nicks )  Detected | %clnicks1 = $deltok(%clnicks1,1- %mcln,44) } }
    } 
  }



what this basically does is: if 2 or more identical first 5 chars match after 2 or more nicks join within threshold of 3 sec it starts sending out bans and kicks for matching nicks
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 21, 2021 10:22 am    Post subject: Reply with quote

sometimes they come with 2 or 3 nicks so using mass join tcl wich already exists isnt optional as that would trigger to quick

i cant find a way to store and increase if it matches the patern

this is what i have so far:

Code:

bind join - * join:clonednicks
proc join:clonednicks {nick uhost hand chan} {
       set clonednicks  [string range $nick 0 4]

}
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Nov 21, 2021 11:47 am    Post subject: Reply with quote

Small script, untested:
Code:
bind join - * join:clonednicks

set joindelay 3

proc join:clonednicks {nick uhost hand chan} {
   set vict [string range [string tolower $nick] 0 4]
   if {![info exists ::clonednicks($vict)] || $::clonednicks($vict)<1} {
      set ::clonednicks($vict) 1
   } else {
      incr ::clonednicks($vict) 1
   }
   utimer $::joindelay [list incr ::clonednicks($vict) -1]
   if {$::clonednicks($vict) >= 2} {
      pushmode $chan +b ${vict}*!*@*
      foreach $kvict [chanlist $chan] {
         if {[string match -nocase ${vict}* $kvict]} {
            putkick $chan $kvict "1 is enough, go out"
         }
      }
   }
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 21, 2021 1:33 pm    Post subject: Reply with quote

thanks CC i tried your posted code it seems a bit slow sending out the kicks and
bans tho

i tried this to stack the bans and kicks but it didnt seem to be any faster

Code:


bind join - * join:clonednicks

set joindelay 3

proc join:clonednicks {nick uhost hand chan} {

   set umasks [list]
   set knicks [list]

   set vict [string range [string tolower $nick] 0 4]
   if {![info exists ::clonednicks($vict)] || $::clonednicks($vict)<1} {
      set ::clonednicks($vict) 1
   } else {
      incr ::clonednicks($vict) 1
   }
   utimer $::joindelay [list incr ::clonednicks($vict) -1]
   if {$::clonednicks($vict) >= 2} {
       lock:chan $chan
       lappend umasks *!*@[lindex [split $uhost @] 1]
 
      foreach kvict [chanlist $chan] {
         if {[string match -nocase ${vict}* $kvict]} {
        lappend knicks $kvict     
         }
      }
   }
                  if {[info exists umasks]} {  stackBans3z $chan $umasks }
                  if {[info exists knicks]} {  stackKicks $chan $knicks "!!! Indentical nicks !!!" }

}

proc stackBans3z {chan banlist {max 10}} {
      set count [llength $banlist]
      while {$count > 0} {
         if {$count> $max} {
            set mode [string repeat "b" $max]
            set masks [join [lrange $banlist 0 [expr {$max - 1}]]]
            set banlist [lrange $banlist $max end]
            incr count -$max
         } else {
            set mode [string repeat "b" $count]
            set masks [join $banlist]
            set count 0
         }
        putnow "MODE $chan +$mode $masks"
      }
   }

proc stackKicks {chan kicklist reason {max 4}} {
      set count [llength $kicklist]
      while {$count > 0} {
         if {$count > $max} {
            set users [join [lrange $kicklist 0 [expr {$max - 1}]] ","]
            set kicklist [lrange $kicklist $max end]
            incr count -$max
         } else {
            set users [join $kicklist ","]
            set count 0
         }
         putnow "KICK $chan $users $reason"
      }
   }



proc lock:chan {chan} {
  global botnick chan_flooded

  if {![info exists chan_flooded($chan)]} {
    set chan_flooded($chan) 1
    putquick "MODE $chan +Rb ${vict}*!*@*"
    utimer 5 "putquick \"MODE $chan -R\""
    utimer 5 [list unset -nocomplain chan_flooded($chan)]
    #unset clonednick
  }
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Sun Nov 21, 2021 4:54 pm    Post subject: Reply with quote

i will poke at it some more to see if i can get it to work as desired
thanks CC much apreciated
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Nov 22, 2021 10:07 am    Post subject: Reply with quote

If the ban is too slow, you can try replace the ban line:
Code:
pushmode $chan +b ${vict}*!*@*

with the putquick command:
Code:
putquick "MODE $chan +b ${vict}*!*@*"


Concerning kicks, it depends on the chanlist size, but you can also use a putquick rather than a putkick.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Nov 22, 2021 10:32 am    Post subject: Reply with quote

thanks CC for your response but that would send each kicks and bans as a single command while the ircd allows stacked kicks and bans

perhaps it would be possible to send the bans and kicks after the +R has been set to make sure it halts incoming nicks for a moment so bans and kicks can be send in stacked packet
wich will make it less spammy and less chances of gettin disconnected for too many commands sent
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Mon Nov 22, 2021 10:04 pm    Post subject: Reply with quote

CrazyCat wrote:
If the ban is too slow, you can try replace the ban line:
Code:
pushmode $chan +b ${vict}*!*@*

with the putquick command:
Code:
putquick "MODE $chan +b ${vict}*!*@*"


Concerning kicks, it depends on the chanlist size, but you can also use a putquick rather than a putkick.


It needs to actually set bans on the hosts as well as the patern
and masskick out the identical nicks
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Nov 23, 2021 3:50 am    Post subject: Reply with quote

Here is the way to ban on the host:
Code:
bind join - * join:clonednicks

set joindelay 3

proc join:clonednicks {nick uhost hand chan} {
   set vict [string range [string tolower $nick] 0 4]
   if {![info exists ::clonednicks($vict)] || $::clonednicks($vict)<1} {
      set ::clonednicks($vict) 1
   } else {
      incr ::clonednicks($vict) 1
   }
   utimer $::joindelay [list incr ::clonednicks($vict) -1]
   if {$::clonednicks($vict) >= 2} {
      foreach $kvict [chanlist $chan] {
         if {[string match -nocase ${vict}* $kvict]} {
            set khost [lindex [split [getchanhost $kvict $chan] @] 1]
            pushmode $chan +b *!*@$khost
            putkick $chan $kvict "1 is enough, go out"
         }
      }
      flushmode $chan
   }
}


Note 1 : this will slow the ban because you have to loop on chanlist to get all the corresponding hosts
Note 2 : no need to create a "stack" proc as eggdrop may manage the modes added with pushmode and stack them (have a look on pushmode and flushmode documentation)
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Nov 23, 2021 9:45 am    Post subject: Reply with quote

thanks CC i tried that code and it seems to set ban on eggdrop as well if rejoining channel and it still seems slow to execute bans and kicks i was hoping there was a way to stack bans and kicks and send in 1 go in packets of 4 kicks and 6 modes at a time

i was hoping we could utilize channel mode +R to have it send the bans and kicks after +R has been set this should make sure it has enough time to stack all the bans and kicks and bans to send in 1 or 2 go's

because for the moment even pusmode doesn't have enough time to stack the bans
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Tue Nov 23, 2021 9:58 am    Post subject: Reply with quote

rem out the flushmode line
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Nov 23, 2021 10:23 am    Post subject: Reply with quote

You can't stack kicks, you're forced to send them one per one.

Imho, the better thing to do to avoid mass-join is to use an autolimit script, have a look on http://tclarchive.org/search.php?str=limit
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Nov 23, 2021 12:35 pm    Post subject: Reply with quote

SpiKe^^ wrote:
rem out the flushmode line


i did just that and it took a while for it to gather it

i used your custom qkick code to gather all the kicks and stack as much as possible that seems to work somewhat better but did take quite a while to get them all when i stress tested

your anti mass join tcl had a special method in it sent out the kicks and bans after a +R wich is much more effective when gathering nicks in mass to kick and ban not sure if we could aply that here as well


Last edited by simo on Tue Nov 23, 2021 12:48 pm; edited 2 times in total
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Tue Nov 23, 2021 12:37 pm    Post subject: Reply with quote

CrazyCat wrote:
You can't stack kicks, you're forced to send them one per one.

Imho, the better thing to do to avoid mass-join is to use an autolimit script, have a look on http://tclarchive.org/search.php?str=limit



auto limit wont do much like for example on dalnet autolimit doesnt do much as abusers just mass join/part without the autolimit being much of use
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Wed Nov 24, 2021 11:50 am    Post subject: clonednicks.tcl ver 0.1 by SpiKe^^ Reply with quote

untested. goodluck.

Code:

#### clonednicks.tcl ver 0.1 by SpiKe^^ (24Nov2021) ####


bind join - * join:clonednicks

proc join:clonednicks {nick uhost hand chan} {
  global cnicks cnickq

  if {[isbotnick $nick] || ([string length $nick] < 6)} { return 0 }
  if {[matchattr $hand f|f $chan]} { return 0 }

  set chan [string tolower $chan]
  set key [string tolower [string range $nick 0 4]]
  set now [clock milliseconds]

  if {[info exists cnicks(${key},$chan)]} {
    ## just expire any old entries ##
    set old [expr {$now - (3 * 1000)}]
    set newls [list]
    foreach joined $cnicks(${key},$chan) {
      if {[lindex [split $joined ","] 1] > $old} { lappend newls $joined }
    }
    if {![llength $newls]} {  unset cnicks(${key},$chan)
    } else {  set cnicks(${key},$chan) $newls  }
  }
  if {![info exists cnicks(${key},$chan)]} {
    set cnicks(${key},$chan) [list "0,${now},${nick}!$uhost"]
    return 0
  }

  if {![info exists cnickq($chan)]} {
    after 1000 [list dobans:clonednicks $chan]
  }
  if {[string match "0,*" [set first [lindex $cnicks(${key},$chan) 0]]]} {
    set cnicks(${key},$chan) [list "1,[string range $first 2 end]"]
    lappend cnickq($chan) [lindex [split $first ","] 2]
  }

  lappend cnicks(${key},$chan) "1,${now},${nick}!$uhost"
  lappend cnickq($chan) "${nick}!$uhost"
  return 0
}


proc dobans:clonednicks {chan} {
  global cnickq

  if {![info exists cnickq($chan)]} { return 0 }
  if {![llength $cnickq($chan)] || ![botisop $chan]} {
    unset cnickq($chan)  ;  return 0
  }

  set bmasks [list]  ;  set knicks [list]
  foreach nkuhost $cnickq($chan) {
    lassign [split $nkuhost "!@"] n u h
    lappend knicks $n
    lappend bmasks *!*@$h
  }

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

  set max 4
  while {[set len [llength $knicks]] > 0} {
    if {$len > $max} {
      set nicks [join [lrange $knicks 0 [expr {$max - 1}]] ","]
      set knicks [lrange $knicks $max end]
    } else {
      set nicks [join $knicks ","]
      set knicks ""
    }
    ##putserv "KICK $ch $nicks :!!! Indentical nicks !!!"
    putserv "KICK $chan $nicks :!!! Indentical nicks !!!"

  }

  unset cnickq($chan)  ;  return 0
}


bind cron - {*/10 * * * *} cleanup:clonednicks

proc cleanup:clonednicks {mn hr da mo wd} {
  global cnicks
  set old [expr {[clock milliseconds] - (3 * 1000)}]

  foreach {key val} [array get cnicks] {
    set newls [list]
    foreach joined $val {
      if {[lindex [split $joined ","] 1] > $old} { lappend newls $joined }
    }
    if {![llength $newls]} {  unset cnicks($key)
    } else {  set cnicks($key) $newls  }
  }
}

putlog "clonednicks.tcl ver 0.1 by SpiKe^^ Loaded."




FIXED a variable naming issue from some reused code in proc dobans:clonednicks
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.


Last edited by SpiKe^^ on Thu Nov 25, 2021 12:12 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
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, 3  Next
Page 1 of 3

 
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