Clone detection from By-Tor bind join clone_detect bind rejn clone_det

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#Clone detection from By-Tor
bind join - * clone_detect
bind rejn - * clone_detect
bind part - * clone_remove
bind sign - * clone_quit
bind kick - * clone_kick
bind dcc m clones clone_stats
set maxclone 1
proc set_clones { } {
global clonelist botnick maxclone
if [array exists clonelist] { unset clonelist }
foreach chan [channels] {
set chan [string tolower $chan]
foreach nick [chanlist $chan] {
scan [getchanhost $nick $chan] "%\[^@]@%s" host host
set host [string tolower $host]
if [info exists clonelist($chan!$host)] {
incr clonelist($chan!$host) 1
if {$clonelist($chan!$host) >= $maxclone} {
newchanban $chan "*!*@$host" $botnick "Clones \($clonelist($chan!$host)\)"
putserv "kick $chan $nick :Too many clones from $host"
putloglev 1 * "Max clones \($maxclone\) exceeded by $nick in $chan \($clonelist($chan!$host) clones\)"
}
continue
}
set clonelist($chan!$host) 0
if {$nick == $botnick} {unset clonelist($chan!$host)}
if [matchattr [nick2hand $nick $chan] b] {if [info exists clonelist($chan!$host)] {unset clonelist($chan!$host)}}
if [matchattr [nick2hand $nick $chan] m] {unset clonelist($chan!$host)}
}
}
}
set_clones
timer 1 set_clones
proc clone_detect { nick uhost hand chan } {
global clonelist maxclone botnick
set chan [string tolower $chan]
if {$nick == $botnick} {return 0}
if [matchattr $hand m] {return 0}
if [matchattr $hand b] {return 0}
scan $uhost "%\[^@]@%s" host host
if [info exists clonelist($chan!$host)] {
incr clonelist($chan!$host) 1
if {$clonelist($chan!$host) >= $maxclone} {
newchanban $chan "*!*@$host" $botnick "Clones \($clonelist($chan!$host)\)"
putserv "kick $chan $nick :Too many clones from $host"
putlog "Max clones \($maxclone\) exceeded by $nick in $chan \($clonelist($chan!$host) clones\)"
return 1
}
putloglev 1 * "Clone detected \($clonelist($chan!$host) total\): $chan $nick!$uhost"
return 1
}
set clonelist($chan!$host) 0
return 0
}
proc clone_remove { nick uhost hand chan } {
global clonelist botnick
set uhost [string tolower $uhost]
set chan [string tolower $chan]
if {$nick == $botnick} {return 0}
if [matchattr $hand m] {return 0}
if [matchattr $hand b] {return 0}
scan $uhost "%\[^@]@%s" host host
if [info exists clonelist($chan!$host)] {
if {$clonelist($chan!$host) < 0} {
putloglev 1 * "Negative number of clones listed?? Something is wrong with the script!"
return 0
} elseif {$clonelist($chan!$host) == 0} {
catch {unset clonelist($chan!$host)}
return 1
} elseif {$clonelist($chan!$host) > 0} {
incr clonelist($chan!$host) -1
putloglev 1 * "Clone parts \($clonelist($chan!$host) remaining\) in $chan: $nick!$uhost"
return 1
}
}
}
proc clone_kick { nick host hand chan knick rest } {
clone_remove $knick [getchanhost $knick $chan] [nick2hand $knick $chan] $chan
}
proc clone_quit { nick host hand chan rest } {
clone_remove $nick $host $hand $chan
}
proc clone_stats { hand idx args } {
global clonelist
regsub -nocase -all \[{}] $args "" args
if {$args == ""} {
putdcc $idx "Usage: clones <channel>"
return 0
}
putdcc $idx "Getting clones for [lindex $args 0]..."
foreach addy [array names clonelist] {
if {$clonelist($addy) > 0} {
scan $addy "%\[^!]!%s" chan host
if {$chan != [string tolower [lindex $args 0]]} { continue }
putdcc $idx "$host: $clonelist($addy)"
}
}
return 1
}
putlog "Clone detection 1.3 by \002By-Tor\002 loaded..."
putlog "To view clone tracking, set console +1"