################################################################## ### Protection contre les couleurs, les CAPS et les vulgarités ### ################################################################## ### # Chargement de la liste des gros mots et initialisations set faithwords "gros.mots" if ![info exists bnick] { # Compteurs set bnick 0 set bword 0 set btopic 0 set kword 0 set knick 0 set wordcnt 0 set nickcnt 0 # Listes d'avertissements set badmouth "" set listekickflood "" set listekickcaps "" set listekickcouleurs "" set listeonjoinpart "" # Listes de mots set badwords "" set badnicks "" set okwords "" set f [open $faithwords r] while {[gets $f line] >= 0} { switch [string index $line 0] { + {lappend badwords [string trim $line +*?]} = {lappend badnicks [string trim $line =*?]} ~ {lappend okwords [string trim $line ~*?]} } } close $f # AntiSpoof set antispoof 0 set timerantispoof "" set banspoof 0 set tmp [expr [unixtime] - 60] set verifspoof "$tmp $tmp $tmp $tmp $tmp" unset tmp set listebanspoof "" # etat utimer 5 { set derniercloneban [lrange [getuser AideBot xtra etat] 0 1] set derniermenageban [lindex [getuser AideBot xtra etat] 2] set derniermenagetilde [lindex [getuser AideBot xtra etat] 3] set activantispoof [lindex [getuser AideBot xtra etat] 4] } # Fin putlog "Protection automatisée du canal activée." } ### # Sauvegarde de la liste des gros mots proc save_words {} { global badwords badnicks faithwords okwords set f [open $faithwords w] foreach w $badwords { puts $f "+[string trim $w *?]" } foreach w $badnicks { puts $f "=[string trim $w *?]" } foreach w $okwords { puts $f "~[string trim $w *?]" } flush $f close $f } ### # Modifier la liste des gros mots bind dcc C +grosmot add_word proc add_word {hand idx word} { global badwords if {$word != ""} { set word [string trim [string tolower $word] *?] foreach w $word { if {[lsearch -exact $badwords $w] < 0} { lappend badwords $w putdcc $idx "Mot ajouté: $w" } } } save_words putdcc $idx "Gros mots: $badwords" return 1 } bind dcc C +grosnick add_nick proc add_nick {hand idx nick} { global badnicks if {$nick != ""} { set nick [string trim [string tolower $nick] *?] foreach w $nick { if {[lsearch -exact $badnicks $w] < 0} { lappend badnicks $w putdcc $idx "Alias ajouté: $w" } } } save_words putdcc $idx "Gros nick: $badnicks" return 1 } bind dcc C +motok add_ok proc add_ok {hand idx word} { global okwords if {$word != ""} { set word [string trim [string tolower $word] *?] foreach w $word { if {[lsearch -exact $okwords $w] < 0} { lappend okwords $w putdcc $idx "Mot Ok ajouté: $w" } } } save_words putdcc $idx "Mots Ok: $okwords" return 1 } bind dcc C -grosmot del_word proc del_word {hand idx word} { global badwords if {$word != ""} { set word [lindex $word 0] set delindex [lsearch -exact $badwords $word] if {$delindex == -1} { putdcc $idx "$word n'a pas été trouvé dans la liste" } else { putdcc $idx "Mot retiré: $word" set badwords [lreplace $badwords $delindex $delindex] } } save_words putdcc $idx "Gros mot: $badwords" return 1 } bind dcc C -grosnick del_nick proc del_nick {hand idx nick} { global badnicks if {$nick != ""} { set nick [lindex $nick 0] set delindex [lsearch -exact $badnicks $nick] if {$delindex == -1} { putdcc $idx "$nick n'a pas été trouvé dans la liste" } else { putdcc $idx "Gros nick retiré: $nick" set badnicks [lreplace $badnicks $delindex $delindex] } } save_words putdcc $idx "Gros nick: $badnicks" return 1 } bind dcc C -motok del_ok proc del_ok {hand idx word} { global okwords if {$word != ""} { set word [lindex $word 0] set delindex [lsearch -exact $okwords $word] if {$delindex == -1} { putdcc $idx "$word n'a pas été trouvé dans la liste" } else { putdcc $idx "Mot Ok retiré: $word" set okwords [lreplace $okwords $delindex $delindex] } } save_words putdcc $idx "Mot Ok: $okwords" return 1 } ### # Afficher le rapport des avertissements bind dcc f|f rapport give_rep proc give_rep {hand idx args} { global botnick bnick bword btopic kword knick badmouth wordcnt nickcnt listekickflood listekickcaps listekickcouleurs listeonjoinpart antispoof timerantispoof banspoof listebanspoof verifspoof putdcc $idx "*** Rapport d'activité de la surveillance automatisée d'AideBot" putdcc $idx " " putdcc $idx "Mots vérifiés: $wordcnt" putdcc $idx "Gros mots (avertissements): $bword" putdcc $idx "Kicks (caps/coul/flood/vulgaire/onjoin): $kword" putdcc $idx "Alias (vérifiés): $nickcnt" putdcc $idx "Alias (Kicks): $bnick" putdcc $idx "Alias (KickBans): $knick" putdcc $idx "Topics: $btopic" putdcc $idx " " putdcc $idx "Grossiers personnnages: \([llength $badmouth]\): $badmouth" putdcc $idx "Amateurs de couleurs: \([llength $listekickcouleurs]\): $listekickcouleurs" putdcc $idx "Criards (CAPS): \([llength $listekickcaps]\): $listekickcaps" putdcc $idx "Floodeurs surveillés: \([llength $listekickflood]\): $listekickflood" putdcc $idx "On join/part notés: \([llength $listeonjoinpart]\): $listeonjoinpart" putdcc $idx " " putdcc $idx "Protection contre les relais illicites:" if $antispoof {set act "actif "} else {set act "inactif"} putdcc $idx " État: $act Timer: [lindex $timerantispoof 1]" putdcc $idx " Détection automatique: [dire_delai [expr [unixtime] - [lindex [lindex $verifspoof 0] 0]]] (5~ join: Activation à moins de 20 secondes)" putdcc $idx " Si actif, bloque: [getuser aidebot xtra spoof] et par IPs" putdcc $idx " Exclusions: ($banspoof): $listebanspoof" return 1 } ### # Vider les avertissements en mémoire bind dcc C videravertissements clear_warnings proc clear_warnings {hand idx args} { global badmouth listekickflood listekickcaps listekickcouleurs listeonjoinpart banspoof listebanspoof set badmouth "" set listekickcouleurs "" set listekickcaps "" set listekickflood "" set listeonjoinpart "" set banspoof 0 set listebanspoof "" putdcc $idx "Les avertissements en mémoire ont été effacés." return 1 } ### # Activation ou désactivation de la protection automatisée set protection_ccf 1 bind pubm - * texte_agressant bind ctcp - action texte_agressant_ctcp bind sign - * texte_agressant bind part - * texte_agressant bind dcc C caps&couleurs protection_canal proc protection_canal {hand idx stuff} { global protection_ccf botnick set cchoice [string tolower [lindex $stuff 0]] if {$cchoice == "off"} { putdcc $idx "Protection automatisée du contenu canal suspendue" if {$protection_ccf == 1} { unbind pubm - * texte_agressant unbind ctcp - action texte_agressant_ctcp unbind sign - * texte_agressant unbind part - * texte_agressant set protection_ccf 0 } return 1 } elseif {$cchoice == "on"} { putdcc $idx "Protection automatisée du contenu canal activée" if {$protection_ccf == 0} { bind pubm - * texte_agressant bind ctcp - action texte_agressant_ctcp bind sign - * texte_agressant bind part - * texte_agressant set protection_ccf 1 } return 1 } else { putdcc $idx "Option Protection automatisée du contenu canal invalide - $cchoice" putdcc $idx "Les options valides sont: \[on/off\]" return 0 } } ######################################## ### # Pour les CTCP et les /me proc texte_agressant_ctcp {nick host hand dest keyword arg} { if [string match *#* $dest] { texte_agressant $nick $host $hand $dest $arg } } ### # Vérification du contenu et de la répétition proc texte_agressant {nick host hand chan text} { global listekickcouleurs listekickcaps listekickflood kword repeat_last repeat_num badwords wordcnt badmouth kword bword regsub -all {\"|\}|\{|\]|\[|\\} $text "" text if {[string toupper $chan] == "#IGT"} { return 0 } if [matchattr $hand b] { return 0 } if ![matchattr $hand nmof|ovf $chan] { if [info exists repeat_last([set n [string tolower $nick]])] { if {[string compare [string tolower $repeat_last($n)] [string tolower $text]] == 0} { if {[incr repeat_num($n)] > 2} { set mechant [trouver_masque $nick $chan] if [string match *$mechant* $listekickflood] { putserv "MODE $chan +b $mechant" putserv "KICK $chan $nick :Désolé $nick, mais tu as déjà été averti au sujet du flood." newchanban $chan $mechant Aidebot "Flood canal répété" 15 } else { petitban $nick $chan "Woho là le perroquet !" lappend listekickflood $mechant } unset repeat_last($n) unset repeat_num($n) return 1 } } } else { set repeat_num($n) 1 set repeat_last($n) $text } set couleurs [regsub -all {|} $text "" tmp] if $couleurs { set mechant [trouver_masque $nick $chan] if [string match *$mechant* $listekickcouleurs] { banetkick $chan $nick "Désolé $nick, mais tu as déjà été averti au sujet des couleurs." $mechant "Excès de couleurs" 15 } else { petitban $nick $chan "Les couleurs ne sont pas acceptées sur le canal." lappend listekickcouleurs $mechant incr kword } return 1 } set caps [regsub -all {[A-Z]} $text "" tmp] if {$caps > 25} { set mechant [trouver_masque $nick $chan] if [string match *$mechant* $listekickcaps] { banetkick $chan $nick "Désolé $nick, mais tu as déjà été averti au sujet des majuscules." $mechant "Excès de majuscules" 15 } else { petitban $nick $chan "Pas trop de majuscules STP !" lappend listekickcaps $mechant incr kword } return 1 } set espaces [regsub -all { } $text "" sansespace] set longueur [string length $text] if {($espaces == 0) && ($longueur > 60) && !(([string tolower [string range $text 0 6]] == "http://")|([string tolower [string range $text 0 5]] == "ftp://")|([string tolower [string range $text 0 3]] == "www."))} { set mechant [trouver_masque $nick $chan] if [string match *$mechant* $listekickflood] { banetkick $chan $nick "Désolé $nick, mais tu as déjà été averti au sujet du flood." $mechant "Flood canal répété" 15 } else { petitban $nick $chan "Hum! C'est du flood ça !" lappend listekickflood $mechant incr kword } return 1 } set test [regsub -all {|} $text "" tmp] if $test { regsub -all {} $sansespace "" maphrase set actif 1 set soulignes 0 set blocs [split $maphrase ] foreach bloc $blocs { incr actif if [expr $actif % 2] { set soulignes [expr $soulignes + [string length $bloc]] } } if {$soulignes > 20} { petitban $nick $chan "Pas trop de soulignés STP !" incr kword return 1 } regsub -all {} $sansespace "" maphrase set actif 1 set gras 0 set blocs [split $maphrase ] foreach bloc $blocs { incr actif if [expr $actif % 2] { set gras [expr $gras + [string length $bloc]] } } if {$gras > 20} { petitban $nick $chan "Pas trop de caractères gras STP !" incr kword return 1 } } } if ![matchattr $hand nm|m $chan] { set text2 [minacc $text] incr wordcnt [llength $text] foreach w $badwords { if [regexp -nocase $w $text2] { if ![iswordok $text2] { if [matchattr $hand -&+o $chan] { putbot Aide "msg $nick STP surveille ton vocabulaire tant que tu seras sur $chan" putbot Aide "msg $nick Je fais référence à: <$nick> $text" putlog "[getuser $hand xtra vrainick] averti sur $chan pour son vocabulaire." return 0 } if ![botisop $chan] { return 0 } if {[lsearch -exact $badmouth [maskhost $host]] > -1} { regsub {\*!} [maskhost $host] \*!\* da_ban if ![isvoice $nick $chan] { putserv "MODE $chan +b $da_ban" newchanban $chan $da_ban Aidebot "Vocabulaire inacceptable" 30 } putserv "KICK $chan $nick :Désolé $nick, mais tu as déjà été averti au sujet de ton vocabulaire." incr kword } else { putbot Aide "msg $nick Attention $nick\! Ce type de vocabulaire ne sera pas toléré sur $chan" lappend badmouth [maskhost $host] putbot Aide "msg $nick Je fais référence à: <$nick> $text" incr bword } return 1 } } } } } ### # Vérification des topics bind topc - "% *" faith_topic proc faith_topic {nick uhost hand chan topic} { global badwords btopic wordcnt if ![botisop $chan] {return 0} incr wordcnt [llength $topic] foreach w $badwords { if [regexp -nocase $w $topic] { if ![iswordok $topic] { putserv "TOPIC $chan :Bienvenue sur $chan" putbot Aide "msg $nick Ce type de topic ne sera pas accepté ici." incr btopic return 1 } } } } ### # Vérification des nick bind join - "% *" faith_join bind nick - "% *" faith_nick proc faith_join {nick uhost hand chan} { global badnicks nickcnt badmouth knick bnick incr nickcnt foreach w $badnicks { if [regexp -nocase $w $nick] { if ![iswordok $nick] { if [matchattr $hand -&+o $chan] { putbot Aide "msg $nick Ce genre d'alias n'est pas acceptable sur $chan" putlog "[getuser $hand xtra vrainick] averti sur $chan pour son alias." return 0 } if ![botisop $chan] { return 0 } if {[lsearch -exact $badmouth [maskhost $uhost]] > -1} { regsub {\*!} [maskhost $uhost] \*!\* da_ban if ![isvoice $nick $chan] { banetkick $chan $nick "Désolé, mais tu as déjà été averti au sujet de ton vocabulaire." $da_ban "Vocabulaire inacceptable" 30 } else { putserv "KICK $chan $nick :Désolé, mais tu as déjà été averti au sujet de ton vocabulaire." } incr knick } else { banetkick $chan $nick "Cet alias ne sera pas accepté sur $chan" "$nick!*@*" "Alias inacceptable" 5 lappend badmouth [maskhost $uhost] putbot Aide "msg $nick Change d'alias et reviens nous voir :)" incr bnick } return 1 } } } } proc faith_nick {nick uhost hand chan newnick} { global repeat_last repeat_num catch {set repeat_last([set nn [string tolower $newnick]]) $repeat_last([set on [string tolower $nick]])} catch {unset repeat_last($on)} catch {set repeat_num($nn) $repeat_num($on)} catch {unset repeat_num($on)} faith_join $newnick $uhost $hand $chan } ### # Sous-routines nécessaire au bon fonctionnement # Répétitions proc repeat_timr {} { global repeat_last if ![regexp repeat_timr [timers]] { timer 1 repeat_timr } catch {unset repeat_last} catch {unset repeat_num} } timer 1 repeat_timr # Gros mots proc iswordok {text} { global okwords if {$okwords == {}} {return 0} foreach w $okwords { if [regexp -nocase $w $text] { return 1 } } return 0 } # Pour éviter que les listes n'engraissent trop :-) proc timer_menageavert {a b c d e} { global badmouth listekickcouleurs listekickcaps listekickflood listeonjoinpart if {[llength $badmouth] > 10} { set badmouth [lrange $badmouth [expr [llength $badmouth] - 10] end] } if {[llength $listekickcouleurs] > 20} { set listekickcouleurs [lrange $listekickcouleurs [expr [llength $listekickcouleurs] - 20] end] } if {[llength $listekickcaps] > 10} { set listekickcaps [lrange $listekickcaps [expr [llength $listekickcaps] - 10] end] } if {[llength $listekickflood] > 10} { set listekickflood [lrange $listekickflood [expr [llength $listekickflood] - 10] end] } if {[llength $listeonjoinpart] > 10} { set listeonjoinpart [lrange $listeonjoinpart [expr [llength $listeonjoinpart] - 10] end] } } bind time - "15 * * * *" timer_menageavert ################################################### # Différents flood ! :-) bind flud - * les_floods proc les_floods {nick host hand type chan} { global listekickflood kword if {$hand != "*" } { putlog "$nick ($hand : $host) flood en $type ($chan)" if [matchattr $hand AGTCOJRPMH-S] { sendnote "AideBot" $hand "Flood loggué -> $nick ($hand : $host) flood en $type ($chan)" } return 0 } set mechant [trouver_masquehost "$nick\!$host" "large"] if {$type == "pub"} { if [string match *$mechant* $listekickflood] { putserv "MODE $chan +b $mechant" putserv "KICK $chan $nick :Désolé $nick, mais tu as déjà été averti au sujet du flood." newchanban $chan $mechant Aidebot "Flood canal répété" 15 } else { petitban $nick $chan "Hééé, on se calme !!! (Flood!)" lappend listekickflood $mechant incr kword } newignore $mechant "AideBot" "Flood sur le canal, protection 2 minutes" 2 return 1 } elseif {$type == "msg"} { newban $mechant "AideBot" "Je n'aime pas me faire flooder en /msg, désolé! (auto-ban)" 5 newignore $mechant "AideBot" "Flood en privé, protection 5 minutes" 5 return 1 } elseif {$type == "ctcp"} { newban $mechant "AideBot" "CTCP Flood! Non merci, bye! (auto-ban)" 30 newignore $mechant "AideBot" "Flood en ctcp, protection 10 minutes" 10 return 1 } else { return 0 } } ################################################### # Protection des popups de #Aide ... bind pubm - * humpopups proc humpopups {nick host hand chan text} { if [matchattr $hand AGCTOJRPMHb] {return 0} if [string match "*(©#Aide)*" $text] { putserv "KICK #Aide $nick :Hum, les popups de #Aide sont réservés aux membres officiels de #Aide ayant terminé leur période d'évaluation." putlog "$nick!$host ($hand) utlise les popups de #Aide sans autorisation." } } ################################################### ### Protection contre les onjoin et les troyens ### ################################################### bind bot - dccsend trojandetecte proc trojandetecte { from commande args } { set args [lindex $args 0] set nick [lindex $args 0] set fichier [lindex $args 1] set hand [nick2hand $nick] if [validuser $hand] { putlog "DCC SEND ProfBot: $nick ($hand) !???" } elseif [onchan $nick #Aide] { putloglev 8 #Aide "DCC SEND suspect on/join de $nick ($fichier) - Je kick." petitban $nick #Aide "Hey $nick! Tu es infecté par un Cheval de Troie! (Un VlRUS) Fais vite « /join 0,#AVU » -ou- vas sur « antivirus.igt.net »" } else { } } bind bot - onjoin onjoinonpart proc onjoinonpart { from commande args } { global listeonjoinpart kword set args [lindex $args 0] set nick [lindex $args 0] set text [lrange $args 1 end] set hand [nick2hand $nick] if [matchattr $hand b] { } elseif [validuser $hand] { putlog "ON JOIN/PART sur #Aide: $nick ($hand) !???" } elseif [onchan $nick #Aide] { putloglev 2 #Aide "ON JOIN\/PART de $nick ($text) - Je kick." set mechant [trouver_masque $nick #Aide] if [string match *$mechant* $listeonjoinpart] { putserv "MODE #Aide +b $mechant" putserv "KICK #Aide $nick :Désolé $nick, mais tu as déjà été averti au sujet des messages on join/part." newchanban #Aide $mechant Aidebot "On Join/Part répété" 15 } else { petitban $nick #Aide "SVP, Pas de message On Join/Part ici. -> /remote off" lappend listeonjoinpart $mechant incr kword } newignore $mechant "AideBot" "On Join/Part, protection 1 minute" 1 } else { } } set anciendccsend "" bind raw - PRIVMSG raw_joinaide bind raw - NOTICE raw_joinaide proc raw_joinaide {from key args} { global anciendccsend regsub -all {\"|\}|\{|\]|\[|\\} $args "" args set args [lrange [lindex $args 0] 1 end] set from [lindex [split $from !] 0] if {![onchan $from #Aide] | [validuser [nick2hand $from]]} { return 0 } if {([string toupper [lrange $args 0 1]] == ":DCC SEND") | ([string toupper [lrange $args 0 1]] == ":DCC SEND")} { set nouveau "$from [lindex $args 2]" if {$nouveau != $anciendccsend} { set anciendccsend $nouveau utimer 15 { set anciendccsend "" } trojandetecte "" "dccsend" $nouveau } return 1 } } ########################################## # Anti spoof ... bind join - * join_spoof bind dcc O antispoof antispoof_act proc antispoof_act {hand idx arg} { global antispoof timerantispoof activantispoof if {$hand != "AideBot"} { if $antispoof { putdcc $idx "*** Anti-spoof désactivé ***" set antispoof 0 putloglev 1 #Aide "Anti-Spoof: Désactivation par [getuser $hand xtra vrainick]." if {$timerantispoof != ""} { killtimer [lindex $timerantispoof 0] set timerantispoof "" } } else { putdcc $idx "*** Anti-spoof activé: Tout ~, sauf: [getuser aidebot xtra spoof] ***" set antispoof 1 set activantispoof [unixtime] putloglev 1 #Aide "Anti-Spoof: Activation par [getuser $hand xtra vrainick] pour 15 minutes." set timerantispoof "[timer 15 {antispoof_act AideBot 0 "timer"}] [getuser $hand xtra vrainick]" } } else { if $antispoof { set antispoof 0 putloglev 1 #Aide "Anti-Spoof: Fin du timer Anti-spoof (re-désactivation de la protection)." } else { set antispoof 1 set activantispoof [unixtime] if {$timerantispoof != ""} { killtimer [lindex $timerantispoof 0] } else { set timerantispoof "[timer 15 {antispoof_act AideBot 0 "timer"}] AideBot" } putloglev 1 #Aide "Anti-Spoof: Activation automatique! \[5 entrées suspectes de suite\] (Pour 15 minutes, .antispoof pour annuler) " } set timerantispoof "" } } bind dcc C +spoof antispoof_change bind dcc C -spoof antispoof_change proc antispoof_change {hand idx arg} { global lastbind set arg [lindex $arg 0] if {$arg == ""} { putdcc $idx "## Syntaxe: <+|->spoof " return 0 } set spoofliste [getuser aidebot xtra spoof] if {[string index $lastbind 0] == "+"} { append spoofliste " [lindex $arg 0]" } else { set delindex [lsearch -exact $spoofliste $arg] if {$delindex != -1} { set spoofliste [lreplace $spoofliste $delindex $delindex] } } putdcc $idx "Nouvelle liste: $spoofliste" setuser aidebot xtra spoof $spoofliste return 1 } proc join_spoof {nick uhost hand chan} { global antispoof banspoof listebanspoof verifspoof if {([string index $uhost 0] != "~") | [matchattr $hand AOJMNVRPH]} { return 0 } if $antispoof { set host [lindex [split $uhost @] 1] set oki 1 foreach item [getuser aidebot xtra spoof] { if [string match "*$item" $host] { set oki 0 } } if $oki { newchanban $chan "*!~*@$host" AideBot "Désolé. Protection contre les relais illicites activée." 5 putloglev 1 #Aide "Anti-spoof: J'ai exclu $nick!$uhost ... .antispoof pour désactiver/activer." incr banspoof append listebanspoof "$nick![lindex [split $uhost @] 0] " } } else { set la [unixtime] set long [string length [lindex [split $uhost @] 0]] set verifspoof [lrange $verifspoof 1 4] lappend verifspoof "$la $long" if {[expr $la - [lindex [lindex $verifspoof 0] 0]] < 20} { antispoof_act "AideBot" 0 "auto" } # Surveillance des patterns de identd if {($long == [lindex [lindex $verifspoof 3] 1]) & ($long == [lindex [lindex $verifspoof 2] 1]) & ($long == [lindex [lindex $verifspoof 1] 1]) & ([expr $la - [lindex [lindex $verifspoof 1] 0]] < 20)} { set masque "*!~" for {set i 1} {$i < $long} {incr i} { append masque "?" } append masque "@*" newchanban $chan $masque AideBot "Attaque de clones sur relais illicites... Banni automatiquement!" 15 stick $masque #Aide putbot Aide "msg X kick #Aide *!~*@* Désolé. Kick de sécurité des gens sans identd." putloglev 1 #Aide "Attaque de clones sur relais illicites... Banni: $masque" } # } } ################################## ### Gestion de la banlist ... utimer 30 timer_banlist set liste_bans_actifs "" proc timer_banlist {} { global liste_bans_actifs if [string match *timer_banlist* [utimers]] {return 0} utimer 30 timer_banlist set liste_bans_actifs "" putbot Aide "banlist" } bind bot - banlist bot_banlist proc bot_banlist {bot command args} { global liste_bans_actifs set liste_bans_actifs [lindex $args 0] timer_banlist_part2 } proc timer_banlist_part2 {} { global derniermenageban derniermenagetilde liste_bans_actifs set maxbantot 25 set liste $liste_bans_actifs if {[llength [split $liste ~]] > [expr $maxbantot - 4]} { putloglev 1 #Aide "Trop de bans de tildes sur #Aide ([llength [split $liste ~]]), j'ai banni complètement *!~*@* pour 10 minutes." newchanban #Aide "*!~*@*" Aide "Hum! Beaucoup trop de bans de tildes sur le canal: Je bloque!" 10 stick "*!~*@*" #Aide set derniermenagetilde [unixtime] foreach ban $liste { if [string match *~* $ban] { killchanban #aide $ban } } } if {[llength $liste] > $maxbantot} { putlog "Trop de bans sur #Aide ([llength $liste]), j'ai enlevé: [lrange $liste [expr $maxbantot -2] [expr $maxbantot + 3]]" putserv "mode #Aide -bbbbbb [lrange $liste [expr $maxbantot -2] [expr $maxbantot + 3]]" foreach ban [lrange $liste [expr $maxbantot -2] [expr $maxbantot + 3]] { killchanban #aide $ban killban $ban } set derniermenageban [unixtime] } set liste_bans_actifs "" } ################################################# # .etat bind dcc OJA etat dcc_etat proc dcc_etat {hand idx arg} { global derniercloneban derniermenageban derniermenagetilde activantispoof antispoof float setuser AideBot xtra etat "$derniercloneban $derniermenageban $derniermenagetilde $activantispoof" putdcc $idx "____________________________________________________________" putdcc $idx "=> Rapport d'état général du canal. <=" putdcc $idx "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" set ligne " Bots: Présents: " foreach bot "AideBot Aide CService" { if [onchan [hand2nick $bot] #aide] { append ligne "3" } else { append ligne "4" } append ligne " $bot" } putdcc $idx $ligne set ligne " Ops: #Aide +o/+v/non-idle: " set n 0 foreach user [chanlist #aide] { if {[matchattr [nick2hand $user] OJ] & ([isop $user #aide] | [isvoice $user #aide] | ([getchanidle $user #aide] < 20))} { incr n } } if {$n < 1} { append ligne "4 $n " } elseif {$n < 2} { append ligne "8 $n " } else { append ligne "3 $n " } putdcc $idx $ligne set ligne " Bans: Taille de la liste: " set lg [llength [banlist #aide]] if {$lg > 20} { append ligne "4" } elseif {$lg > 10} { append ligne "8" } else { append ligne "3" } append ligne " [llength [banlist #aide]]" putdcc $idx $ligne set lb [lindex [lindex [banlist #aide] 0] 3] if {$lb != ""} { set d [expr [unixtime] - $lb] if {$d > 60} { set coul "3" } elseif {$d > 25} { set coul "8" } else { set coul "4" } set db [lindex [lindex [banlist #aide] 0] 0] } else { set coul "3" set d 0 set db "aucun ban actif" } putdcc $idx " Dernier ban: $coul [dire_delai $d]  (2 $db )" set d [expr [unixtime] - $derniermenageban] if {$d > 1800} { set coul "3" } elseif {$d > 600} { set coul "8" } else { set coul "4" } putdcc $idx " Dernier ménage max: $coul [dire_delai $d]" set d [expr [unixtime] - $derniermenagetilde] if {$d > 1800} { set coul "3" } elseif {$d > 600} { set coul "8" } else { set coul "4" } putdcc $idx " Dernier ménage tildes:$coul [dire_delai $d]" set d [expr [unixtime] - [lindex $derniercloneban 1]] if {$d > 1800} { set coul "3" } elseif {$d > 600} { set coul "8" } else { set coul "4" } putdcc $idx " Clones: Dernière avalanche: $coul [dire_delai $d]  (2 [lindex $derniercloneban 0] )" set d [expr [unixtime] - $activantispoof] if {$d > 1800} { set coul "3" } elseif {$d > 600} { set coul "8" } else { set coul "4" } set ligne " Blocage des relais illicites: " if $antispoof { append ligne " 4 Actif" } else { append ligne " $coul [dire_delai $d]" } putdcc $idx $ligne set ligne " Gestion de la limite: " if $float(actif) { append ligne " 3 Active " } else { append ligne " 4 Inactive" } set buf [lindex [getchanmode #aide] 1] if ![estunnombre:ok $buf] { set buf "-" } append ligne " (2 [llength [chanlist #aide]] / $buf )" putdcc $idx $ligne putdcc $idx "____________________________________________________________" putdcc $idx "* Pour des statistiques plus détaillées, utilisez .rapport *" putdcc $idx "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" return 1 } # nbre usagers nbre + nbre bots (op?) + nbre ops / dernier kick / dernier ban heu.. autre chose? ########################################## # .limite (et surveillance de la limite) proc float_defaut { } { global float # putbot Aide "auth" set float(actif) 1 set float(freq) 10 set float(freqtop) 30 # putbot Aide "msg x set #aide floatperiod 20" set float(diff) 5 # putbot Aide "msg x set #aide floatmargin 5" set float(min) 2 set float(max) 2 set float(top) 1 # putbot Aide "msg x set #aide floatgrace 2" # putbot Aide "msg x set #aide floatlim on" set float(log) "..." } if ![info exist float] { utimer 30 { set float(actif) 1 set float(freq) [lindex [getuser AideBot xtra limite] 0] set float(diff) [lindex [getuser AideBot xtra limite] 1] set float(max) [lindex [getuser AideBot xtra limite] 2] set float(min) [lindex [getuser AideBot xtra limite] 3] set float(top) [lindex [getuser AideBot xtra limite] 4] set float(freqtop) [lindex [getuser AideBot xtra limite] 5] set float(log) "..." } utimer 40 timer_limite } bind dcc A limite dcc_limite proc dcc_limite {hand idx args} { global float set args [lindex $args 0] if {[lindex $args 0] == ""} { set lim [lindex [getchanmode #aide] 1] putdcc $idx "_____________________________________________" putdcc $idx "Système d'ajustement automatique de la limite" putdcc $idx "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" putdcc $idx " Limite actuelle: [llength [chanlist #aide]]/$lim" if $float(actif) { putdcc $idx " Différence souhaitée: $float(diff) ([expr [llength [chanlist #aide]] + $float(diff)])" putdcc $idx " Fréquence de vérification: aux $float(freq) secondes" putdcc $idx " Tolérance vers le bas: - $float(min) ([expr $lim - $float(diff) - $float(min)])" putdcc $idx " Tolérance vers le haut: + $float(max) ([expr $lim - $float(diff) + $float(max)])" putdcc $idx " Ajustement de canal plein: + $float(top)" putdcc $idx " Si plein, attente minimum: $float(freqtop) secondes" } else { putdcc $idx " Surveillance de la limite inactive" } putdcc $idx "_____________________________________________" putdcc $idx " Syntaxe? -> '.limite ?'" return 1 } elseif {$args == "-"} { float_defaut putdcc $idx "Paramètres de la surveillance de limite réinitialisée" timer_limite return 1 } elseif {$args == "on"} { set float(actif) 1 putdcc $idx "Activation de la surveillance de limite" timer_limite # putbot Aide "auth" # putbot Aide "msg x set #aide floatlim on" return 1 } elseif {$args == "off"} { set float(actif) 0 putdcc $idx "Désctivation de la surveillance de limite" pushmode #aide -l # putbot Aide "auth" # putbot Aide "msg x set #aide floatlim off" return 1 } regsub -all {\{|\}| } $args "" buf if {([llength $args] != 6) | ![estunnombre:ok $buf]} { putdcc $idx "## Syntaxe: .limite (pour voir l'état actuel)" putdcc $idx " ou .limite ? (pour ce message)" putdcc $idx " ou .limite (pour activer ou désactiver le controle du mode +l)" putdcc $idx " ou .limite " putdcc $idx " (pour ajuster les paramètres et activer)" putdcc $idx " ou .limite - (pour restaurer les options par défaut et activer)" putdcc $idx " fréquence: Nombre de secondes séparant chaque vérification d'état." putdcc $idx " Différence: Différence entre la limite et le nombre d'usagers." putdcc $idx " minimum: Tolérance d'écart vers le bas." putdcc $idx " maximum: Tolérance d'écart vers le haut." putdcc $idx " top: De combien monter la limite si on est au maximum?" putdcc $idx " fréqtop: Si la limite a été atteinte, attente avant prochaine vérification." return 0 } set freq [lindex $args 0] set diff [lindex $args 1] set min [lindex $args 2] set max [lindex $args 3] set top [lindex $args 4] set freqtop [lindex $args 5] if {($freq < 5) | ($freqtop < 5)} { putdcc $idx "Ajustements aux $freq secondes? Na, j'ai trop peur de me flooder... (minimum 5 secondes)" return 0 } if {($freq > 60) | ($freqtop > 60)} { putdcc $idx "Ajustements aux $freq secondes? Je ne crois pas que ce soit une bonne idée... (maximum 60 secondes)" return 0 } if {$diff < 3} { putdcc $idx "Ouch, une différence de $diff c'est bien trop serré! (minimum 3, 5 recommendé)" return 0 } if {$diff > 25} { putdcc $idx "Euh, et à quoi ça servirait une différence de $diff? C'est bien trop large! (maximum 25, 10 ou moins recommendé)" return 0 } if {$min > 20} { putdcc $idx "Hum, une différence de $min vers le bas me semble pas mal trop large... (maximum 20, 10 ou mains recommendé)" return 0 } if {$min < 2} { putdcc $idx "Hum, une différence de $min vers le bas est trop serré. (minimum 2)" return 0 } if {$max >= $diff} { putdcc $idx "Ouch, la différence vers le haut ($max) ne peut pas être égale ou dépasser la différence souhaitable ($diff)!" return 0 } if {$max < 2} { putdcc $idx "Hum, une différence de $max vers le haut est trop serré. (minimum 2)" return 0 } if {$top < 1} { putdcc $idx "Ben là, si on atteint la limite du canal, il faut quand même pouvoir l'augmenter ensuite! (top minimum de 1)" return 0 } if {$top >= $max} { putdcc $idx "Heu, un top ($top) est plus grand ou égal à la tolérance vers le haut ($max) n'a pas vraiment de sens..." return 0 } # putbot Aide "auth" set float(freq) [lindex $args 0] set float(freqtop) [lindex $args 5] if {$freq > 200} { set but 200 } elseif {$freq < 20} { set buf 20 } else { set buf $freq } # putbot Aide "msg x set #aide floatperiod [lindex $args 0]" set float(diff) [lindex $args 1] if {$diff > 20} { set but 20 } elseif {$diff < 2} { set buf 2 } else { set buf $diff } # putbot Aide "msg x set #aide floatmargin $buf" set float(min) [lindex $args 2] set float(max) [lindex $args 3] if {$min > $max} { set buf $min } else { set buf $max } # putbot Aide "msg x set #aide floatgrace $buf" set float(top) [lindex $args 4] setuser AideBot xtra limite "$float(freq) $float(diff) $float(max) $float(min) $float(top) $float(freqtop)" putlog "#$hand# limite -> Fréquence:$float(freq)\s Différence:$float(diff) Maximum:+$float(max) Minimum:-$float(min) Top:+$float(top) FreqTop:$float(freqtop)\s" return 0 } proc timer_limite { } { global float botnick if !$float(actif) {return 0} if ![botisop #Aide] { utimer $float(freq) timer_limite return 0 } set nombre [llength [chanlist #aide]] set limite [lindex [getchanmode #aide] 1] if {$nombre >= $limite} { if ![string match *timer_limite* [utimers]] { utimer $float(freqtop) timer_limite } pushmode #aide +l [expr $nombre + $float(top)] flushmode #aide set float(log) "{[time] +$nombre/$limite+} [lrange $float(log) 0 9]" if [string match *+* [lindex $float(log) 1]] { putlog "Oh? Limite atteinte deux fois de suite! Est-ce une attaque? ... Je log. -> $float(log)" foreach user [lrange [chanlist #aide] [expr [llength [chanlist #aide]] - $float(diff) - $float(min)] end] { if {[nick2hand $user] == "*"} { lappend tmp "$user![getchanhost $user]" } } exec echo "\[[date] à [time]\] $float(log)" >> /aide/www/admins/attaques.txt exec echo " -> Usagers inconnus récemment entrés: $tmp" >> /aide/www/admins/attaques.txt } else { putlog "Oh? Limite atteinte! Prudence... -> $float(log)" } } elseif {($nombre > [expr $limite - $float(diff) + $float(max)]) | ($nombre < [expr $limite -$float(diff) - $float(min)])} { if ![string match *timer_limite* [utimers]] { utimer $float(freq) timer_limite } pushmode #aide +l [expr $nombre + $float(diff)] set float(log) "{[time] $nombre/$limite} [lrange $float(log) 0 9]" } } bind time - "* * * * *" check_timer_lim proc check_timer_lim { a b c d e } { global float if {![string match *timer_limite* [utimers]] & $float(actif)} { timer_limite } } ####################################### # Présence sur des canaux illicites ... bind bot - 319 bot_319 proc bot_319 {from command args} { set args [lindex $args 0] set nick [lindex $args 0] set canaux [string tolower [lrange $args 1 end]] set survcanal [getuser AideBot xtra survcanal] regsub -all {#|#} $survcanal "#" survcanal set canauxnet "" foreach can $canaux { if {($can != "#aide") & ($can != "#igt") & ($can != "#cours")} { append canauxnet " #[lindex [split $can #] 1]" } } if ![matchattr [nick2hand $nick] pSWN] { exec echo $canauxnet >> stats.canaux.prov } foreach can $survcanal { if [string match "* $can *" " $canauxnet "] { agir_319 $nick $can $canaux return 0 } } } proc agir_319 {nick can canaux} { set hand [nick2hand $nick] if ![matchattr $hand pxZ] { set masque "*!*@[lindex [split [getchanhost $nick] @] 1]" putserv "MODE #Aide +b $masque" putserv "KICK #Aide $nick :Visite importune. Au revoir!" newchanban #Aide $masque AideBot "Visite importune. Au revoir!" 20 } if [matchattr $hand WS] { putlog "CANAL surveillé:4 $hand ($nick)  (Suspendu?) est entré sur #Aide, puis a été exclu. Il était sur $canaux ($can)" } elseif [matchattr $hand pxZ] { putlog "CANAL surveillé:7 [getuser $hand xtra vrainick] ($nick)  (Membre ou PUC) est entré sur #Aide, alors qu'il se trouvait également sur $canaux ($can) !?" } else { putlog "CANAL surveillé: $nick  a été automatiquement banni. Il était sur $canaux ($can)" } } bind dcc A survcanal dcc_survcanal proc dcc_survcanal {hand idx args} { set args [lindex $args 0] set survcanal [getuser AideBot xtra survcanal] set canal [string tolower [lindex $args 1]] if {[lindex $args 0] == "+"} { if [string match "* $canal *" " $survcanal "] { putdcc $idx "Cet élément est déjà dans la liste ..." return 0 } elseif {($canal != "") & (([string index $canal 0] == "#") | ([string range $canal 0 1] == "#") | ([string range $canal 0 1] == "#")) & ([string index $canal 1] != "")} { setuser AideBot xtra survcanal "$survcanal $canal" } } elseif {[lindex $args 0] == "-"} { if ![string match "* $canal *" " $survcanal "] { putdcc $idx "Cet élément n'est pas dans la liste ..." return 0 } else { set buf "" foreach can $survcanal { if {$can != $canal} { append buf " $can" } } setuser AideBot xtra survcanal $buf } } elseif {[lindex $args 0] != ""} { putdcc $idx "## Syntaxe: .survcanal \[<+|-> \]" return 0 } putdcc $idx "______________________________________" putdcc $idx "Liste des canaux maintenant surveillés:" putdcc $idx "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" set listesurv "" foreach can [getuser AideBot xtra survcanal] { append listesurv " $can" } putdcc $idx " ->$listesurv <-" putdcc $idx "______________________________________" return 1 }