3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

Improve check for ban-evasion when nick-change is detected

This commit is contained in:
Pragmatic Software 2014-08-12 05:51:21 +00:00
parent 068c6a0559
commit 654cce66a5
4 changed files with 18 additions and 8 deletions

View File

@ -190,6 +190,10 @@ sub check_flood {
if($newnick =~ m/^Guest\d+$/) {
# Don't enforce for services-mandated change to guest account
} else {
$mask = "$newnick!$user\@$host";
$account = $self->{pbot}->{messagehistory}->get_message_account($newnick, $user, $host);
$nick = $newnick;
$self->{nickflood}->{$account}->{changes}++;
}
} else {
@ -252,7 +256,9 @@ sub check_flood {
# check for ban evasion if channel begins with # (not private message) and hasn't yet been validated against ban evasion
if($channel =~ m/^#/ and not $self->{pbot}->{messagehistory}->{database}->get_channel_data($account, $channel, 'validated')->{'validated'} & $self->{NICKSERV_VALIDATED}) {
if($mode == $self->{pbot}->{messagehistory}->{MSG_DEPARTURE}) {
# don't check for evasion on PART/KICK
# don't check for evasion on PART/KICK
} elsif ($mode == $self->{pbot}->{messagehistory}->{MSG_NICKCHANGE}) {
$self->{pbot}->{conn}->whois($nick);
} else {
$self->{pbot}->{conn}->whois($nick);
$self->check_bans($account, $mask, $channel);
@ -703,6 +709,7 @@ sub check_nickserv_accounts {
$hostmask = $self->{pbot}->{messagehistory}->{database}->find_most_recent_hostmask($message_account);
my @channels = $self->{pbot}->{messagehistory}->{database}->get_channels($message_account);
foreach my $channel (@channels) {
next unless $channel =~ /^#/;
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
if($force_validation or $channel_data->{validated} & $self->{NEEDS_CHECKBAN}) {
$self->{pbot}->{logger}->log("anti-flood: [check-account] $nick [nickserv: $account] needs check-ban validation for $hostmask in $channel.\n");
@ -751,7 +758,7 @@ sub adjust_offenses {
}
foreach my $account (keys %{ $self->{nickflood} }) {
if($self->{nickflood}->{$account}->{offenses} and gettimeofday - $self->{nickflood}->{$account}->{timestamp} >= 60 * 60 * 24) {
if($self->{nickflood}->{$account}->{offenses} and gettimeofday - $self->{nickflood}->{$account}->{timestamp} >= 60 * 60 * 48) {
$self->{nickflood}->{$account}->{offenses}--;
if($self->{nickflood}->{$account}->{offenses} == 0) {

View File

@ -291,7 +291,7 @@ sub on_nickchange {
$self->{pbot}->{logger}->log("$nick!$user\@$host changed nick to $newnick\n");
my $message_account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host);
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($message_account);
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($message_account, $self->{pbot}->{antiflood}->{NEEDS_CHECKBAN});
my @channels = $self->{pbot}->{messagehistory}->{database}->get_channels($message_account);
foreach my $channel (@channels) {
next if $channel !~ m/^#/;
@ -299,7 +299,7 @@ sub on_nickchange {
}
my $newnick_account = $self->{pbot}->{messagehistory}->{database}->get_message_account($newnick, $user, $host);
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($newnick_account);
$self->{pbot}->{messagehistory}->{database}->devalidate_all_channels($newnick_account, $self->{pbot}->{antiflood}->{NEEDS_CHECKBAN});
$self->{pbot}->{messagehistory}->{database}->update_hostmask_data($newnick_account, { last_seen => scalar gettimeofday });
$self->{pbot}->{antiflood}->check_flood("$nick!$user\@$host", $nick, $user, $host, "NICKCHANGE $newnick",

View File

@ -645,14 +645,17 @@ sub get_channel_datas_with_enter_abuses {
}
sub devalidate_all_channels {
my ($self, $id) = @_;
my ($self, $id, $mode) = @_;
$mode = 0 if not defined $mode;
my $where = '';
$where = 'WHERE id = ?' if defined $id;
eval {
my $sth = $self->{dbh}->prepare("UPDATE Channels SET validated = 0 $where");
$sth->bind_param(1, $id) if defined $id;
my $sth = $self->{dbh}->prepare("UPDATE Channels SET validated = ? $where");
$sth->bind_param(1, $mode);
$sth->bind_param(2, $id) if defined $id;
$sth->execute();
$self->{new_entries}++;
};

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 775,
BUILD_REVISION => 776,
BUILD_DATE => "2014-08-11",
};