If you have a suggestion let me know.
To run this script you need mytools.tcl, i wll create a new post for better overview.
Code: Select all
###################################################################################################################################
# antitrojan.tcl infos #
###################################################################################################################################
# -+--+--+--+--+--+
# copyright:
# -+--+--+--+--+--+
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# antitrojan.tcl version 0.1 - by sKy\ - #Apache-root @ irc.quakenet.org
# Remember removing copyright is lame...
# this script is based on: (proc trojan:meltdown)
#################################################################
# Meltdowns NickChecker V0.1 (25-09-2004) #
# Contact: meltdown@gmx.at | #meltdown on quakenet #
# http://scripts.udp.at #
# [! LEAVE THESE CREDITS INTACT. !] thx... #
#################################################################
# without his great code i got no idea "how to detect random"
# thanks :)
# -+--+--+--+--+--+
# end copyright:
# -+--+--+--+--+--+
# Read this infos, else the script won`t work. :p
# If you are not able to read this little doc
# i will not help you.
# does a /whois 1 $nickname on every user which joins your channel
# if something seems like a spam bot some score will be added
# rather, if score is to high the user will be banned on each channel the script is active
# script has a floodprotection which means join/part flood won`t hurt.
# people which are allready in the global or channel banlist will not been whoised.
# !!!
# this scripts need mytools.tcl version 0.6 or above !
# without mytools.tcl the bot will only spamm your partylne with errors (load it before loading this script.)
# get it at forum www.egghelp.org (own website comming soon)
# !!!
# add to your config
# source scripts/antitrojan.tcl
# rehash your bot, script should work
# .chanset #yourchannel +antitrojan <- turn on
# .chanset #yourchannel -antitrojan <- turn off
# script is currenty a beta version, which means there can be some bugs inside
# If something goes wrong, do not bother me!
# But if you found bugs or have any usefull suggestions please tell me.
# I need your feedback.
# To contact me write a private message to me on irc or write an pm
# to me on www.egghelp.org userforum
# script has a debug mode... you can turn off kick/bans and you see everything on paryline via putlogs
# might be useful if you want first configure the script and look which one will be kicked in the furtre if you turn on kickfuntion
# people which are banned can unban hisself with:
# /msg botnick removeme
# them will be added to a user called nofloodbot
# .+host nofloodbot *!*@whatever.org on that way you can extempt users by hand too
# error rate should be less then 2-5%
# the script does not listen for private spam to the bot (via privmsg/notice/...)
# get another script therefore
# Sure you can edit the source to your own needs, but if something goes wrong don`t ask me.
# Please do not modify the script and say you have done a "better" version.
# If you want a to create a better version make your own one!
# At least, i hope you think this script is useful.
# Have fun and enjoy.
###################################################################################################################################
# antitrojan.tcl configuration #
###################################################################################################################################
###############
# - Detection
###############
# any of the channels the bot is on, must be valid
set trojan_testchan "#Apache-root"
# if the nickname + ident consits only big letters this score will be added
set trojan_only_big 10
# if more then .. digits inside the nick
set digits_in_nickname 4
# or more then .. digtis in ident
set digits_in_ident 4
# then this points will be added
set trojan_digit_nickname 10
# then this points will be added
set trojan_digit_ident 10
# if realname is random then this points will be added
set trojan_random_realname 30
# if realname filed with color then this points will be added(not often used on quakenet)
set trojan_realname_with_color 0
# all colors (for realname/away check)
set trojan_colors " "
# all badwords (for realname/away check)
set trojan_badwords "# www decode http"
# if authname is random then this points will be added (not often used on quakenet)
set trojan_random_authname 0
# if badword inside away msg (not often used on quakenet)
set trojan_away_with_badword 0
# if a badword is inside the realname (not often used on quakenet)
set trojan_realname_with_badword 0
# if away msg is random text (not often used on quakenet)
set trojan_random_away 0
# if away msg is colored (not often used on quakenet)
set trojan_away_with_color 0
# the time the user should idle
set trojan_idletime 30
# if less them that time then this points will be added
set trojan_less_idle 0
# if trojan has this status in any channel points will be decrased
set trojan_status_op 3
set trojan_status_voice 2
set trojan_status_regular 2
set trojan_status_delayed 2
# if user is in less then chans:
set trojan_minimum_chans 4
# score + this points if to less chans
set trojan_to_less_chans 10
# if nick consits this it will not be a trojan (user extempt), you can set to "" too.
set trojan_goodwords "bnc off et cs play game zzz"
# if nickname is random
set trojan_random_nickname 30
# if ident is random
set trojan_random_ident 20
#############################
# - Remove from trojan list
#############################
# comment this line with a # at start if you don`t want people able to remove hisself from banlist
# for sure it will not remove people which are banned with other reason... don`t unbind if you don`t like unless privmsgs :)
bind msg - removeme trojan:msg:removeme
######################
# - Kick/Ban options
######################
# kickmsg:
# trojanbot <- this word is important. if a user /msg botnick removeme - then the bot will remove matching global or channel bans if this word is inside the kickreason
# which means, let this word inside the kickmsg... you can change it, but then change it in the code below to
# search for #1 and #2 markes if you want change it. if you don`t know, just let this word inside the kickmsg
# variables are :id: :points: :botnick:
# if you want to use { } / \ [ ] $ " inside the kickmsg, you have to escape them which means you have to write
# not only ] --> \] ....
set trojan_kick_reason "1..:: Reason: detected as trojanbot :: If you arn`t floodbot, you can rejoin. :: And please type: /msg :botnick: removeme 1 :: badpoints: :points: :: ID: :id: ::.."
# maximum badpoints, if more -> ban
set trojan_max_points 11
# ban trojan? 1 yes, 0 no
# ban will not expire, op`s can remove them. be ensure that you use a scripts which controll the banlistlenght
set trojan_ban 1
# kick trojan? 1 yes, 0 no
set trojan_kick 1
# use newchanban? useful to get clones off the spammbot outside too.
set trojan_newchanban 0
# the bantime if you use newchanban, something between 1 - 1440 will be useful
# 1440 min = 1 day and those bots change mosttimes ip after 1 day
set trojan_newchan_bantime 10
# use global bans? 0 no, 1 yes. 0 suggested
set trojan_newban 0
# global bantime in min
set trojan_newban_bantime 1
###################
# - Debug options
###################
# show on partyline who will be banned or kicked? 1 yes, 0 no
set trojan_debugmode 1
# show many putlogs for debuging...
set ::trojan_debug_mode 1
# how long a user is stored as authed
set authed_time 60
# how long a user is stored as away
set away_time 60
# in minutes how long a nick is a ircop
set ircop_time 1400
# minutes before the bot will do a whois again
# join/part floods won`t hurt if you don`t decrase
set trojan_floodprot 5
###################################################################################################################################
# less channels (alpha) #
###################################################################################################################################
# .chanset #yourchannel +less_channels
# .chanset #yourchannel -less_channels
# .chanset #yourchannel min_channel 5
# or whatever
set to_less_channels_reason "You are in to less channels."
setudef flag less_channels
setudef str min_channels
proc lesschannel { nickname count_chans } {
global botnick to_less_channels_reason
set botnic [string tolower $botnick]
set nickname [string tolower $nickname]
if { $nickname == $botnic } { return }
foreach channel [channels] {
if { ! [validchan $channel] } { continue }
if { ! [isop $botnick $channel] } { continue }
if { ! [channel get $channel less_channels] } { continue }
if { [onchan $nickname $channel] } { continue }
set host [getchanhost $nickname]
set BUZAin "trojankeepout!$host"
set hostname [get:ban:mask $BUZAin]
if { [string match -nocase "*.users.quakenet.org*" $hostname] } { continue }
set fullhost "$nickname!$hostname"
set handle [finduser $fullhost]
if { [matchattr handle mnofvI|mnofvI $channel] } { continue }
if { [string equal -nocase $handle "nofloodbot"] } { return }
set min_channels [channel get $channel min_channels]
if { $min_channels == "" } {
continue
}
if { $min_channels == 1 } {
continue
}
if { $min_channels == 2 } {
continue
}
if { $min_channels < $count_chans } { return }
put:quick $channel +b $hostname
kick:user $channel $nickname $to_less_channels_reason
flood:detect $channel
}
}
###################################################################################################################################
# trojan bind nick #
###################################################################################################################################
# bind nick - * trojan:nickchange
proc trojan:nickchange { nickname hostname handle channel newnick } {
if { ! [validchan $channel] } { return }
global botnick
if { $nickname == $botnick } { return }
if { $newnick == $botnick } { return }
set nickname $newnick
trojan:join $nickname $hostname $handle $channel
}
###################################################################################################################################
# trojan test join #
###################################################################################################################################
proc trojan:test { nickname } {
global trojan_testchan
set hostname "x@y"
set handle "*"
trojan:join $nickname $hostname $handle $trojan_testchan
}
###################################################################################################################################
# trojan join #
###################################################################################################################################
setudef flag antitrojan
# bind join - * trojan:join
proc trojan:join { nickname hostname handle channel } {
if { ! [channel get $channel antitrojan] } { return }
global botnick
set botnic [string tolower $botnick]
set nickname [string tolower $nickname]
if { $nickname == $botnic } { return }
set nickname [string tolower $nickname]
global trojan_random_nickname trojan_random_ident trojan_goodwords trojan_floodprot
if { [matchattr handle mnofvI|mnofvI $channel] } { return }
if { ! [validchan $channel] } { return }
if { [string equal -nocase $handle "nofloodbot"] } {
if { $::trojan_debug_mode } {
putlog "trojan:join: $nickname -- $hostname -- $channel -- nofloodbot"
}
return
}
if { [string match -nocase "*.users.quakenet.org*" $hostname] } { return }
if { [isban $hostname $channel] } { return }
if { [isban $hostname] } { return }
if { $trojan_goodwords != "" } {
foreach nobadword $trojan_goodwords {
if { [string match -nocase $nobadword $nickname] } {
return
}
}
}
set ident [lindex [split $hostname "@"] 0]
set BUZAout $hostname
if { [info exists ::trojandns($BUZAout) ] } { return }
if { ! [info exists ::trojandns($BUZAout) ] } {
set ::trojandns($BUZAout) 1
timer $trojan_floodprot [list unset ::trojandns($BUZAout)]
}
if { [info exists ::trojan_points($nickname) ] } {
unset ::trojan_points($nickname)
}
set ::trojan_points($nickname) 0
if { $::trojan_debug_mode } {
putlog "trojan:join: $nickname -- $hostname -- $channel"
}
if { [trojan:meltdown $nickname] } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_random_nickname $trojan_random_nickname"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_random_nickname}]
}
if { [trojan:meltdown $ident] } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_random_ident $trojan_random_ident"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_random_ident}]
}
global trojan_only_big
if { [trojan:onlybig $nickname] && [trojan:onlybig $ident] } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_only_big $trojan_only_big"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_only_big}]
}
set digit_nickname [trojan:digits $nickname]
set digit_ident [trojan:digits $ident]
global digits_in_nickname digits_in_ident trojan_digit_nickname trojan_digit_ident
if { $digit_nickname >= $digits_in_nickname } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_digit_nickname $trojan_digit_nickname"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_digit_nickname}]
}
if { $digit_ident >= $digits_in_ident } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_digit_ident $trojan_digit_ident"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_digit_ident}]
}
whois $nickname $hostname $channel
}
###################################################################################################################################
# meltdowns nickchecker (copy right in script header) #
###################################################################################################################################
proc trojan:meltdown { input } {
set result 0
set check(cons) "bcdfghjklmnpqrstvxyz"
set check(good) "tt ll ss"
set check(affixture) "off bnc \[ \] afk"
set const_count 0
set score 0
set txt [string map "0 o 1 l 3 e 7 t 4 a" $input]
foreach x [split $check(good)] {
set txt [string map -nocase "$x \"\"" $txt]
}
foreach x [split $check(affixture)] {
if { [string match -nocase *$x* $txt] } {
set txt [string map -nocase "$x \"\"" $txt]
set score [expr {$score - 10}]
}
}
for { set x 0 } { $x < [string length $txt] } { incr x } {
if { [string last [string index $txt $x] $check(cons) ] > -1 } {
incr const_count
if { $const_count >= 3 } { set score [expr {$score+10}] }
} else {
set const_count 0
}
}
if { $score >= 30 } {
set result 1
}
return $result
}
###################################################################################################################################
# trojan onlybig #
###################################################################################################################################
proc trojan:onlybig { input } {
set output 0
set output [regexp {^[A-Z]+$} $input]
return $output
}
###################################################################################################################################
# trojan digits #
###################################################################################################################################
proc trojan:digits { input } {
set output [regexp -all {[0-9]} $input]
return $output
}
###################################################################################################################################
# trojan raw 301 - realname #
###################################################################################################################################
bind raw - 311 trojan:raw:311
proc trojan:raw:311 { from key text } {
global trojan_random_realname trojan_colors trojan_badwords trojan_realname_with_badword trojan_realname_with_color
set nickname [lindex [split $text " "] 1]
set realname [lindex [split $text ":"] end]
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
if { [trojan:meltdown $realname] } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_random_realname $trojan_random_realname"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_random_realname}]
}
foreach color $trojan_colors {
if { [string match "*$color*" $realname] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_realname_with_color $trojan_realname_with_color"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_realname_with_color}]
break
}
}
foreach badword $trojan_badwords {
if { [string match "*$badword*" $realname] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_realname_with_badword $trojan_realname_with_badword"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_realname_with_badword}]
break
}
}
set ::real_name($nickname) $realname
}
###################################################################################################################################
# realname #
###################################################################################################################################
proc realname { nickname } {
if { [info exists ::real_name($nickname) ] } {
return $::real_name($nickname)
} else {
return 0
}
}
###################################################################################################################################
# trojan raw 330 - auth #
###################################################################################################################################
bind raw - 330 trojan:raw:330
proc trojan:raw:330 { from key text } {
global trojan_random_authname authed_time
set nickname [lindex [split $text " "] 1]
set authname [lindex [split $text " "] 2]
# putlog "trojan: nickname: $nickname -- authname: $authname "
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
if { [trojan:meltdown $authname] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_random_authname $trojan_random_authname"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_random_authname}]
}
set ::authed($nickname) $authname
utimer $authed_time [list catch { unset ::authed($nickname) } error]
}
###################################################################################################################################
# is authed or not #
###################################################################################################################################
proc authed { nickname } {
if { [info exists ::authed($nickname) ] } {
return 1
} else {
return 0
}
}
###################################################################################################################################
# trojan raw 301 - away #
###################################################################################################################################
bind raw - 301 trojan:raw:301
proc trojan:raw:301 { from key text } {
putlog "trojan:raw:301 -- away -- $text"
global trojan_random_away away_time trojan_colors trojan_away_with_color trojan_badwords trojan_away_with_badword
set nickname [lindex [split $text " "] 1]
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
set away [lindex [split $text ":"] end]
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
if { [trojan:meltdown $away] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_random_away $trojan_random_away"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_random_away}]
}
foreach color $trojan_colors {
if { [string match "*$color*" $away] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_away_with_color $trojan_away_with_color"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_away_with_color}]
break
}
}
foreach badword $trojan_badwords {
if { [string match "*$badword*" $away] } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- + trojan_away_with_badword $trojan_away_with_badword"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_away_with_badword}]
break
}
}
set ::away($nickname) 1
if { $away == "" } {
catch { unset ::away($nickname) } error
}
utimer $away_time [list catch { unset ::away($nickname) } error]
}
###################################################################################################################################
# is away or not #
###################################################################################################################################
proc away { nickname } {
set nickname [string tolower $nickname]
if { [info exists ::away($nickname) ] } {
return 1
} else {
return 0
}
}
###################################################################################################################################
# trojan raw 313 - irc op #
###################################################################################################################################
bind raw - 313 trojan:raw:313
proc trojan:raw:313 { from key text } {
global ircop_time
set nickname [lindex [split $text " "] 1]
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
set ::trojan_points($nickname) 0
set ::ircop($nickname) 1
if { $::trojan_debug_mode } {
putlog "trojan:raw:313: $nickname is an IRC Operator"
}
# timer $ircop_time [list catch { unset ::ircop($nickname) } error]
}
###################################################################################################################################
# is ircop or not #
###################################################################################################################################
proc ircop { nickname } {
if { [info exists ::ircop($nickname) ] } {
return 1
} else {
return 0
}
}
###################################################################################################################################
# trojan raw 317 - idletime #
###################################################################################################################################
bind raw - 317 trojan:raw:317
proc trojan:raw:317 { from key text } {
global trojan_idletime trojan_less_idle
set nickname [lindex [split $text " "] 1]
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
set idletime [lindex [split $text " "] 2]
set singon [lindex [split $text " "] 3]
# putlog "trojan: nickname: $nickname -- idletime: $idletime -- singon: $singon"
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
if { $idletime < $trojan_idletime } {
# putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- idletime: $idletime < trojan_idletime: $trojan_idletime + $trojan_less_idle"
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_less_idle}]
}
}
###################################################################################################################################
# trojan raw 319 - channel #
###################################################################################################################################
bind raw - 319 trojan:raw:319
proc trojan:raw:319 { from key text } {
global trojan_status_op trojan_status_voice trojan_status_regular trojan_status_delayed trojan_minimum_chans trojan_to_less_chans
set nickname [lindex [split $text " "] 1]
set nickname [string tolower $nickname]
set chans [lindex [split $text ":"] end]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { $::trojan_debug_mode } {
putlog "trojan nickname: $nickname -- chans: $chans"
}
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
set op_channels 0
set voice_channels 0
set regular_channels 0
set delay_channels 0
set count_chans 0
foreach channel $chans {
set status [string index $channel 0]
set count_chans [expr {$count_chans +1}]
if { $status == "@" } {
set op_channels [expr {$op_channels +1}]
}
if { $status == "+" } {
set voice_channels [expr {$voice_channels +1}]
}
if { $status == "#" } {
set regular_channels [expr {$regular_channels +1}]
}
if { $status == "<" } {
set delay_channels [expr {$delay_channels +1}]
}
}
set oppoints [expr {$op_channels * $trojan_status_op}]
set voicepoints [expr {$voice_channels * $trojan_status_voice}]
set regularpoints [expr {$regular_channels * $trojan_status_regular}]
set delaypoints [expr {$delay_channels * $trojan_status_delayed}]
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) - $oppoints}]
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- op_channels: $op_channels -- oppoints: $oppoints"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) - $voicepoints}]
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- voice_channels: $voice_channels -- voicepoints: $voicepoints"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) - $regularpoints}]
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- regular_channels: $regular_channels -- regularpoints: $regularpoints"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) - $delaypoints}]
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- delay_channels: $delay_channels -- delaypoints: $delaypoints"
}
lesschannel $nickname $count_chans
if { $count_chans < $trojan_minimum_chans } {
if { $::trojan_debug_mode } {
putlog "trojan: nickname: $nickname -- points: $::trojan_points($nickname) -- user is only in $count_chans chans -> + $trojan_to_less_chans"
}
set ::trojan_points($nickname) [expr {$::trojan_points($nickname) + $trojan_to_less_chans}]
}
}
###################################################################################################################################
# trojan raw 318 - end whois #
###################################################################################################################################
bind raw - 318 trojan:raw:318
proc trojan:raw:318 { from key text } {
set nickname [lindex [split $text " "] 1]
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { ! [info exists ::trojan_points($nickname) ] } {
set ::trojan_points($nickname) 0
}
trojan:after:whois $nickname $::trojan_points($nickname)
if { [info exists ::trojan_points($nickname) ] } {
unset ::trojan_points($nickname)
}
}
###################################################################################################################################
# trojan after whois #
###################################################################################################################################
proc trojan:after:whois { nickname points } {
global trojan_max_points
set nickname [string tolower $nickname]
global botnick
set botnic [string tolower $botnick]
if { $nickname == $botnic } { return }
if { $::trojan_debug_mode } {
putlog "trojan:after:whois: $nickname -- authed: [authed $nickname]"
putlog "trojan:after:whois: $nickname -- away: [away $nickname]"
putlog "trojan:after:whois: $nickname -- ircop: [ircop $nickname]"
putlog "14trojan:after:whois: $nickname -- points: $points -- \/whois $nickname"
}
if { [ircop $nickname] } { return }
if { [authed $nickname] } { return }
if { $points <= 0 || $points == "" } { return }
if { $::trojan_debug_mode } {
putlog "4trojan:after:whois: $nickname -- points: $points -- \/whois $nickname"
}
if { $points >= $trojan_max_points } {
trojan:keepout $nickname $points
}
}
###################################################################################################################################
# trojan remove me #
###################################################################################################################################
proc trojan:msg:removeme { nickname hostname handle text } {
set BUZAin "antitrojan!$hostname"
set BUZAout [get:ban:mask $BUZAin]
# if { [info exists ::trojanremoveme($BUZAout) ] } { return }
if { ! [info exists ::trojanremoveme($BUZAout) ] } {
set ::trojanremoveme($BUZAout) 1
timer 60 [list unset ::trojanremoveme($BUZAout) ]
}
set addhost [maskhostxx "$nickname!$hostname" 3]
set hand "nofloodbot"
if { ! [validuser $hand] } {
putlog "trojan:msg:removeme adduser $hand"
adduser $hand
}
if { [validuser $hand] } {
putlog "trojan:msg:removeme setuser $hand hosts $addhost"
setuser $hand hosts $addhost
}
putserv "NOTICE $nickname :You added yourself to my userbase. I will not kick you again if you stick to this host: $addhost ."
if { [isban $BUZAout] } { trojan:remove:globalban $BUZAout }
if { [isban $addhost] } { trojan:remove:globalban $addhost }
foreach channel [channels] {
if { [validchan $channel] } {
if { [isban $BUZAout $channel] } { trojan:remove:chanban $BUZAout $channel }
if { [isban $addhost $channel] } { trojan:remove:chanban $addhost $channel }
}
}
utimer 2 [list unban:all:channel $BUZAout]
utimer 2 [list unban:all:channel $addhost]
}
# 1
proc trojan:remove:globalban { hostname } {
global trojan_kick_reason
foreach bans [banlist] {
set ban [lindex $bans 0]
set reason [lindex $bans 1]
if { [string match -nocase "*$hostname*" $ban] } {
if { [string match -nocase "*trojanbot*" $reason] } {
killban $ban
}
}
}
}
# 2
proc trojan:remove:chanban { hostname channel } {
global trojan_kick_reason
foreach bans [banlist $channel] {
set ban [lindex $bans 0]
putlog "$ban"
set reason [lindex $bans 1]
if { [string match -nocase "*$hostname*" $ban] } {
if { [string match -nocase "*trojanbot*" $reason] } {
killchanban $channel $ban
}
}
}
}
###################################################################################################################################
# trojan keepout #
###################################################################################################################################
proc trojan:keepout { nickname points } {
global trojan_kick_reason botnick trojan_ban trojan_kick trojan_debugmode trojan_testchan
global trojan_newchan_bantime trojan_newchanban trojan_newban trojan_newban_bantime
set handle [nick2hand $nickname]
if { [string equal -nocase $::botnick $nickname] } { return }
if { [string equal -nocase $handle "nofloodbot"] } { return }
if { $trojan_goodwords != "" } {
foreach nobadword $trojan_goodwords {
if { [string match -nocase $nobadword $nickname] } {
return
}
}
}
if { [string match -nocase "*.users.quakenet.org*" $hostname] } { return }
if { [matchattr handle mnofvI|mnofvI $channel] } { return }
set id [id $trojan_testchan]
regsub -all -- {:id:} $trojan_kick_reason $id trojan_kick_reason
regsub -all -- {:botnick:} $trojan_kick_reason $botnick trojan_kick_reason
regsub -all -- {:points:} $trojan_kick_reason $points trojan_kick_reason
set trojan_kickmsg $trojan_kick_reason
# append trojan_kickmsg " And please type: /msg $botnick removeme 1 :: badpoints: $points :: ID: $id ::.."
set host [getchanhost $nickname]
set BUZAin "trojankeepout!$host"
set hostname [get:ban:mask $BUZAin]
if { [isban $hostname] } { return }
foreach channel [channels] {
# if { ! [isop $botnick $channel] } { continue }
if { ! [channel get $channel antitrojan] } { continue }
if { ! [onchan $nickname $channel] } { continue }
if { [isban $hostname $channel] } { continue }
if { $trojan_debugmode } {
# putlog "newchan:ban $channel $hostname antitojan.tcl $trojan_kickmsg $trojan_newchan_bantime"
# putlog "new:ban $channel $hostname antitojan.tcl $trojan_kickmsg $trojan_newban_bantime"
# putlog "0,4trojan:keepout: put:quick $channel +b $hostname"
putlog "0,4trojan:keepout: kick:user $nickname $channel $trojan_kickmsg"
}
if { $trojan_ban } {
put:quick $channel +b $hostname
}
if { $trojan_kick } {
flood:detect $channel
kick:user $nickname $channel $trojan_kickmsg
}
if { $trojan_newchanban } {
newchan:ban $channel $hostname "antitojan.tcl" $trojan_kickmsg $trojan_newchan_bantime
}
if { $trojan_newban } {
new:ban $channel $hostname "antitojan.tcl" $trojan_kickmsg $trojan_newchan_bantime
}
}
}
###################################################################################################################################
# Copyright / Putlog #
###################################################################################################################################
putlog "*** antitrojan.tcl by sKy\\ - #apache-root @ Quakenet loaded. ***"
# This script is under GNU General Public License! For more infos see in the script header!