if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; }; # Copyright (c) 2004 BlackJac@EFNet # # Version: 1.0.2004.05.26.2 # # This script will perform an ETRACE and filter the results based on # your requested filter type and pattern. # # Usage: /tfind - [-log] # # Available switches: # all users with nick!user@host#gecos matching # class users in class matching # gecos users with gecos matching # ip users with ip address matching # nick users with nick matching # rall users with nick!user@host#gecos matching regex # rgecos users with gecos matching regex # rnick users with nick matching regex # ruh users with userhost matching regex # uh users with userhost matching package tfind; # Set this to the directory where tfind should store its log files: assign TFIND_LOGDIR ~/logs; alias tfind (choice, pattern, log, void) { if (choice && @pattern) { @ tfind.regexp = choice =~ [-r%] ? regcomp($pattern) : []; @ tfind.pattern = pattern; @ tfind.log = log; switch ($choice) { (-all) { ^on ^709 "% % % % % % % *" { if (match($tfind.pattern "$3!$4@$5#$7-")) { tfind.parse $2-; }; }; tfind.init clients; }; (-class) { ^on ^709 "% % % % % % % *" { if ([$2] =~ tfind.pattern) { tfind.parse $2-; }; }; tfind.init clients in class; }; (-gecos) { ^on ^709 "% % % % % % % *" { if (match($tfind.pattern "$7-")) { tfind.parse $2-; }; }; tfind.init gecos; }; (-ip) { ^on ^709 "% % % % % % % *" { if ([$6] =~ tfind.pattern) { tfind.parse $2-; }; }; tfind.init IP addresses; }; (-nick) { ^on ^709 "% % % % % % % *" { if ([$3] =~ tfind.pattern) { tfind.parse $2-; }; }; tfind.init nicknames; }; (-rall) { if (!regerror($tfind.regexp)) { ^on ^709 "% % % % % % % *" { if (!regexec($tfind.regexp $3!$4@$5#$7-)) { tfind.parse $2-; }; }; }; tfind.init clients; }; (-rgecos) { if (!regerror($tfind.regexp)) { ^on ^709 "% % % % % % % *" { if (!regexec($tfind.regexp $7-)) { tfind.parse $2-; }; }; }; tfind.init gecos; }; (-rnick) { if (!regerror($tfind.regexp)) { ^on ^709 "% % % % % % % *" { if (!regexec($tfind.regexp $3)) { tfind.parse $2-; }; }; }; tfind.init nicknames; }; (-ruh) { if (!regerror($tfind.regexp)) { ^on ^709 "% % % % % % % *" { if (!regexec($tfind.regexp $4@$5)) { tfind.parse $2-; }; }; }; tfind.init userhosts; }; (-uh) { ^on ^709 "% % % % % % % *" { if ([$4@$5] =~ tfind.pattern) { tfind.parse $2-; }; }; tfind.init userhosts; }; (*) { xecho -b -c /tfind [-all|-class|-gecos|-ip|-nick|-rall|-rgecos|-rnick|-ruh|-uh] [-log]; @ tfind.log = tfind.pattern = []; if (tfind.regexp) { @ regfree($tfind.regexp); }; }; }; } else { xecho -b -c /tfind [-all|-class|-gecos|-ip|-nick|-rall|-rgecos|-rnick|-ruh|-uh] [-log]; }; }; alias tfind.init (type) { @ tfind.counter = 0; ^on ^262 "% % End of TRACE" { if (tfind.log) { @ write($tfind.logopen); @ close($tfind.logopen); @ tfind.log = tfind.logopen = tfind.strftime = []; }; xecho -b -c Total matching clients: $tfind.counter; @ tfind.counter = tfind.pattern = []; if (tfind.regexp) { @ regfree($tfind.regexp); }; ^on 262 -"% % End of TRACE"; ^on 709 -"% % % % % % % *"; }; xecho -b -c Searching for $type matching $tfind.pattern ...; quote etrace; }; alias tfind.parse (class, nick, username, hostname, ip, gecos) { xecho -b -c Trace [$class]: $nick \($username@$hostname/$ip\) - $gecos; if (tfind.log) { if (!tfind.strftime) { if (fexist($TFIND_LOGDIR) != 1) { @ mkdir($TFIND_LOGDIR); }; @ tfind.strftime = strftime(%Y-%m-%d_%I-%M-%S); if (tfind.logopen = open($TFIND_LOGDIR/tfind.$tfind.strftime W)) { @ write($tfind.logopen ## TRACE LOG \($strftime(%c %Z)\)); @ write($tfind.logopen); }; }; @ write($tfind.logopen $[10]tolower($class) $[9]nick \($username@$hostname/$ip\) - $gecos); }; @ tfind.counter++; }