### Qauth Autohost v0.4 script by CyBex, lastupdate 04.10.2004 # # !!! This script has a big problem with thommeys patch, please dont use it at moment !!! # # # This scripts add and remove autmatic hostmask to a handle # # Commands: (only Partyline supportet) # qauth [*whois*|auth|perm|temp] : show details about user, default is whois and it work .qauth # qwhois : is alternative command, if you dont extend the whois partyline command # qmatch : list every user with the auth # qnoauth : list every user without auth # -quser : remove a user from userfile # +quser : add user and qauth to userfile # -qauth : remove auth from user # +qauth : add auth to user # addqauth : do the same like +qauth # -phost : remove permanent hostmask from user # +phost : add permanent hostmask to user # addphost : do the same like +phost # -thost : remove temporary hostmask from user # +thost : add temporary hostmask to user # deloldhost : remove hostmask from user, that not added by this script except telnet # delallhost : remove all hostmask from user except telnet - everything gets refreshed # qreload # qhelp : this text # # This script include two procs from thommeys example script with small changes # and the maskhost-fix is included and a litte changed for non idented users # # To download the patch visit http://sonys.de/thommey/eggdrop.html # # Q: How to use? # Wie benutzt man das Script? # A: Thats depends a litte if you add a newuser or change an old # das is abhängig, ob man einen neuen user hinzufügt oder einen alten veränder # 1: add the user (best with .+user , because adduser take the hostmask from channel) !! Only with new user required !! # Füge einen User hinzu # 2: when you have two users with the same ident@host, add a perm hostmask to both handles, like .+phost handle *nick1*!ident@host (permhost stay longer up in the user and have higher prio, you must know what your do!) # Wenn du 2 getrennte User mit dem gleichen ident@host hast, adde bei beiden eine perm hostmask, wie zB *nick*!ident@host # 3: add the quakenet auth to the user. .+qauth (you can add more then one auth, but only 1 auth in one step at moment, even later) # Füge zu dem User einen Qaukenet Auth hinzu. (Du kannst mehr als einen adden, aber nur einen pro Command) # 4: look with .qauth | every (X) marked hostmask is known by the script and get auto added/removed | every (!) is an old hostmask or added with .+host, they leave untouched in normal run | every (-) marked is a telnet. thats everytime untouched. # Guck mit ... | Jede (X) markierte hostmask is dem Script bekannt und wird automatisch geadded/entfernt | Jede Hostmask mit (!) is eine normale, von Hand hinzugefühgte Hostmask. # 5: when it is an old user, you can remove every (!) marked hostmask with .deloldhost | .delallhost remove all hostmask, this is like an init, every hostmask get fresh auto added !! Only with old user required !! # Wenn es ein alter User ist, können alle Hostmask mit (!) entfernt mit .deloldhost werden | .delallhost entfernt alle Hostmasks, so ähnlich wie ein neuer User, jede Hostmask wird wieder frisch automatisch hinzugefügt # # Q: Why not handle equal to quakenet auth required? # Warum wird kein Handle der gleich dem QuaketNet Auth ist gebraucht/gemacht? (default bei thommeys patch) # A: Because some bots have installed stats.mod and there is the Handle in use also. # Weil einige Bots zB das stats.mod benutzen und dort wird das Handle auch als Name für die Statistiken benutzt. # # Q: Work it with a Botnet? # A: Yes, when you share userfiles, you need only one or two qauth scanner, because every hostmask get automatic shared # Ja, wenn Userfile gemeinsam genutzt wird, brauch man nur einen Qaukenet Auth Scanner, jeder ander Bot bekommt die Hostmask automatisch durchs teilen. # # Q: How does this script work? # A: Sometimees and if someone is unknown and the bot "who #chan/nick" and catch the result. When some user match with the qauth, the bot compares the hostmask and add temp (stay default 3 hour when unseen) or *.user.quakenet.org perm (stay default 1 week) # Manchmal (per Zeit) und wenn jemand unbekannt ist, macht der Bot ein WHO und fängt das Ergebnis ab. Wenn ein User mit dem Auth übereinstimmt, vergleicht der Bot die hostmask und fügt sie temporär oder permanent zum User hinzu. # # Q: How fast is it? # A: When no netsplit and lag, it require 1 or 2 minutes to add the hostmask, but you can speed it up with a utimer loop (but dont go lower then 5-10 secs) and WHO the chan. And now it scans on join. # Wenn gerade kein Netzsplit oder Lag ist, dauernts normalerweise keine Minute bis alle User bekannt sind. Aber man kann die Geschwindigkeit auch erhöhen durch eine Schleife. # # Created on 17.09.2004 # Release 19.09.2004 # Lastupdate 04.10.2004 # # Changelog v0.1 -> v0.4 # ! Bugfixes with update lastseen # + Added onjoin check # + Added commands # dirty quick fix, if the patch isn't loaded if {[info command getchanlogin]==""} { putlog "\002WARNING!\002 thommeys patch not found, build procs in Tcl" proc getchanlogin {nick {channel ""}} { if [info exist ::CyQauths($nick)] {return $::CyQauths($nick)} return 0 } } if {[info command getchanlogin]==""} { putlog "WARNING, cant find thommeys quakenet eggdrop patch" return } if {![info exist use-354]} { putlog "variable use-354 dont exists, created!"; set use-354 1 } elseif {${use-354}!=1} { putlog "variable use-354 is 0, set to 1!"; set use-354 1 } namespace eval {::qauthautohost::} { ### config ### variable logaddremove 1 ; # 0 = off // 1 = on = show public how to add/remove hosts to user variable extendwhois 1 ; # 0 = off // 1 = on = extend the partyline .whois command variable removeperm 604800 ; # remove unused perm hosts after X seconds (minimum 1000 required) (default 604800 / 1 week) variable removetemp 21600 ; # remove unused perm hosts after X seconds (minimum 1000 required) (default 21600 / 6 hours) ### end of config ## bind dcc t|m qauth {::qauthautohost::cybex:dcccmd qnet} bind dcc t|m qhelp {::qauthautohost::cybex:dcccmd qhelp} bind dcc t|m qreload {::qauthautohost::cybex:dcccmd reload} bind dcc t|m qwhois {::qauthautohost::cybex:dcccmd whois} bind dcc t|m qmatch {::qauthautohost::cybex:dcccmd match} bind dcc t|m qnoauth {::qauthautohost::cybex:dcccmd noauth} bind dcc t|m qlongseen {::qauthautohost::cybex:dcccmd noseen} bind dcc t|m qmanyhost {::qauthautohost::cybex:dcccmd manyhost} bind dcc t|m qwho {::qauthautohost::cybex:dcccmd who} bind dcc t|m +quser {::qauthautohost::cybex:dcccmd quser:add} bind dcc t|m -quser {::qauthautohost::cybex:dcccmd quser:remove} bind dcc t|m +qauth {::qauthautohost::cybex:dcccmd qauth:add} bind dcc t|m -qauth {::qauthautohost::cybex:dcccmd qauth:remove} bind dcc t|m +phost {::qauthautohost::cybex:dcccmd perm:add} bind dcc t|m -phost {::qauthautohost::cybex:dcccmd perm:remove} bind dcc t|m +thost {::qauthautohost::cybex:dcccmd temp:add} bind dcc t|m -thost {::qauthautohost::cybex:dcccmd temp:remove} bind dcc t|m addqauth {::qauthautohost::cybex:dcccmd qauth:add} bind dcc t|m addphost {::qauthautohost::cybex:dcccmd perm:add} bind dcc t|m delallall {::qauthautohost::cybex:dcccmd host:remove:all:all} bind dcc t|m delallold {::qauthautohost::cybex:dcccmd host:remove:all:old} bind dcc t|m deloldhost {::qauthautohost::cybex:dcccmd host:remove} bind dcc t|m remoldhost {::qauthautohost::cybex:dcccmd host:remove} bind dcc t|m delallhost {::qauthautohost::cybex:dcccmd host:remove:all} bind dcc t|m remallhost {::qauthautohost::cybex:dcccmd host:remove:all} ## comment the next line, if you want to use the lol-toolz .whois if {$extendwhois} {bind dcc -|- whois {::qauthautohost::cybex:dcccmd whois}} {bind dcc -|- whois *dcc:whois} bind raw - 354 ::qauthautohost::cybex:raw354 bind join - * ::qauthautohost::cybex:join bind time - "58 *" ::qauthautohost::cybex:checktime bind time - "13 *" ::qauthautohost::cybex:checktime bind time - "28 *" ::qauthautohost::cybex:checktime bind time - "43 *" ::qauthautohost::cybex:checktime #unbind time - * ::qauthautohost::cybex:checktime #unbind time - "58 *" ::qauthautohost::cybex:checktime #unbind time - "13 *" ::qauthautohost::cybex:checktime #unbind time - "28 *" ::qauthautohost::cybex:checktime #unbind time - "43 *" ::qauthautohost::cybex:checktime #bind time - * ::qauthautohost::cybex:checktime bind time - * ::qauthautohost::thommey:refresh_time bind evnt - connect-server ::qauthautohost::cybex:delay if {$removeperm<1000} {set removeperm 1000} if {$removetemp<1000} {set removetemp 1000} variable script [info script] proc cybex:dcccmd {what from idx text} { set arg0 [lindex [split $text] 0] set arg1 [lindex [split $text] 1] switch -exact -- $what { reload { variable script uplevel #0 [subst -nocommand {source $script}] } who { if {$arg0==""} {putdcc $idx "Usage: $::lastbind "; return 0} #putlog "WHO $arg0" ##### puthelp "WHO $arg0 n%hnua" } noauth { set ulist [list] foreach user [lsort -dic [userlist]] { if {[getuser $user xtra qauths]==""} { lappend ulist $user #cybex:dcccmd whois $from $idx $user } } putdcc $idx [join [lsort -dic $ulist] ", "] } noseen { foreach user [lsort -dic [userlist]] { if {[getuser $user xtra qauths]==""} { set year [clock scan "-1year"] set globls [getuser $user laston]; set berls [getuser $user laston #berlin]; set otherls [list]; foreach ch [channels] { if {$ch!="#berlin" && [set other [getuser $user laston $ch]]!="" && $other!="0"} {lappend otherls "$ch $other"} } if {$globls=="" && $berls=="" && $otherls==[list]} { putdcc $idx "Never seen $user ($berls)" #cybex:dcccmd whois $from $idx $user #deluser $user } { #putdcc $idx "$user seen $globls ($berls) \[$otherls\]" } } } } manyhost { foreach user [lsort -dic [userlist]] { if {[llength [set hsts [getuser $user hosts]]]>3} { putcmdlog "$user has [llength $hsts] hosts" } } } match { foreach user [userlist] { if {[set qauth [getuser $user xtra qauths]]!="" && [string match -nocase *$arg0* $qauth]} { cybex:dcccmd whois $from $idx $user } } } whois { *dcc:whois $from $idx $text if [validuser $arg0] { set hand $arg0 if {$hand!="*" || $arg0=="whois"} { set hlist [list] set qauths [getuser $hand xtra qauths] set thosts [getuser $hand hosts] set tphosts [getuser $hand xtra permhosts] set tttthosts [getuser $hand xtra] if {$qauths!=[list]} { putdcc $idx " \002$hand\002 has the following auth(s): \002[join $qauths ", "]\002" } { putdcc $idx " \002$hand\002 has \002no\002 auth" } set i 0; set list [list] foreach {host time} $tphosts { if {![string is digit -strict $time]} {set time [unixtime]} #putcmdlog "host: -$host- time: -$time-" set txt "" if {$i==0} {set txt " Inactive perm host: "} {set txt " "} if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host; set akttxt "(X)"} { incr i set akttxt "" append txt "$akttxt $host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]])" lappend list $txt } } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} set i 0; set list [list] foreach ttthosts $tttthosts { if {[string match -nocase temp*hosts* $ttthosts]} { set txt "" foreach {thname tthosts} $ttthosts { foreach {host time ctime} $tthosts { if {![string is digit -strict $time]} {set time [unixtime]} if {![string is digit -strict $ctime]} {set ctime [unixtime]} if {$i==0} {set txt " Inactive temp host: "} {set txt " "} if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host; set akttxt "(X)"} { incr i set akttxt "" append txt "$akttxt $host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]]), created: [clock format $ctime -format "%H:%M %d.%m.%Y"] (since [duration [expr {[unixtime]-$ctime}]])" lappend list $txt } } } } } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} set i 0; set list [list] foreach host $thosts { set txt "" if {$i==0} {set txt " HOST: "} {set txt " "} if {[lsearch [string tolower $hlist] [text2pattern [string tolower $host]]]!=-1} {set akttxt "(X)"} { if {[string match -nocase "-telnet!*@*" $host]} {set akttxt "(-)"} { incr i set akttxt "(!)" append txt "$akttxt $host" lappend list $txt } } } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} } } return 0 } qhelp { putdcc $idx "This scripts add and remove autmatic hostmask to a handle" putdcc $idx " " putdcc $idx "Commands: (only Partyline supportet)" putdcc $idx "qauth \[\002whois\002|auth|perm|temp] : show details about user, default is whois and it work .qauth " putdcc $idx "qwhois : is alternative command, if you dont extend the whois partyline command" putdcc $idx "-qauth : remove auth from user" putdcc $idx "+qauth : add auth to user" putdcc $idx "addqauth : do the same like +qauth" putdcc $idx "-phost : remove permanent hostmask from user" putdcc $idx "+phost : add permanent hostmask to user" putdcc $idx "addphost : do the same like +phost" putdcc $idx "-thost : remove temporary hostmask from user" putdcc $idx "+thost : add temporary hostmask to user" putdcc $idx "deloldhost : remove hostmask from user, that not added by this script except telnet" putdcc $idx "delallhost : remove all hostmask from user except telnet - everything gets refreshed" } qnet { if {$arg0==""} {putdcc $idx "Usage: qauth \[\002whois\002|auth|perm|temp] "; return 0} set hand "*" if {[validuser $arg1] && $hand=="*"} {set hand $arg1} if {[validuser $arg0] && $hand=="*"} {set hand $arg0} if {$hand=="*"} {putdcc $idx "can't find a valid user in $text!"; return 0} switch -exact -- $arg0 { auth { set qauths [getuser $hand xtra qauths] if {$qauths!=[list]} { putdcc $idx "\002$hand\002 has this qauths \002[join $qauths ", "]\002" } { putdcc $idx "\002$hand\002 has \002no\002 qauths" } } perm { set qauths [getuser $hand xtra qauths] set tphosts [getuser $hand xtra permhosts] if {$qauths!=[list]} { putdcc $idx "\002$hand\002 has this qauths \002[join $qauths ", "]\002" } { putdcc $idx "\002$hand\002 has \002no\002 qauths" } set i 0; set list [list] foreach {host time} $tphosts { incr i; set txt "" if {$i==1} {set txt "PERM: "} {set txt " "} append txt "$host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]])" lappend list $txt } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} } temp { set qauths [getuser $hand xtra qauths] set tttthosts [getuser $hand xtra] if {$qauths!=[list]} { putdcc $idx "\002$hand\002 has this qauths \002[join $qauths ", "]\002" } { putdcc $idx "\002$hand\002 has \002no\002 qauths" } set i 0; set list [list] foreach ttthosts $tttthosts { if {[string match -nocase temp*hosts* $ttthosts]} { incr i; set txt "" foreach {thname tthosts} $ttthosts { foreach {host time ctime} $tthosts { if {$i==1} {set txt "TEMP: "} {set txt " "} append txt "$host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]]), created: [clock format $ctime -format "%H:%M %d.%m.%Y"] (since [duration [expr {[unixtime]-$ctime}]])" lappend list $txt } } } } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} } default { if {$hand!="*" || $arg0=="whois"} { set hlist [list] set qauths [getuser $hand xtra qauths] set thosts [getuser $hand hosts] set tphosts [getuser $hand xtra permhosts] set tttthosts [getuser $hand xtra] if {$qauths!=[list]} { putdcc $idx "\002$hand\002 has this qauths \002[join $qauths ", "]\002" } { putdcc $idx "\002$hand\002 has \002no\002 qauths" } set i 0; set list [list] foreach {host time} $tphosts { incr i; set txt "" if {$i==1} {set txt "PERM: "} {set txt " "} if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host; set akttxt "(X)"} {set akttxt " - "} append txt "$akttxt $host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]])" lappend list $txt } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} set i 0; set list [list] foreach ttthosts $tttthosts { if {[string match -nocase temp*hosts* $ttthosts]} { incr i; set txt "" foreach {thname tthosts} $ttthosts { foreach {host time ctime} $tthosts { if {$i==1} {set txt "TEMP: "} {set txt " "} if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host; set akttxt "(X)"} {set akttxt " - "} append txt "$akttxt $host, [clock format $time -format "%H:%M %d.%m.%Y"] (not seen since [duration [expr {[unixtime]-$time}]]), created: [clock format $ctime -format "%H:%M %d.%m.%Y"] (since [duration [expr {[unixtime]-$ctime}]])" lappend list $txt } } } } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} set i 0; set list [list] foreach host $thosts { incr i; set txt "" if {$i==1} {set txt "HOST: "} {set txt " "} if {[lsearch [string tolower $hlist] [text2pattern [string tolower $host]]]!=-1} {set akttxt "(X)"} { if {[string match -nocase "-telnet!*@*" $host]} {set akttxt "(-)"} {set akttxt "(!)"} } append txt "$akttxt $host" lappend list $txt } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} } { putdcc $idx "can't find a valid user in $text!"; return 0 } ; # hand != * } } ; # switch } # qnet quser:add { if {$arg1==""} {putdcc $idx "Usage: +quser "; return 0} if {[validuser $arg0]} {putdcc $idx "$arg0 allready exists!"; return 0} adduser $arg0 set qauths [getuser $arg0 xtra qauths] if {[lsearch [string tolower $qauths] [text2pattern [string tolower $arg1]]]!=-1} {putdcc $idx "$arg1 has allready added to $arg0"} {lappend qauths $arg1; setuser $arg0 xtra qauths $qauths; putdcc $idx "added $arg0 and $arg1 qauth"} } quser:remove { if {$arg1==""} {putdcc $idx "Usage: -quser "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} set qauths [getuser $arg0 xtra qauths] deluser $arg0 putdcc $idx "removed $arg0 from userfile" } qauth:add { if {$arg1==""} {putdcc $idx "Usage: +qauth "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} set qauths [getuser $arg0 xtra qauths] if {[lsearch [string tolower $qauths] [text2pattern [string tolower $arg1]]]!=-1} {putdcc $idx "$arg1 has allready added to $arg0"} {lappend qauths $arg1; setuser $arg0 xtra qauths $qauths; putdcc $idx "added $arg1 qauth to $arg0"} } qauth:remove { if {$arg1==""} {putdcc $idx "Usage: -qauth "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} set qauths [getuser $arg0 xtra qauths] if {[set pos [lsearch [string tolower $qauths] [text2pattern [string tolower $arg1]]]]!=-1} {set qauths [lreplace $qauths $pos $pos]; setuser $arg0 xtra qauths $qauths; putdcc $idx "removed $arg1 qauth from $arg0"} {putdcc $idx "$arg1 not found from $arg0"} } perm:add { if {$arg1==""} {putdcc $idx "Usage: +phost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} if {![string match *!*@* $arg1]} {putdcc $idx "$arg1 is not a valid hostmask!"; return 0} set permhosts [getuser $arg0 xtra permhosts] if {[lsearch [string tolower $permhosts] [text2pattern [string tolower $arg1]]]!=-1} {putdcc $idx "$arg1 has allready added to $arg0"} {lappend permhosts $arg1 [clock second]; setuser $arg0 xtra permhosts $permhosts; addhost $arg0 $arg1; putdcc $idx "added $arg1 permhost to $arg0"} } perm:remove { if {$arg1==""} {putdcc $idx "Usage: -phost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} if {![string match *!*@* $arg1]} {putdcc $idx "$arg1 is not a valid hostmask!"; return 0} set permhosts [getuser $arg0 xtra permhosts] if {[set pos [lsearch [string tolower $permhosts] [text2pattern [string tolower $arg1*]]]]!=-1} {set permhosts [lreplace $permhosts $pos [expr {1+$pos}]]; setuser $arg0 xtra permhosts $permhosts; delhost $arg0 $arg1; putdcc $idx "removed $arg1 permhost from $arg0"} {putdcc $idx "$arg1 not found from $arg0"} } temp:add { if {$arg1==""} {putdcc $idx "Usage: +thost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} if {![string match *!*@* $arg1]} {putdcc $idx "$arg1 is not a valid hostmask!"; return 0} set i 0; set done 0; set free 0 for {set i 0} {$i<9999 && !$done} {incr i} { if {[getuser $arg0 xtra temp${i}hosts]!=[list]} { set host [lindex [getuser $arg0 xtra temp${i}hosts] 0]; if {[string match -nocase $arg1 $host] || [string match -nocase [text2pattern $host] $arg1] || [string equal $host $arg1]} {set done 1} } {if {$free==0} {set free $i}} } if {$done==1} { putdcc $idx "$arg1 has allready added to $arg0" } { set temphosts [list $arg1 [clock second] [clock second]] setuser $arg0 xtra temp${free}hosts $temphosts; addhost $arg0 $arg1; putdcc $idx "added $arg1 temphost to $arg0 ($free)" } #set qauths [getuser $arg0 xtra qauths] #if {[lsearch [string tolower $qauths] [text2pattern [string tolower $arg1]]]!=-1} {putdcc $idx "$arg1 has allready added to $arg0"} {lappend qauths $arg1; setuser $arg0 xtra qauths $qauths; putdcc $idx "added $arg1 qauth to $arg0"} } temp:remove { if {$arg1==""} {putdcc $idx "Usage: -thost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} #set qauths [getuser $arg0 xtra qauths] #if {[set pos [lsearch [string tolower $qauths] [text2pattern [string tolower $arg1]]]]!=-1} {set qauths [lreplace $qauths $pos $pos]; setuser $arg0 xtra qauths $qauths; putdcc $idx "removed $arg1 qauth from $arg0"} {putdcc $idx "$arg1 not found from $arg0"} set i 0; set done 0; set free 0 for {set i 0} {$i<9999 && !$done} {incr i} { if {[getuser $arg0 xtra temp${i}hosts]!=[list]} { set host [lindex [getuser $arg0 xtra temp${i}hosts] 0]; if {[string match -nocase $arg1 $host] || [string match -nocase [text2pattern $host] $arg1] || [string equal $host $arg1]} {set done 1; if {$free==0} {set free $i}} } } if {$done==1} { #set temphosts [list $arg1 [clock second] [clock second]] putdcc $idx "removed $arg1 temphost from $arg0 ($free)" setuser $arg0 xtra temp${free}hosts "" delhost $arg0 $arg1; } { putdcc $idx "$arg1 not found from $arg0" } } host:remove:all:old { foreach usr [userlist] { if {[getuser $usr xtra qauths]!=""} { cybex:dcccmd host:remove $from $idx $usr } } } host:remove:all:all { foreach usr [userlist] { if {[getuser $usr xtra qauths]!=""} { cybex:dcccmd host:remove:all $from $idx $usr } } } host:remove:all { if {$arg0==""} {putdcc $idx "Usage: delallhost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} set thosts [getuser $arg0 hosts]; putcmdlog "remove all hosts from $arg0" if {[set pos [lsearch [string tolower $thosts] *-telnet*]]!=-1} {set telnet [lindex $thosts $pos]} {set telnet ""} setuser $arg0 hosts; if {$telnet!=""} {addhost $arg0 $telnet; cybex:dcccmd perm:add $from $idx "$arg0 $telnet"} } host:remove { if {$arg0==""} {putdcc $idx "Usage: deloldhost "; return 0} if {![validuser $arg0]} {putdcc $idx "$arg0 is not a valid user!"; return 0} set hand $arg0 if {$hand!="*" || $arg0=="whois"} { set hlist [list]; set qauths [getuser $hand xtra qauths]; set thosts [getuser $hand hosts]; set tphosts [getuser $hand xtra permhosts]; set tttthosts [getuser $hand xtra] foreach {host time} $tphosts {if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host}} foreach ttthosts $tttthosts { if {[string match -nocase temp*hosts* $ttthosts]} { foreach {thname tthosts} $ttthosts { foreach {host time ctime} $tthosts {if {[lsearch [string tolower $thosts] [text2pattern [string tolower $host]]]!=-1} {lappend hlist $host}} } } } set i 0; set list [list] foreach host $thosts { incr i; set txt "" if {$i==1} {set txt "HOST: "} {set txt " "} if {[lsearch [string tolower $hlist] [text2pattern [string tolower $host]]]==-1} {if {![string match -nocase "-telnet!*@*" $host]} {delhost $arg0 $host; putcmdlog "remove $host from $arg0"}} } if {$list!=[list]} {putdcc $idx "[join $list "\n"]"} } } default {putdcc $idx "Unknown DCC-CMD $what, from $from"} return 1 } if {[validuser $arg0] && [set n [hand2nick $arg0]]!="" && $n!="*"} { ##### puthelp "WHO $n n%hnua" } return 1 } proc cybex:checkusr {nick uhost hand auth} { set found 0; set thost [list] #if {[string match -nocase *ber* $uhost]} {putcmdlog "finduser $hand ($nick!$uhost) \[$auth]"} foreach usr [userlist ] { set getauth "" if {[set getauth [getuser $usr xtra qauths]]!="" && [lsearch -exact [string tolower $getauth] [string tolower $auth]]!="-1"} { incr found 1; if {$found==1} {set fauth $getauth; set fusr $usr} if {[lsearch $thost [text2pattern $usr]]==-1} {lappend thost $usr} } } set tfound 0; set ttfound 0; if {$found>1} { set ttfound 0 foreach usr [userlist ] { set tfound 0 if {[set getauth [getuser $usr xtra qauths]]!="" && [lsearch -exact [string tolower $getauth] [string tolower $auth]]!="-1"} { foreach thosts [getuser $usr hosts] { if {[string match -nocase [text2pattern $thosts] $nick!$uhost]} {incr tfound; incr ttfound; set fauth $getauth; set fusr $usr} } foreach {host lastseen} [getuser $usr xtra permhosts] { if {[string match -nocase [text2pattern $host] $nick!$uhost]} {incr tfound; incr ttfound; set fauth $getauth; set fusr $usr} } } } } #if {$found>1} {putcmdlog "found $found - tfound $tfound - ttfound $ttfound - usr $fusr - fauth $fauth"} if {$found!=1 && $ttfound>0} {set found 1} if {$found==1} { set hfound 0 foreach host [getuser $fusr hosts] { #putcmdlog "string match -nocase p:[text2pattern $host] hm:$nick!$uhost ($hand) == [string match -nocase [text2pattern $host] $nick!$uhost]" if {[string match -nocase [text2pattern $host] $nick!$uhost]} {set hfound 1} } if {$hfound=="0"} { foreach {host lastseen} [getuser $fusr xtra permhosts] { if {[string match -nocase [text2pattern $host] $nick!$uhost]} { variable logaddremove if {$logaddremove=="1"} {putlog "add permhost $host to user $fusr // n:$nick uh:$uhost h:$hand a:$auth"} addhost $fusr $host set hfound 1 } } if {$hfound=="0" && [string match -nocase *!*@*.users.quakenet.org $nick!$uhost]} { set addhost [maskhost $nick!$uhost] set permhosts [getuser $fusr xtra permhosts] if {[lsearch [string tolower $permhosts] [text2pattern [string tolower $addhost]]]==-1} { lappend permhosts $addhost [clock second] variable logaddremove if {$logaddremove=="1"} {putlog "append permhosts with $addhost and add host $addhost to user $fusr // n:$nick uh:$uhost h:$hand a:$auth"} setuser $fusr xtra permhosts $permhosts addhost $fusr $addhost } set hfound 1 } if {$hfound=="0"} { set addhost [maskhost $nick!$uhost] set i 0; set done 0 for {set i 0} {$i<9999 && !$done} {incr i} { if {[getuser $fusr xtra temp${i}hosts]!=[list]} { set host [lindex [getuser $fusr xtra temp${i}hosts] 0]; if {[string match -nocase [text2pattern $addhost] $host] || [string match -nocase [text2pattern $host] $addhost] || [string equal $host $addhost]} { variable logaddremove if {$logaddremove=="1"} {putlog "remove lastseen ${i} // n:$nick uh:$uhost h:$hand a:$auth"} setuser $fusr xtra temp${i}hosts } } } } if {$hfound=="0"} { #set addhost [maskhost $nick!$uhost] set addhost *![string map [list ~ \?] $uhost] set i 0; set done 0 for {set i 0} {$i<9999 && !$done} {incr i} { if {[getuser $fusr xtra temp${i}hosts]==[list]} { variable logaddremove if {$logaddremove=="1"} {putlog "addhost $fusr $addhost - temp${i}hosts is free /1/ n:$nick uh:$uhost h:$hand a:$auth"} setuser $fusr xtra temp${i}hosts [list $addhost [clock second] [clock second]] addhost $fusr $addhost set done 1 }; # if getuser }; # for } } { set found 0 # if $found==0 foreach {host lastseen} [getuser $fusr xtra permhosts] { if $found continue if {[string match -nocase [text2pattern $host] $nick!$uhost]} { set phosts [getuser $fusr xtra permhosts] set num [lsearch -exact [string tolower $phosts] [string tolower $host]] if {$num!=-1} { set found 1 set inc [expr 1+$num] set phosts [lreplace $phosts $inc $inc [clock second]] #variable logaddremove #if {$logaddremove=="1"} {putlog "usr: update perm lastseen $fusr $host // n:$nick uh:$uhost h:$hand a:$auth"} setuser $fusr xtra permhosts $phosts } } } if {$found==0} {foreach temp [getuser $fusr xtra] { foreach {thost tval} $temp { if {[string match -nocase temp*hosts $thost]} { foreach {hostmask lastseen created} $tval { if $found continue if {[string match -nocase [text2pattern $hostmask] $nick!$uhost]} { set found 1 #variable logaddremove #if {$logaddremove=="1"} {putlog "usr: update temp lastseen $fusr $hostmask // n:$nick uh:$uhost h:$hand a:$auth"} set tval [lreplace $tval 1 1 [clock second]] setuser $fusr xtra $thost $tval } } ; # foreach host } ; # if } ; # foreach thost } } ; # foreach temp / if }; # if $hfound==0 } { # else if $found #if {$found==0} {putcmdlog "no user found for $nick!$uhost ($hand/\002$auth\002)"} if {$found>=2} { if {[set lastwarn [getuser $fusr xtra lastqawarn]]=="" || ![string is integer $lastwarn]} {putcmdlog "init lastwarn for $fusr"; set lastwarn [expr [clock second]-10080]; setuser $fusr xtra lastqawarn $lastwarn} if {[expr [clock second]-$lastwarn]>=10080} { putlog "more then one user ([join $thost ", "]) found with this qauth ($auth), need manual host adjust $nick!$uhost ($hand/$fusr)" setuser $fusr xtra lastqawarn [clock second] } } } ; # if $found } proc cybex:del:CyQauths {name} { if [info exist ::CyQauths($name)] { if [info exists ::CyQauths($name:lastused)] {unset ::CyQauths($name:lastused)} unset ::CyQauths($name) return 1 } {return 0} } proc cybex:ren:CyQauths {name newname} { if [info exist ::CyQauths($name)] { if [info exists ::CyQauths($name:lastused)] {unset ::CyQauths($name:lastused)} set ::CyQauths($newname) $::CyQauths($name) set ::CyQauths($newname:lastused) [clock sec] unset ::CyQauths($name) return 1 } {return 0} } bind nick - * [namespace current]::cybex:nickch proc cybex:nickch {nick uh h chan new} { set res [cybex:ren:CyQauths $nick $new] if $res {putcmdlog "$nick nick $res $new"} } bind part - * [namespace current]::cybex:part proc cybex:part {nick args} { set res [cybex:del:CyQauths $nick] if $res {putcmdlog "$nick part $res $args"} } bind sign - * [namespace current]::cybex:sign proc cybex:sign {nick args} { set res [cybex:del:CyQauths $nick] if $res {putcmdlog "$nick sign $res $args"} } proc cybex:checktime args { putcmdlog "cybex:checktime $args" set now [clock sec] foreach {name value} [array get ::CyQauths *:lastused] { if {$now-$value>3600} { set nick [lindex [split $name :] 0] unset -nocomplain ::CyQauths($nick) unset -nocomplain ::CyQauths($name) putcmdlog "delete $nick (too old [duration [expr {$now-$value}]]) (name:$name value:$value)" } } foreach {name value} [array get ::CyQauths] { if [string match *:lastused $name] continue if ![info exist ::CyQauths($name:lastused)] { unset -nocomplain ::CyQauths($name) putcmdlog "delete $name (no lastused)" } } foreach ch [channels] {if [botonchan $ch] { ##### puthelp "WHO $ch c%hnua" }} foreach usr [userlist] { set chkhosts [list] set permhosts [list] set temphosts [list] set oldhosts [list] set usrhosts [getuser $usr hosts] set found 0 foreach {host lastseen} [set phosts [getuser $usr xtra permhosts]] { if {[lsearch [string tolower $usrhosts] [text2pattern [string tolower $host]]]!=-1} { set tnick [hand2nick $usr] if {$tnick!="" && $tnick!="*"} { set tuhost [getchanhost $tnick] #update timestamp if {[string match -nocase [text2pattern $host] $tnick!$tuhost] && $found==0} { set found 1 set pos [lsearch [string tolower $phosts] [string tolower $host*]]; set inc [expr {1+$pos}] #variable logaddremove #if {$logaddremove=="1"} {putlog "time: perm update lastseen $usr perm $host"} setuser $usr xtra permhosts [lreplace $phosts $inc $inc [clock sec]] } #remove old variable removeperm if {[clock seconds]-$lastseen>$removeperm && ![string match *-telnet*!*@* $host]} { variable logaddremove if {$logaddremove=="1"} {putlog "$usr to old perm $host $lastseen [duration [expr [clock sec]-$lastseen]] // n:$tnick"} delhost $usr $host lappend oldhosts $host } } } } #set found 0 foreach temp [getuser $usr xtra] { foreach {thost tval} $temp { if {[string match -nocase temp*hosts $thost]} { foreach {hostmask lastseen created} $tval { #update timestamp if {[lsearch [string tolower $usrhosts] [text2pattern [string tolower $hostmask]]]!=-1} { # # set tnick [hand2nick $usr] if {$tnick!="" && $tnick!="*"} { set tuhost [getchanhost $tnick] #update timestamp if {[string match -nocase [text2pattern $hostmask] $tnick!$tuhost] && $found==0} { set found 1 #variable logaddremove #if {$logaddremove=="1"} {putlog "time: temp update lastseen $usr temp $hostmask"} setuser $usr xtra $thost [list $hostmask [clock second] $created] } #remove old variable removetemp #putcmdlog "[expr [clock seconds]-$lastseen]>$removetemp && ![string match *-telnet*!*@* $hostmask] $usr $hostmask" if {[clock seconds]-$lastseen>$removetemp && ![string match *-telnet*!*@* $hostmask]} { variable logaddremove if {$logaddremove=="1"} {putlog "$usr to old temp $hostmask [duration [expr [clock sec]-$lastseen]] ($thost) // n:$tnick"} delhost $usr $hostmask setuser $usr xtra $thost lappend oldhosts $hostmask } } { variable removetemp #putcmdlog "[expr [clock seconds]-$lastseen]>$removetemp && $found==0 $usr $hostmask" if {[clock seconds]-$lastseen>$removetemp && ![string match *-telnet*!*@* $hostmask] && $found=="0"} { variable logaddremove if {$logaddremove=="1"} {putlog "$usr to old temp $hostmask [duration [expr [clock sec]-$lastseen]] ($thost) // n:$tnick"} delhost $usr $hostmask setuser $usr xtra $thost lappend oldhosts $hostmask #putcmdlog "no nick found for $usr ($found)" } } } { variable logaddremove if {$logaddremove=="1"} {putlog "$usr has inactive temp $hostmask [duration [expr [clock sec]-$lastseen]] ($thost)"} setuser $usr xtra $thost lappend oldhosts $hostmask } } } } } } } proc cybex:join {nick uhost hand chan} { if {[set auth [getchanlogin $nick $chan]] == "0" || $auth == ""} { putcmdlog "WHO $nick n%hnua // join $hand $chan ([getchanlogin $nick $chan])" ##### puthelp "WHO $nick n%hnua" } { #set uhost [getchanhost $nick $chan]; set hand * if {$hand=="*" && [set hand [finduser *!$uhost]]=="*"} { putlog "cybex:checkusr n:$nick uh:$uhost h:$hand auth:$auth" cybex:checkusr $nick $uhost $hand $auth } { #putcmdlog "!not! cybex:checkusr $nick $uhost $hand $auth" } } } proc cybex:raw354 {from key text} { set list [split $text] set ident [lindex $list 1] if {[validchan $ident]} { #putlog "ident $ident is a valid chan: $text" return 0 } set host [lindex $list 2] set nick [lindex $list 3] set auth [lindex $list 4] if [info exi ::ModeD::joinlist] { if {[set num [lsearch -exact $::ModeD::joinlist $nick]]!=-1} { putcmdlog "\002join354\002 $nick!$ident@$host ($auth)" if {[info command spamscan:join]!=""} { spamscan:join $nick $ident@$host [nick2hand $nick] $::ModeD::channel } set ::ModeD::joinlist [lreplace $::ModeD::joinlist $num $num] if {$::username=="b0rkBerlin"} { if {[info command getchanlogin]=="getchanlogin"} { putmsg #cybex.test "\002join354\002 $nick!$ident@$host A:$auth \[[getchanlogin $nick]\]" } { putmsg #cybex.test "\002join354\002 $nick!$ident@$host A:$auth" } } } } if {$auth!="0"} { set ::CyQauths($nick) $auth set ::CyQauths($nick:lastused) [clock sec] #putcmdlog "get raw n:$nick id:$ident host:$host auth:$auth from $text" cybex:checkusr $nick $ident@$host [finduser *!$ident@$host] $auth } { if [info exist ::CyQauths($nick)] {unset ::CyQauths($nick); unset ::CyQauths($nick:lastused)} } return 0 } proc cybex:delay args { variable startup 1 utimer 300 [list unset ::qauthautohost::startup] } proc thommey:refresh_time {{args ""}} { variable blocked variable startup if {[info exists startup] && $startup==1} {putcmdlog "delayed join exist, wait ..."; return 0} if {[info exists blocked] && $blocked==1} {putcmdlog "blocked exists, there must be a problem in the script"; return 0} set blocked 1 thommey:refresh utimer 15 [list unset ::qauthautohost::blocked] } proc thommey:refresh {{chan ""}} { set toask [list] if {$chan == ""} { foreach chn [channels] { foreach nick [chanlist $chn] { set auth 0 if {[set auth [getchanlogin $nick $chn]] == "0" || $auth == "" } { lappend toask $nick } { set uhost [getchanhost $nick $chn]; set hand * if {[set hand [finduser *!$uhost]]=="*"} {cybex:checkusr $nick $uhost $hand $auth} } } } if {[llength $toask]} { set toask [lsort -unique $toask] set toask2 [list] foreach n $toask { lappend toask2 $n if {[string length [join $toask2]] > 400} { puthelp "WHO [join $toask2 ","] n%hnua" set toask2 [list] } } if {[llength $toask2]} { puthelp "WHO [join $toask2 ","] n%hnua" } } } { ##### puthelp "WHO $chan c%hnua" } return 0 } proc text2pattern {text} { return [string map [list \\ \\\\ \[ \\\[ \] \\\]] $text] #return [string map [list \\ \\\\ \[ \\\[ \] \\\] \* \\\* \? \\\?] $text] regsub -all -- {\\} $text {\\\\} text #regsub -all -- {\}} $text {\}} text #regsub -all -- {\{} $text {\{} text regsub -all -- {\]} $text {\]} text regsub -all -- {\[} $text {\[} text return $text } } # Maskhost-Fix # written by thommey # Lets maskhost (used by most scripts to select banmask/usermask) # return *!*@HOST if the thing you set here matches the host # Usable most likely on Quakenet and Undernet # to handle *!*@*.users.network.org masks correctly # Set here now the masks (ex: "*.users.undernet.org"). # One line per mask. It is matched against nick!ident@host. set ::fakehostmasks { *.users.quakenet.org *.users.undernet.org } if {[info commands maskhost_r] != "maskhost_r"} { rename maskhost maskhost_r } proc maskhost {host} { global fakehostmasks foreach fmask [split $fakehostmasks \n] { set fmask [string trim $fmask] if {$fmask == ""} { continue } regsub -all {\\} $fmask {\\\\} fmask regsub -all {\[} $fmask {\\\[} fmask regsub -all {\]} $fmask {\\\]} fmask if {[string match -nocase $fmask $host]} { return *!*@[lindex [split $host @] end] } } if {[string match -nocase *!~* $host]} { return *![string map [list ~ \?] [lindex [split $host !] end]] } return [maskhost_r $host] } putlog "Maskhost-Fix by thommey and C*Bex Qauth-autohost v0.4 loaded" return "load \"[info script]\" ,8,1\nready\nrun" # dirty quick fix #proc getchanlogin nick { # return 0 #}