anticollide.tcl

anticollide.tcl

For a good secure You have to Install this script on more than 4 Bots in your Botnet. If an Attack is detected the following procedures happens: The nickchangemode starts on all Netbots for 5 minutes; The Channelmode changed to +i (invite mode); All unfriendly ( not +f flag) would be kicked

Postat de Copyright Categorie Review user Vizualizari Data
btc Fitti protections Cod netestat 312 2023-12-24 22:52:31

#Anti Nick Collide Schript by Fitti <fitti_@gmx.de>
#For a good secure You have to Install this scipt
#on more than 4 Bots in your Botnet
#If there more then x collides in y minutes the Script
#If an Attack is detected the following procedures happends:
#	The nickchangemode starts on all Netbots for 5 minutes
#	The Channelmode changed to +i (invite mode)
#	All unfriendly ( not +f flag) would be kicked
#
#	.startkicking <chan> 
#		starts to kick all unfriendly Users on a specific
#		chan manually
#
#	.stopkicking <chan>
#		stops kicking
#
#	.startnickchange 
#		starts the nickchange mode
#
#	.stopnickchange
#		stops the nickchange mode
# there could be still a few bugs left. please contact me for
# any questions/ideas/fixes etc.

global keep-nick
#number of max collides in y minutes
set rf_acflood 3:5
#time the Chan is +i after attack
set rf_blocktime 15
set acvers "0.49"



#---------------------------------------------------------------------------
set nickchange 0
set sidx 0
if { [info exists db3] == 1 } {
	unset db3
}

set temp1 [rand 10]
set temp2 [rand 10]
set temp3 [rand 10]
set temp4 [rand 10]
set temp5 [rand 10]
set temp6 [rand 10]
set temp7 [rand 10]
set tempie ac$temp1$temp2$temp3$temp4$temp5$temp6$temp7

foreach timer [timers] {
	if {[string match "*ac_DecreaseCounter*" $timer]} {
		  killtimer [lindex $timer 2]
		}
	}
	
proc ac_DecreaseCounter { chan } {
	global db3 rf_acflood
	set chan [string tolower $chan]
	if { [info exists db3($chan,nickcollide) ] == 1 } {	
		incr db3($chan,nickcollide) -1
		if {$db3($chan,nickcollide) <= 0} {		
			foreach {i j}  [array get db3 $chan,*] {				
				unset db3($i)
			}
			rf_sendtoparty  "Collide Counter for $chan has been erased"
		} else {	
			rf_sendtoparty  "Counter for $chan has been set to $db3($chan,nickcollide)"
			foreach timer [timers] {
				if {[string match "*ac_DecreaseCounter $chan*" $timer]} {
					return 0				
				}
			}
			timer [lindex [split $rf_acflood ":"] 1] "ac_DecreaseCounter $chan"			
		}
	}
}
proc fv_dcc_startnickchange { handle idx arg } {
	putdcc $idx "Nickchangung mode Startet"
	startnickchange 

}
proc fv_dcc_showotheracbots { handle idx arg } {
global sidx
set sidx $idx
	putallbots "anticollide showversion"
}
proc fv_dcc_stopnickchange { handle idx arg } {
	putdcc $idx "Nickchangung mode Stop"
	stopnickchange	
}
proc fv_dcc_stopkickalluser { handle idx arg } {
	global db3 
	set arg [lindex $arg 0]
	if {[validchan $arg]} {
		kickalluser $arg
		putallbots "anticollide stopkicking {$arg}"
		putlog "kickall users stopped by $handle on chan $arg"
		set db3($arg,kicking) 0
		putdcc $idx "Kick all unknown Users on $arg stopped"
	} else {
		putdcc $idx "Kick all unknown Users stopped"
		putallbots "anticollide stopkicking"
		foreach {i j}  [array get db3 *,kicking] {				
			set db3($i) 0
		}
	}	
}
proc fv_dcc_kickalluser { handle idx arg } {
global db3 rf_blocktime
set arg [lindex $arg 0]
	if {[validchan $arg]} {
		kickalluser $arg
		putallbots "anticollide startkicking {$arg}"
		putlog "kickall users startet by $handle on chan $arg"
		set db3($arg,kicking) 1
		putdcc $idx "Kick all unknown Users on $arg startet"
		timer $rf_blocktime "putserv {mode $arg -i}"
		timer 5 "set db3($arg,kicking) 0"
	} else {
		putdcc $idx "Syntax is : .startkicking.<chan> . The chan must be valid"
	}	
}
proc kickalluser { chan } {
global rf_blocktime db3
	if { ![info exists db3($chan,kicking) ] == 1 } {	
		return 0
	}
	if {![validchan $chan] } {
		return 0
	}
	if { $db3($chan,kicking) == 0 } {	
		return 0
	}
set mode [lindex [getchanmode #flirt] 0]
if { ![string match "*i*" $mode ] } {
	putquick "mode $chan +is"
}
	set randf [expr { rand() * 10 } ]

set counter 0
set kicku ""
	if {[botisop $chan]} {
		putlog "Kickick Scanning $chan"
		set users  [chanlist $chan "-f"]
		set users [lsort $users]
		foreach user $users {
			if { [string length $kicku] > 0 } {	
				set kicku "$kicku,$user"
			} else {
				set kicku "$user"				
			}
			incr counter
			if { $counter >= 6 } {
				putquick "KICK $chan $kicku :channel closed cause technical Problems sorry ;)"
				#putlog "KICK $chan $kicku :channel closed cause technical Problems sorry ;)"
				set counter 0
				set kicku ""				
			}
			if { $db3($chan,kicking) == 0 } {
				return 0
			}			
		}
		if { [string length $kicku] > 0 } {
			#putlog "KICK $chan $kicku :channel closed cause technical Problems sorry ;)"
			putquick "KICK $chan $kicku :channel closed cause technical Problems sorry ;)"
		}
	}
	set ftopic [topic $chan]
	if { ![string match "*Attack*" $ftopic] } {
		putserv "topic $chan :Channel closed cause Attack"
	}
	utimer [expr 10 + $randf] "kickalluser $chan"
}
proc startnickchange { } {	
	global nickchange keep-nick tempie
	set keep-nick 0
	set nickchange 1
	putquick "NICK $tempie"
	utimer 15 ac_changenick
	putallbots "anticollide startnickchanging"
	timer 5 stopnickchange
}

proc stopnickchange { } {	
	global nickchange keep-nick
	set keep-nick 1
	set nickchange 0
	putallbots "anticollide stopnickchanging"
}
proc ac_changenick {} {
    global nickchange
	set randf [expr { rand() * 10 } ]
	if {$nickchange==1} {
		set temp1 [rand 10]
		set temp2 [rand 10]
		set temp3 [rand 10]
		set temp4 [rand 10]
		set temp5 [rand 10]
		set temp6 [rand 10]
		set temp7 [rand 10]
		set tempie ac$temp1$temp2$temp3$temp4$temp5$temp6$temp7
		putserv "NICK $tempie"
		utimer [expr 10 + $randf] ac_changenick
	}
	

}

proc botsign { nick uhost handle channel reason } {
global db3 rf_acflood nickchange tempie
set channel [string tolower $channel]
set nick [string tolower $nick]
	
	if { [string match -nocase *Killed* $reason] } {
		if {![info exists db3($channel,nick,$nick)]} {
			set db3($channel,nick,$nick) 1					
			if {![info exists db3($channel,nickcollide) ]} {
				set db3($channel,nickcollide) 1
			} else {
				incr db3($channel,nickcollide) 1
			}
		}
		
		
		putallbots "anticollide collidereceive {$channel} {$nick}"
		
		if { $db3($channel,nickcollide) >= [lindex [split $rf_acflood ":"] 0] } {
		set nickchange 1
		#kick all user
		putquick "NICK $tempie"
		utimer 15 ac_changenick
		kickalluser $channel
		#changenick
		 
		timer 5 stopnickchange
		#send to nickcollide attack to others
		}
		putlog "nick collide $db3($channel,nickcollide) "
		if { $db3($channel,nickcollide) < 2 } {
			foreach timer [timers] {
				if {[string match "*ac_DecreaseCounter $channel*" $timer]} {
					return 0				
				}
			}
			timer [lindex [split $rf_acflood ":"] 1] "ac_DecreaseCounter $channel"		
		}
	}
}

proc fv_dcc_seetimers {handle idx arg} {
	foreach t [timers] {
		putdcc $idx $t
	}
	putdcc $idx "utimer :"
	foreach t [utimers] {
			putdcc $idx $t
	}
}
proc fv_dcc_seedb {handle idx arg} {
global db3
	foreach i [array names db3 *,*] {				
		putdcc $idx "$i $db3($i)"
	}	
}
proc fv_anticollide {frombot cmd arg} { 
	global db3 rf_acflood tempie nickchange keep-nick rf_blocktime acvers sidx
	set arg [split $arg]
	set cmd1 [lrange [split $arg] 1 end]
	set cmd2 [string tolower [lrange $cmd1 0 0]]
	
	if {![islinked $frombot]} {return 0}
	#putlog "fv_anticollide Command  received  $arg"
	switch -exact [lindex $arg 0] {
	"showversion" {
		putbot $frombot "anticollide myversion $acvers"
	}
	"myversion" {
		if {[valididx $sidx]} {
			putdcc $sidx "Other ac bot is $frombot [lindex $cmd1 0]"
		}
	}
	"startnickchanging" {
		putquick "NICK $tempie"
		utimer 15 ac_changenick
		set keep-nick 0
		set nickchange 1
		timer 5 stopnickchange
		}
	"stopnickchanging" {
		set nickchange 0
		set keep-nick 1
		putlog "Nickchangung mode Stop"
		}
	"startkicking" {
		if { ![validchan [join [lindex $arg 1]]] } {
			return 0
		}
		putlog "Start to kick all users on [join [lindex $arg 1]]"
		set db3([join [lindex $arg 1]],kicking) 1
		timer $rf_blocktime "putserv {mode [join [lindex $arg 1]] -i}"
		kickalluser [join [lindex $arg 1]]
		timer 5 "set db3([join [lindex $arg 1]],kicking) 0"
		}
	"stopkicking" {
			if { ![validchan [join [lindex $arg 1]]] } {
				foreach {i j}  [array get db3 *,kicking] {				
					set db3($i) 0
				}	
			} else {
				set db3([join [lindex $arg 1]],kicking) 0
			}	
		}
	"collidereceive" {
		#putlog "collidereceive $cmd3"
		set channel [join [lindex $cmd2 0 ]]
		
		putlog "collidereceive2  $channel , [join [lindex $arg 1]]"
		if {![info exists db3([join [lindex $arg 1]],nick,[join [lindex $arg 2]])]} {
				set db3([join [lindex $arg 1]],nick,[join [lindex $arg 2]]) 1					
				if {![info exists db3([join [lindex $arg 1]],nickcollide) ]} {
					set db3([join [lindex $arg 1]],nickcollide) 1
				} else {
					incr db3([join [lindex $arg 1]],nickcollide) 1
				}
			}
			if { $db3([join [lindex $arg 1]],nickcollide) < 2 } {
				foreach timer [timers] {
					if {[string match "*ac_DecreaseCounter [join [lindex $arg 1]]*" $timer]} {
						return 0				
					}
				}
				timer [lindex [split $rf_acflood ":"] 1] "ac_DecreaseCounter [join [lindex $arg 1]]"		
			}
			if { $db3($channel,nickcollide) >= [lindex [split $rf_acflood ":"] 0] } {
				set nickchange 1
				#kick all user
				putquick "NICK $tempie"
				utimer 15 ac_changenick
				kickalluser $channel
				#changenick

				timer 5 stopnickchange
			}
		}
	}

}
bind sign +b|o * botsign
bind dcc m showacdb fv_dcc_seedb
bind dcc m showactimers fv_dcc_seetimers
bind dcc m startkicking fv_dcc_kickalluser
bind dcc m stopkicking fv_dcc_stopkickalluser
bind dcc m startnickchange fv_dcc_startnickchange
bind dcc m stopnickchange fv_dcc_stopnickchange
bind dcc m showotheracbots fv_dcc_showotheracbots
bind bot - anticollide fv_anticollide
putlog "Anticollide $acvers by Fitti loaded"