diff options
| -rw-r--r-- | lib/ASM/Classes.pm | 43 | ||||
| -rw-r--r-- | lib/ASM/Commander.pm | 53 | ||||
| -rw-r--r-- | lib/ASM/DB.pm | 68 | ||||
| -rw-r--r-- | lib/ASM/Event.pm | 44 | ||||
| -rw-r--r-- | lib/ASM/Inspect.pm | 5 | ||||
| -rw-r--r-- | lib/ASM/Log.pm | 5 |
6 files changed, 121 insertions, 97 deletions
diff --git a/lib/ASM/Classes.pm b/lib/ASM/Classes.pm index 44e51b7..8a0b36a 100644 --- a/lib/ASM/Classes.pm +++ b/lib/ASM/Classes.pm @@ -8,6 +8,7 @@ use Regexp::Wildcards; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; my %sf = (); +my $cvt = Regexp::Wildcards->new(type => 'jokers'); sub new { @@ -48,11 +49,12 @@ sub new sub cloning { my ($chk, $id, $event, $chan, $rev) = @_; my $max = int($chk->{content}); + $chan = lc $chan; my @nicks = grep { (defined($::sn{$_}->{host})) && (defined($::sn{$_}->{mship})) && ($::sn{$_}->{host} eq $event->{host}) && - (lc $chan ~~ $::sn{$_}->{mship}) + ($chan ~~ $::sn{$_}->{mship}) } keys %::sn; if ($#nicks >= $max) { return ASM::Util->commaAndify(@nicks); @@ -86,12 +88,13 @@ sub joinmsgquit { my ($chk, $id, $event, $chan, $rev) = @_; my $time = $chk->{content}; + my $nick = lc $event->{nick}; ##STATE $chan = lc $chan; #don't know if this is necessary but I'm trying to track down some mysterious state tracking corruption - return 0 unless defined($::sc{$chan}{users}{lc $event->{nick}}{jointime}); - return 0 unless defined($::sc{$chan}{users}{lc $event->{nick}}{msgtime}); - return 0 if ((time - $::sc{$chan}{users}{lc $event->{nick}}{jointime}) > $time); - return 0 if ((time - $::sc{$chan}{users}{lc $event->{nick}}{msgtime}) > $time); + return 0 unless defined($::sc{$chan}{users}{$nick}{jointime}); + return 0 unless defined($::sc{$chan}{users}{$nick}{msgtime}); + return 0 if ((time - $::sc{$chan}{users}{$nick}{jointime}) > $time); + return 0 if ((time - $::sc{$chan}{users}{$nick}{msgtime}) > $time); return 1; } @@ -187,12 +190,12 @@ sub levenflood sub nickfuzzy { my ($chk, $id, $event, $chan) = @_; - my $nick = $event->{nick}; - $nick = $event->{args}->[0] if ($event->{type} eq 'nick'); + my $nick = lc $event->{nick}; + $nick = lc $event->{args}->[0] if ($event->{type} eq 'nick'); my ($fuzzy, $match) = split(/:/, $chk->{content}); my @nicks = split(/,/, $match); foreach my $item (@nicks) { - if (distance(lc $nick, lc $item) <= $fuzzy) { + if (distance($nick, lc $item) <= $fuzzy) { return 1; } } @@ -231,8 +234,7 @@ sub dnsbl sub floodqueue2 { my ($chk, $id, $event, $chan, $rev) = @_; my @cut = split(/:/, $chk->{content}); - - my $cvt = Regexp::Wildcards->new(type => 'jokers'); + my $nick = lc $event->{nick}; my $hit = 0; foreach my $mask ( keys %{$::sc{lc $chan}{quiets}}) { if ($mask !~ /^\$/) { @@ -241,10 +243,10 @@ sub floodqueue2 { if (lc $event->{from} =~ lc $regex) { $hit = 1; } - } elsif ( (defined($::sn{lc $event->{nick}}{account})) && ($mask =~ /^\$a:(.*)/)) { - my @div = split(/\$/, $mask); + } elsif ( (defined($::sn{$nick}{account})) && ($mask =~ /^\$a:(.*)/)) { + my @div = split(/\$/, $1); my $regex = $cvt->convert($div[0]); - if (lc ($::sn{lc $event->{nick}}{account}) =~ lc $regex) { + if (lc ($::sn{$nick}{account}) =~ lc $regex) { $hit = 1; } } @@ -275,9 +277,10 @@ sub cyclebotnet { my ($chk, $id, $event, $chan, $rev) = @_; my ($cycletime, $queueamt, $queuetime) = split(/:/, $chk->{content}); + my $nick = lc $event->{nick}; $chan = lc $chan; #don't know if this is necessary but I'm trying to track down some mysterious state tracking corruption - return 0 unless defined($::sc{$chan}{users}{lc $event->{nick}}{jointime}); - return 0 if ((time - $::sc{$chan}{users}{lc $event->{nick}}{jointime}) > int($cycletime)); + return 0 unless defined($::sc{$chan}{users}{$nick}{jointime}); + return 0 if ((time - $::sc{$chan}{users}{$nick}{jointime}) > int($cycletime)); return 1 if ( flood_add( $chan, $id, "cycle", int($queuetime)) == int($queueamt) ); return 0; } @@ -321,6 +324,7 @@ sub process_cf sub splitflood { my ($chk, $id, $event, $chan) = @_; my $text; + my $nick = lc $event->{nick}; my @cut = split(/:/, $chk->{content}); $cf{$id}{timeout}=int($cut[1]); if ($event->{type} =~ /^(public|notice|part|caction)$/) { @@ -330,8 +334,8 @@ sub splitflood { # a bit ugly but this should avoid false positives on foolish humans # give them the benefit of the doubt if they talked before ... but not too recently # if we didn't see them join, assume they did talk at some point - my $msgtime = $::sc{$chan}{users}{lc $event->{nick}}{msgtime} // 0; - $msgtime ||= 1 if !$::sc{$chan}{users}{lc $event->{nick}}{jointime}; + my $msgtime = $::sc{$chan}{users}{$nick}{msgtime} // 0; + $msgtime ||= 1 if !$::sc{$chan}{users}{$nick}{jointime}; return if $text =~ /^[^\w\s]+\w+\s*$/ && $msgtime && ($msgtime + $cf{$id}{timeout}) < time; # return unless length($text) >= 10; if (defined($bs{$id}{$text}) && (time <= $bs{$id}{$text} + 600)) { @@ -463,8 +467,9 @@ sub gecos { sub nuhg { my ( $chk, $id, $event, $chan) = @_; - return 0 unless defined($::sn{lc $event->{nick}}->{gecos}); - my $match = $event->{from} . '!' . $::sn{lc $event->{nick}}->{gecos}; + my $nick = lc $event->{nick}; + return 0 unless defined($::sn{$nick}->{gecos}); + my $match = $event->{from} . '!' . $::sn{$nick}->{gecos}; return 1 if ($match =~ /$chk->{content}/); return 0; } diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm index b64103a..0813dff 100644 --- a/lib/ASM/Commander.pm +++ b/lib/ASM/Commander.pm @@ -450,13 +450,15 @@ sub cmd_investigate { return; } my $person = $::sn{$nick}; + my $user = lc $person->{user}; + my $gecos = lc $person->{gecos}; my $dbh = $::db->{DBH}; my $mnicks = $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE nick like " . $dbh->quote($nick) . ';'); - my $musers = (lc $person->{user} ~~ $::mysql->{ignoredidents}) ? "didn't check" : $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE user like " . $dbh->quote($person->{user}) . ';'); + my $musers = ($user ~~ $::mysql->{ignoredidents}) ? "didn't check" : $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE user like " . $dbh->quote($person->{user}) . ';'); my $mhosts = $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE host like " . $dbh->quote($person->{host}) . ';'); my $maccts = $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE account like " . $dbh->quote($person->{account}) . ';'); - my $mgecos = (lc $person->{gecos} ~~ $::mysql->{ignoredgecos}) ? "didn't check" : $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE gecos like " . $dbh->quote($person->{gecos}) . ';'); + my $mgecos = ($gecos ~~ $::mysql->{ignoredgecos}) ? "didn't check" : $dbh->do("SELECT * from $::db->{ACTIONTABLE} WHERE gecos like " . $dbh->quote($person->{gecos}) . ';'); my $ip = ASM::Util->getNickIP($nick); my $matchedip = 0; @@ -474,9 +476,9 @@ sub cmd_investigate { $conn->privmsg($event->replyto, "I found $mnicks matches by nick ($nick), $musers by user ($person->{user}), $mhosts by hostname ($person->{host}), " . "$maccts by NickServ account ($person->{account}), $mgecos by gecos field ($person->{gecos}), and $matchedip by real IP ($dq). " . ASM::Shortener->shorturl('https://antispammeta.net/cgi-bin/secret/investigate.pl?nick=' . uri_escape($nick) . - ((lc $person->{user} ~~ $::mysql->{ignoredidents}) ? '' : '&user=' . uri_escape($person->{user})) . + (($user ~~ $::mysql->{ignoredidents}) ? '' : '&user=' . uri_escape($person->{user})) . '&host=' . uri_escape($person->{host}) . '&account=' . uri_escape($person->{account}) . - ((lc $person->{gecos} ~~ $::mysql->{ignoredgecos}) ? '' : '&gecos=' . uri_escape($person->{gecos})) . '&realip=' . $dq)); + (($gecos ~~ $::mysql->{ignoredgecos}) ? '' : '&gecos=' . uri_escape($person->{gecos})) . '&realip=' . $dq)); } sub cmd_investigate2 { @@ -532,6 +534,7 @@ sub cmd_user_add { my ($conn, $event) = @_; my $nick = lc $+{account}; + my $account; my $flags = $+{flags}; my %hasflagshash = (); foreach my $item (split(//, $::users->{person}->{lc $::sn{lc $event->{nick}}->{account}}->{flags})) { @@ -547,9 +550,9 @@ sub cmd_user_add { $conn->privmsg($event->replyto, "The d flag may not be assigned over IRC. Edit the configuration manually."); return; } - if ( (defined($::sn{$nick}->{account})) && ( lc $::sn{$nick}->{account} ne $nick ) ) { - $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . lc $::sn{$nick}->{account} . '.'); - $nick = lc $::sn{$nick}->{account}; + if ( (defined($::sn{$nick}->{account})) && ( ($account = lc $::sn{$nick}->{account}) ne $nick ) ) { + $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . $account . '.'); + $nick = $account; } if (defined($::users->{person}->{$nick})) { $conn->privmsg($event->replyto, "The user $nick already exists. Use ;user flags $nick $flags to set their flags"); @@ -564,9 +567,10 @@ sub cmd_user_flags { my ($conn, $event) = @_; my $nick = lc $+{account}; - if ( defined($::sn{$nick}) && (defined($::sn{$nick}->{account})) && ( lc $::sn{$nick}->{account} ne $nick ) ) { - $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . lc $::sn{$nick}->{account} . '.'); - $nick = lc $::sn{$nick}->{account}; + my $account; + if ( defined($::sn{$nick}) && (defined($::sn{$nick}->{account})) && ( ($account = lc $::sn{$nick}->{account}) ne $nick ) ) { + $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . $account . '.'); + $nick = $account; } my $sayNick = substr($nick, 0, 1) . "\x02\x02" . substr($nick, 1); if (defined($::users->{person}->{$nick}->{flags})) { @@ -581,6 +585,7 @@ sub cmd_user_flags2 { my $nick = lc $+{account}; my $flags = $+{flags}; + my $account; my %hasflagshash = (); foreach my $item (split(//, $::users->{person}->{lc $::sn{lc $event->{nick}}->{account}}->{flags})) { $hasflagshash{$item} = 1; @@ -595,9 +600,9 @@ sub cmd_user_flags2 { $conn->privmsg($event->replyto, "The d flag may not be assigned over IRC. Edit the configuration manually."); return; } - if ( (defined($::sn{$nick}->{account})) && ( lc $::sn{$nick}->{account} ne $nick ) ) { - $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . lc $::sn{$nick}->{account} . '.'); - $nick = lc $::sn{$nick}->{account}; + if ( (defined($::sn{$nick}->{account})) && ( ($account = lc $::sn{$nick}->{account}) ne $nick ) ) { + $conn->privmsg($event->replyto, "I'm assuming you mean " . $nick . "'s nickserv account, " . $account . '.'); + $nick = $account; } if (defined($::users->{person}->{$nick}) && defined($::users->{person}->{$nick}->{flags}) && @@ -839,20 +844,22 @@ sub cmd_ops { my ($conn, $event) = @_; my $tgt = lc $event->{to}->[0]; + my $msgtgt = $tgt; + my $nick = lc $event->{nick}; $tgt = lc $+{chan} if defined($+{chan}); my $msg = $+{reason}; if ( $tgt =~ /^#/ && ((($::channels->{channel}->{$tgt}->{monitor} // "yes") eq "no") || #we're not monitoring this channel - !($tgt ~~ $::sn{lc $event->{nick}}->{mship})) ) { #they're not on the channel they're calling !ops for + !($tgt ~~ $::sn{$nick}->{mship})) ) { #they're not on the channel they're calling !ops for return; } if (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) { - if (ASM::Util->notRestricted(lc $event->{nick}, "noops")) { - if (lc $event->{to}->[0] eq '##linux') { + if (ASM::Util->notRestricted($nick, "noops")) { + if ($msgtgt eq '##linux') { $conn->privmsg($event->{nick}, "I've already been recently asked to summon op attention. " . "In the future, please use /msg $conn->{_nick} !ops $event->{to}->[0] reasonGoesHere" . " - this allows ops to be notified while minimizing channel hostility."); - } elsif (lc $event->{to}->[0] eq lc $conn->{_nick}) { - if (lc $tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target + } elsif ($msgtgt eq lc $conn->{_nick}) { + if ($tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target $conn->privmsg($event->{nick}, "Sorry, it looks like you've tried to use the !ops command " . "via PM but haven't specified a target. Try again with /msg $conn->{_nick} " . "!ops #channelGoesHere ReasonGoesHere"); @@ -863,16 +870,16 @@ sub cmd_ops { } return; } - if (ASM::Util->notRestricted(lc $event->{nick}, "noops")) { - if (lc $event->{to}->[0] eq '##linux') { + if (ASM::Util->notRestricted($nick, "noops")) { + if ($msgtgt eq '##linux') { $conn->privmsg($event->{nick}, "I've summoned op attention. In the future, please use /msg " . "$conn->{_nick} !ops $event->{to}->[0] reasonGoesHere - this allows ops to " . "be notified while minimizing channel hostility."); } elsif (($tgt eq '#wikipedia-en-help') && (!defined($msg))) { $conn->privmsg($event->{nick}, "I've summoned op attention, but in the future, please specify " . "a reason, e.g. !ops reasongoeshere - so ops know what is going on. Thanks! :)"); - } elsif (lc $event->{to}->[0] eq lc $conn->{_nick}) { - if (lc $tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target + } elsif ($msgtgt eq lc $conn->{_nick}) { + if ($tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target $conn->privmsg($event->{nick}, "Sorry, it looks like you've tried to use the !ops command " . "via PM but haven't specified a target. Try again with /msg $conn->{_nick} " . "!ops #channelGoesHere ReasonGoesHere"); @@ -883,7 +890,7 @@ sub cmd_ops { } my $hilite=ASM::Util->commaAndify(ASM::Util->getAlert($tgt, 'opalert', 'hilights')); my $txtz = "[\x02$tgt\x02] - $event->{nick} wants op attention"; - if ((time-$::sc{$tgt}{users}{lc $event->{nick}}{jointime}) > 90) { + if ((time-$::sc{$tgt}{users}{$nick}{jointime}) > 90) { $txtz .= " ($msg) $hilite !att-$tgt-opalert"; } my $uuid = $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n"); diff --git a/lib/ASM/DB.pm b/lib/ASM/DB.pm index 762d40a..bf56a8a 100644 --- a/lib/ASM/DB.pm +++ b/lib/ASM/DB.pm @@ -63,6 +63,7 @@ sub actionlog my ($action, $reason, $channel, $nick, $user, $host, $gecos, $account, $ip, $bynick, $byuser, $byhost, $bygecos, $byaccount); + my ($lcnick, $lcbynick); if ($event->{type} eq 'mode') { $action = $modedata1; @@ -104,26 +105,26 @@ sub actionlog $channel = $event->{args}->[0]; } return unless defined($action); -# $bynick = lc $bynick if defined $bynick; #we will lowercase the NUHGA info later. - if ( (defined($bynick)) && (defined($::sn{lc $bynick})) ) { #we have the nick taking the action available, fill in missing NUHGA info - $byuser //= $::sn{lc $bynick}{user}; - $byhost //= $::sn{lc $bynick}{host}; - $bygecos //= $::sn{lc $bynick}{gecos}; - $byaccount //= $::sn{lc $bynick}{account}; + $lcbynick = lc $bynick if defined $bynick; #we will lowercase the NUHGA info later. + if ( (defined($bynick)) && (defined($::sn{$lcbynick})) ) { #we have the nick taking the action available, fill in missing NUHGA info + $byuser //= $::sn{$lcbynick}{user}; + $byhost //= $::sn{$lcbynick}{host}; + $bygecos //= $::sn{$lcbynick}{gecos}; + $byaccount //= $::sn{$lcbynick}{account}; if (($byaccount eq '0') or ($byaccount eq '*')) { $byaccount = undef; } } -# $nick = lc $nick if defined $nick; - if ( (defined($nick)) && (defined($::sn{lc $nick})) ) { #this should always be true, else something has gone FUBAR - $user //= $::sn{lc $nick}{user}; - $host //= $::sn{lc $nick}{host}; - $gecos //= $::sn{lc $nick}{gecos}; - $account //= $::sn{lc $nick}{account}; + $lcnick = lc $nick if defined $nick; + if ( (defined($nick)) && (defined($::sn{$lcnick})) ) { #this should always be true, else something has gone FUBAR + $user //= $::sn{$lcnick}{user}; + $host //= $::sn{$lcnick}{host}; + $gecos //= $::sn{$lcnick}{gecos}; + $account //= $::sn{$lcnick}{account}; if (($account eq '0') or ($account eq '*')) { $account = undef; } - $ip = ASM::Util->getNickIP(lc $nick); + $ip = ASM::Util->getNickIP($lcnick); } # my ($action, $reason, $channel, # $nick, $user, $host, $gecos, $account, $ip @@ -179,6 +180,8 @@ sub logg my ($event) = @_; my $dbh = $self->{DBH_LOG}; my $table = $event->{type}; + my $nick = lc $event->{nick}; + my $victim; $table = 'action' if ($table eq 'caction'); $table = 'privmsg' if ($table eq 'public'); return if (($table eq 'action') or ($table eq 'privmsg')); #Disabling logging of privmsg stuffs to mysql. no point. @@ -189,10 +192,10 @@ sub logg if ($table eq 'quit') { $string = 'INSERT INTO `quit` (nick, user, host, geco, ip, account, content1) VALUES (' . $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' . - $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{lc $event->{nick}}->{gecos}) . ','; - my $ip = ASM::Util->getNickIP(lc $event->{nick}, $event->{host}); + $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ','; + my $ip = ASM::Util->getNickIP($nick, $event->{host}); if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; } - my $account = $::sn{lc $event->{nick}}->{account}; + my $account = $::sn{$nick}->{account}; if (!defined($account) or ($account eq '0') or ($account eq '*')) { $account = 'NULL'; } else { @@ -206,10 +209,10 @@ sub logg $string = 'INSERT INTO `part` (channel, nick, user, host, geco, ip, account, content1) VALUES (' . $dbh->quote($event->{to}->[0]) . ',' . $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' . - $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{lc $event->{nick}}->{gecos}) . ','; - my $ip = ASM::Util->getNickIP(lc $event->{nick}, $event->{host}); + $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ','; + my $ip = ASM::Util->getNickIP($nick, $event->{host}); if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; } - my $account = $::sn{lc $event->{nick}}->{account}; + my $account = $::sn{$nick}->{account}; if (!defined($account) or ($account eq '0') or ($account eq '*')) { $account = 'NULL'; } else { @@ -220,23 +223,24 @@ sub logg ASM::Util->dprint($string, 'mysql'); return; } elsif ($table eq 'kick') { + $victim = lc $event->{to}->[0]; $string = 'INSERT INTO `kick` (channel, nick, user, host, geco, ip, account, ' . 'victim_nick, victim_user, victim_host, victim_geco, victim_ip, victim_account, content1) VALUES (' . $dbh->quote($event->{args}->[0]) . ',' . $dbh->quote($event->{nick}) . ',' . $dbh->quote($event->{user}) . ',' . - $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{lc $event->{nick}}->{gecos}) . ','; - my $ip = ASM::Util->getNickIP(lc $event->{nick}); + $dbh->quote($event->{host}) . ',' . $dbh->quote($::sn{$nick}->{gecos}) . ','; + my $ip = ASM::Util->getNickIP($nick); if (defined($ip)) { $ip = $dbh->quote($ip); } else { $ip = 'NULL'; } - my $account = $::sn{lc $event->{nick}}->{account}; + my $account = $::sn{$nick}->{account}; if (($account eq '0') or ($account eq '*')) { $account = 'NULL'; } else { $account = $dbh->quote($account); } $string = $string . $ip . ',' . $account; $string = $string . ', ' . $dbh->quote($event->{to}->[0]); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{user}); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{host}); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{gecos}); - my $vic_ip = ASM::Util->getNickIP(lc $event->{to}->[0]); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{user}); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{host}); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{gecos}); + my $vic_ip = ASM::Util->getNickIP($victim); if (defined($vic_ip)) { $vic_ip = $dbh->quote($vic_ip); } else { $vic_ip = 'NULL'; } - my $vic_account = $::sn{lc $event->{to}->[0]}->{account}; + my $vic_account = $::sn{$victim}->{account}; if (($vic_account eq '0') or ($vic_account eq '*')) { $vic_account = 'NULL'; } else { $vic_account = $dbh->quote($vic_account); } $string = $string . ', ' . $vic_ip . ',' . $vic_account . ',' . $dbh->quote($event->{args}->[1]) . ');'; $dbh->do($string); @@ -267,7 +271,7 @@ sub logg if ($table eq 'kick') { $string = $string . $dbh->quote($event->{args}->[0]) . ", "; } - my $geco = $::sn{lc $event->{nick}}->{gecos}; + my $geco = $::sn{$nick}->{gecos}; $string = $string . $dbh->quote($event->{nick}) . ", " . $dbh->quote($event->{user}) . ", " . $dbh->quote($event->{host}) . ", " . $dbh->quote($geco); if (($table ne 'join') && ($table ne 'kick')) { @@ -275,16 +279,16 @@ sub logg } if ($table eq 'kick') { $string = $string . ', ' . $dbh->quote($event->{to}->[0]); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{user}); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{host}); - $string = $string . ', ' . $dbh->quote($::sn{lc $event->{to}->[0]}->{gecos}); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{user}); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{host}); + $string = $string . ', ' . $dbh->quote($::sn{$victim}->{gecos}); $string = $string . ', ' . $dbh->quote($event->{args}->[1]); } if ($table eq 'mode') { $string = $string . ', ' . $dbh->quote($event->{args}->[1]); } if ($table eq 'join') { - my $account = $::sn{lc $event->{nick}}->{account}; + my $account = $::sn{$nick}->{account}; if (!defined($account) or ($account eq '0') or ($account eq '*')) { $account = 'NULL'; } else { diff --git a/lib/ASM/Event.pm b/lib/ASM/Event.pm index fe9db78..4080c78 100644 --- a/lib/ASM/Event.pm +++ b/lib/ASM/Event.pm @@ -11,6 +11,8 @@ use Array::Utils qw(:all); use Net::DNS::Async; no if $] >= 5.017011, warnings => 'experimental::smartmatch'; +my $cvt = Regexp::Wildcards->new(type => 'jokers'); + sub new { my $module = shift; @@ -152,10 +154,11 @@ sub on_ping sub on_account { my ($conn, $event) = @_; - @{$::sa{$::sn{lc $event->{nick}}{account}}} = grep { $_ ne lc $event->{nick} } @{$::sa{$::sn{lc $event->{nick}}{account}}}; - delete $::sa{$::sn{lc $event->{nick}}{account}} unless scalar @{$::sa{$::sn{lc $event->{nick}}{account}}}; - $::sn{lc $event->{nick}}{account} = lc $event->{args}->[0]; - push @{$::sa{$::sn{lc $event->{nick}}{account}}}, lc $event->{nick}; + my $nick = lc $event->{nick}; + @{$::sa{$::sn{$nick}{account}}} = grep { $_ ne $nick } @{$::sa{$::sn{$nick}{account}}}; + delete $::sa{$::sn{$nick}{account}} unless scalar @{$::sa{$::sn{$nick}{account}}}; + $::sn{$nick}{account} = lc $event->{args}->[0]; + push @{$::sa{$::sn{$nick}{account}}}, $nick; } sub on_connect { @@ -175,7 +178,7 @@ sub on_join { my $nick = lc $event->{nick}; my $chan = lc $event->{to}->[0]; my $rate; - if ( lc $conn->{_nick} eq lc $nick) { + if ( lc $conn->{_nick} eq $nick) { $::sc{$chan} = {}; mkdir($::settings->{log}->{dir} . $chan); $::synced{$chan} = 0; @@ -295,7 +298,8 @@ sub on_quit my @channels=(); my $nick = lc $event->{nick}; for ( keys %::sc ) { - push ( @channels, lc $_ ) if delete $::sc{lc $_}{users}{$nick}; + my $chan = lc $_; + push ( @channels, $chan ) if delete $::sc{$chan}{users}{$nick}; } $event->{to} = \@channels; if (defined $::db) { @@ -336,16 +340,18 @@ sub blah sub irc_users { my ( $channel, @users ) = @_; + $channel = lc $channel; for (@users) { + my $nick = lc $_; my ( $op, $voice ); $op = 0; $voice = 0; $op = 1 if s/^\@//; $voice = 1 if s/^\+//; - $::sc{lc $channel}{users}{lc $_} = {}; - $::sc{lc $channel}{users}{lc $_}{op} = $op; - $::sc{lc $channel}{users}{lc $_}{voice} = $voice; - $::sc{lc $channel}{users}{lc $_}{jointime} = 0; + $::sc{$channel}{users}{$nick} = {}; + $::sc{$channel}{users}{$nick}{op} = $op; + $::sc{$channel}{users}{$nick}{voice} = $voice; + $::sc{$channel}{users}{$nick}{jointime} = 0; } } @@ -417,11 +423,11 @@ sub on_nick { sub on_kick { my ($conn, $event) = @_; - if (lc $event->{to}->[0] eq lc $conn->{_nick}) { + my $nick = lc $event->{to}->[0]; + if ($nick eq lc $conn->{_nick}) { $conn->privmsg($::settings->{masterchan}, "I've been kicked from " . $event->{args}->[0] . ": " . $event->{args}->[1]); # $conn->join($event->{args}->[0]); } - my $nick = lc $event->{to}->[0]; my $chan = lc $event->{args}->[0]; if (defined $::db) { $::db->logg( $event ); @@ -444,12 +450,12 @@ sub on_kick { } if ( lc $conn->{_nick} eq $nick ) { - delete( $::sc{lc $event->{args}->[0]} ); - on_byechan(lc $event->{to}->[0]); + delete( $::sc{$chan} ); + on_byechan($chan); } else { - delete( $::sc{lc $event->{args}->[0]}{users}{$nick} ); + delete( $::sc{$chan}{users}{$nick} ); } } @@ -517,7 +523,6 @@ sub on_channelmodeis sub whoGotHit { my ($chan, $mask) = @_; - my $cvt = Regexp::Wildcards->new(type => 'jokers'); my @affected = (); if ($mask !~ /^\$/) { my @div = split(/\$/, $mask); @@ -732,7 +737,8 @@ sub on_channelurlis sub on_ctcp_dcc { my ($conn, $event) = @_; - my $acct = lc $::sn{lc $event->{nick}}->{account}; + my $nick = lc $event->{nick}; + my $acct = lc $::sn{$nick}->{account}; ASM::Util->dprint(Dumper($event), 'ctcp'); if (($event->{type} eq 'cdcc') && (defined($::users->{person}->{$acct})) && @@ -741,7 +747,7 @@ sub on_ctcp_dcc ASM::Util->dprint(Dumper($event), 'dcc'); my @spit = split(/ /, $event->{args}->[0]); if (($spit[0] eq 'CHAT') && ($spit[1] eq 'CHAT')) { - $::chat = Net::IRC::DCC::CHAT->new($conn, 0, lc $event->{nick}, $spit[2], $spit[3]); + $::chat = Net::IRC::DCC::CHAT->new($conn, 0, $nick, $spit[2], $spit[3]); } } } @@ -764,7 +770,7 @@ sub on_whoxreply my ($tgt, $magic, $chan, $user, $realip, $host, $nick, $account, $gecos) = @{$event->{args}}; return unless $magic eq '314'; $nick = lc $nick; $chan = lc $chan; - if (!defined $::sn{lc $nick}) { + if (!defined $::sn{$nick}) { $::sn{$nick} = {}; $::sn{$nick}->{mship} = [$chan]; } else { diff --git a/lib/ASM/Inspect.pm b/lib/ASM/Inspect.pm index e18572d..b4b0fbc 100644 --- a/lib/ASM/Inspect.pm +++ b/lib/ASM/Inspect.pm @@ -78,7 +78,7 @@ sub inspect { my (@dnsbl, @uniq); my ($match, $txtz, $iaddr); my @override = []; - my $nick = ($event->{type} eq 'nick') ? $event->{args}->[0] : lc $event->{nick}; + my $nick = ($event->{type} eq 'nick') ? lc $event->{args}->[0] : lc $event->{nick}; my $xresult; return if (index($nick, ".") != -1); if ( $event->{type} eq 'join' ) { @@ -119,6 +119,7 @@ sub inspect { my $evcontent = $event->{args}->[0]; my $evhost = $event->{host}; foreach $chan (@{$event->{to}}) { + $chan = lc $chan; foreach $id ( keys %dct ) { return unless (ASM::Util->notRestricted($nick, "notrigger") && ASM::Util->notRestricted($nick, "no$id")); $xresult = $dct{$id}{xresult}; @@ -128,7 +129,7 @@ sub inspect { } $txtz = "\x03" . $::RCOLOR{$::RISKS{$dct{$id}{risk}}} . "\u$dct{$id}{risk}\x03 risk threat [\x02$chan\x02] - ". "\x02$event->{nick}\x02 - ${nicereason}; ping "; - $txtz = $txtz . ASM::Util->commaAndify(ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights')) if (ASM::Util->getAlert(lc $chan, $dct{$id}{risk}, 'hilights')); + $txtz = $txtz . ASM::Util->commaAndify(ASM::Util->getAlert($chan, $dct{$id}{risk}, 'hilights')) if (ASM::Util->getAlert($chan, $dct{$id}{risk}, 'hilights')); $txtz = $txtz . ' !att-' . $chan . '-' . $dct{$id}{risk}; my $uuid = $::log->incident($chan, "$chan: $dct{$id}{risk} risk: $event->{nick} - $nicereason\n"); $txtz = $txtz . ' ' . ASM::Shortener->shorturl($::settings->{web}->{detectdir} . $uuid . '.txt'); diff --git a/lib/ASM/Log.pm b/lib/ASM/Log.pm index ef204f0..adeb4f2 100644 --- a/lib/ASM/Log.pm +++ b/lib/ASM/Log.pm @@ -116,10 +116,11 @@ sub logg print "COULDN'T PRINT TO $path - $line"; } my $spy; + my $nick = lc $event->{nick}; if (defined($::spy{$chan})) { $spy = $::spy{$chan}; - } elsif (defined($::spy{lc $event->{nick}})) { - $spy = $::spy{lc $event->{nick}}; + } elsif (defined($::spy{$nick})) { + $spy = $::spy{$nick}; } if (defined($spy)) { say $spy "$chan: $nostamp"; |
