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 repeat from multi host/ip
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Mon Mar 23, 2015 6:58 pm    Post subject: Reply with quote

error is gone but still no effect
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3767
Location: Mint Factory

PostPosted: Tue Mar 24, 2015 3:02 am    Post subject: Reply with quote

Alright, corrected a few typos and rookie mistakes I've made in previous code. Now you need to get on DCC Chat to enable this for each individual channel with .chanset #channel +hashCheck

As always, haven't tested anything so report back if you get any issues.
Code:

namespace eval hashCheck {
   setudef flag hashCheck
   bind pubm - * [namespace current]::hashCheck
   set setup [dict create limit 3 time 10]
   
   proc hashCheck {nick uhost hand chan text} {
      if {![channel get $chan hashCheck]} return
      variable setup
      variable md5hashes
      set hash [md5 [split $text]]
      if {[info exists md5hashes]} {
         if {[lsearch [dict keys [dict get $md5hashes $chan] $hash] != -1} {
            set hosts [dict get $md5hashes $chan $hash]
            if {[llength $hosts] > [dict get $setup limit]} {
               hashPunish $chan $hosts
               dict unset md5hashes $chan $hash
            } else {
               dict set md5hashes $chan $hash [list [dict get $md5hashes $chan $hash] $uhost]
               utimer [dict get $setup time] [list [namespace current]::hashPurge $chan $hash $uhost]
            }
         }
      } else {
         dict set md5hashes $chan $hash $uhost
      }
   }
   
   proc hashPurge {chan hash uhost} {
      variable md5hashes
      set hosts [dict get $md5hashes $chan $hash]
      set pos [lsearch -nocase $hosts $uhost]
      if {$pos!=-1} {
         set hosts [lreplace $hosts $pos $pos]
         dict set md5hashes $chan $hash $hosts
      }
      foreach key [dict keys [dict get $md5hashes $chan]] {
         if {![llength [dict get $md5hashes $chan $key]]} {
            dict unset md5hashes $chan $key
         }
      }
   }
}

From here onwards will extend it to remove hashes upon kick, ban, quit, part, and so on. For now want to see if this is working or not.

Edit: Fixed typo.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Tue Mar 24, 2015 7:03 am; edited 1 time in total
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Tue Mar 24, 2015 4:28 am    Post subject: Reply with quote

after replacing it with your latest code it gives me this error
Quote:

09:26:36 <SeCuRiTy> [04:13:44] Tcl error [::hashCheck::hashCheck]: missing close-bracket
09:26:36 <SeCuRiTy> in expression "[lsearch [dict keys [di..."
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3767
Location: Mint Factory

PostPosted: Tue Mar 24, 2015 7:01 am    Post subject: Reply with quote

Replace:
Code:

if {[lsearch [dict keys [dict get $md5hashes $chan]] $hash != -1} {

with:
Code:

if {[lsearch [dict keys [dict get $md5hashes $clan]] $hash] != -1} {

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Tue Mar 24, 2015 7:06 am    Post subject: Reply with quote

after doing that it still doesnt trigger error is gone tho
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3767
Location: Mint Factory

PostPosted: Tue Mar 24, 2015 8:09 am    Post subject: Reply with quote

Got a testing bot up and running and realized that this isn't going to won't work as I hoped and found a couple of issues I'll try to correct.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Tue Mar 24, 2015 9:43 am    Post subject: Reply with quote

ok sir all your efforts are much apreciated
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Wed Mar 25, 2015 12:05 am    Post subject: Reply with quote

Her ya go, untested, good luck, let me know:)
Code:

# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>

# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 5:60

# Repeat flood kick-ban reason #
set rp_breason "repeat flood"

# Length of time in minutes to ban Repeat flooders #
set rp_btime 60

# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds    #
set rp_blinger 10

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

bind pubm - * rp_pubmsg

set rp_bflood [split $rp_bflood :]

proc rp_pubmsg {nick uhost hand chan text} {
  global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set text [string map [list \017 ""] [stripcodes abcgru $text]]
  set text [string tolower $text]
  if {[isbotnick $nick]} {  return 0  }
  if {[matchattr $hand f|f $chan]} {  return 0  }
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  if {[info exists rp_bcount($chan:$text)]} {
    set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($chan:$text)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($chan:$text)  }
  }

  if {![info exists rp_bcount($chan:$text)]} {
    set rp_bcount($chan:$text) [list 1 $utnow $uhost]
    return 0
  }

  if {$utnow <= $utend} {
    incr cnt
    if {[lsearch $uhlist $uhost] == "-1"} {  lappend uhlist $uhost  }
    set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
    if {$cnt < $target} {  return 0  }
    if {$cnt == $target} {  rp_dobans $chan $uhlist
    } else {  rp_dobans $chan [list $uhost]  }
  } elseif {$cnt >= $target} {  rp_dobans $chan [list $uhost]  }

  return 0
}

proc rp_dobans {chan uhlist} {
  global rp_breason rp_btime
  set hslist ""

  foreach uhost $uhlist {
    foreach {nk un hs} [split $uhost !@] { break }
    if {[botisop $chan] && [onchan $nk $chan]} {
      putserv "KICK $chan $nk :$rp_breason"
    }
    if {[lsearch $hslist $hs] == "-1"} {
      newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
      lappend hslist $hs
    }
  }
}

proc rp_breset {} {
  global rp_bcount rp_bflood rp_blinger
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  foreach {key val} [array get rp_bcount] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($key)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($key)  }
  }

  utimer 30 [list rp_breset]
}

if {![info exists rp_running]} {
  utimer 30 [list rp_breset]
  set rp_running 1
}

putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^"


_________________
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
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 4:06 am    Post subject: Reply with quote

it works excellent except it doesn't kick ban instant it takes time for it to ban and kick all text repeating flooding bots i would rather see it ban and kick instant and push as much mode settings in 1 line as possible other than that is works nicely good job sir
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 4:10 am    Post subject: Reply with quote

oh i forgot to mention i also would like it not to stickban just regular ban so the channel ops can remove if they see fit

tnx
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 4:34 am    Post subject: Reply with quote

this is what i have so far seems to work only it doesnt compress ban modes it does each ban seperate also when this type of flood accures how would we integrate for it also to lock channel for set amount of time
Code:

# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>

# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 2:10

# Repeat flood kick-ban reason #
set rp_breason "repeat flood"

# Length of time in minutes to ban Repeat flooders #
set rp_btime 1

# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds    #
set rp_blinger 10

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

bind pubm - * rp_pubmsg

set rp_bflood [split $rp_bflood :]

proc rp_pubmsg {nick uhost hand chan text} {
  global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set text [string map [list \017 ""] [stripcodes abcgru $text]]
  set text [string tolower $text]
  if {[isbotnick $nick]} {  return 0  }
  if {[matchattr $hand f|f $chan]} {  return 0  }
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  if {[info exists rp_bcount($chan:$text)]} {
    set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($chan:$text)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($chan:$text)  }
  }

  if {![info exists rp_bcount($chan:$text)]} {
    set rp_bcount($chan:$text) [list 1 $utnow $uhost]
    return 0
  }

  if {$utnow <= $utend} {
    incr cnt
    if {[lsearch $uhlist $uhost] == "-1"} {  lappend uhlist $uhost  }
    set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
    if {$cnt < $target} {  return 0  }
    if {$cnt == $target} {  rp_dobans $chan $uhlist
    } else {  rp_dobans $chan [list $uhost]  }
  } elseif {$cnt >= $target} {  rp_dobans $chan [list $uhost]  }

  return 0
}

proc rp_dobans {chan uhlist} {
  global rp_breason rp_btime
  set hslist ""

  foreach uhost $uhlist {
    foreach {nk un hs} [split $uhost !@] { break }
    if {[botisop $chan] && [onchan $nk $chan]} {
      putserv "KICK $chan $nk :$rp_breason"
    }
    if {[lsearch $hslist $hs] == "-1"} {
            putquick "MODE $chan +b *!*@$hs"
#     newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
      lappend hslist $hs
    }
  }
}

proc rp_breset {} {
  global rp_bcount rp_bflood rp_blinger
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  foreach {key val} [array get rp_bcount] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($key)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($key)  }
  }

  utimer 30 [list rp_breset]
}

if {![info exists rp_running]} {
  utimer 30 [list rp_breset]
  set rp_running 1
}

putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^"
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 4:44 am    Post subject: Reply with quote

i noticed it kicks first then it bans i would like it to see set ban first so they wont get choice to quik rejoin
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 6:22 am    Post subject: Reply with quote

also i noticed it doesnt excempt halfop and above from beeing effected
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3767
Location: Mint Factory

PostPosted: Wed Mar 25, 2015 6:24 am    Post subject: Reply with quote

Ahh, I see SpiKe beat me to the punch. Very Happy

To be honest I would stick with hashing the texts rather than having to strip them out and so on.

You should take out
Code:

# if the bot isn't OP then no point into continuing
    if {[botisop $chan] && [onchan $nk $chan]} {
      putserv "KICK $chan $nk :$rp_breason"
    }

from the foreach loop. As for multiple kicks/bans in a single line I think this should do it.
Code:

proc rp_dobans {chan uhlist} {
   # if the bot isn't OP there's no point to continue
   if {![botisop $chan]} return
   set blist ""
   set klist ""

   # loop through uhosts
   foreach uhost $uhlist {

      # filter out any duplicates
      if {[lsearch $blist $uhost] != -1} continue

      # set the ban mask as you want
      scan $uhost {%[^@]@%s} user host

      # save the list with masks to ban
      lappend blist "*!*@$host"

      # save the list with masks to get nicks from later on cos we will destroy the $blist
      lappend klist $uhost
   }

   # push 6 ban masks (or change to match how many bans per line the server you are on allows) at a time until the list is empty
   while {[llength $blist] != 0} {
      puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]"
      set blist [lrange $blist 6 end]
   }
      
   # from the given uhosts we ban make a list of nicks to kick and again filter out duplicates
   set nlist ""
   set userlist [lreplace [chanlist $chan] 0 0]
   foreach u [split $userlist] {
      set uhost [getchanhost $user $chan]
      scan $uhost {%[^@]@%s} user host
      if {[lsearch $klist $uhost] != -1} continue
      lappend nlist $u
   }

   # use putkick to do 6 kicks per a single line sent to server
   while {[llength $nlist] != 0} {
      putkick $chan [join [lrange $nlist 0 6] ","] "repeat flood"
      set nlist [lrange $nlist 6 end]
   }
}

Haven't tested anything. Razz

Edit: Fixed missing variable.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Wed Mar 25, 2015 9:04 am; edited 1 time in total
Back to top
View user's profile Send private message
simo
Revered One


Joined: 22 Mar 2015
Posts: 1027

PostPosted: Wed Mar 25, 2015 8:20 am    Post subject: Reply with quote

after changint that i get this error

Quote:

13:18:42 <SeCuRiTy> [08:05:48] Tcl error [rp_pubmsg]: illegal channel: ChanServ,AmaziGH,Lilli,Avila,Orourke,Rima,Oglesby
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 Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 2 of 8

 
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