3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 05:49:27 +01:00

Improve account-tracking and ban-evasion for Freenode irccloud.com web gateways

This commit is contained in:
Pragmatic Software 2015-06-13 16:08:57 -07:00
parent 8033213a7f
commit 4db125c3c2
2 changed files with 26 additions and 1 deletions

View File

@ -102,6 +102,8 @@ sub get_baninfo {
$self->{pbot}->{logger}->log("[get-baninfo] Getting baninfo for $mask in $channel using account " . (defined $account ? $account : "[undefined]") . "\n");
}
my ($nick, $user, $host) = $mask =~ m/([^!]+)!([^@]+)@(.*)/;
foreach my $mode (keys %{ $self->{banlist}{$channel} }) {
foreach my $banmask (keys %{ $self->{banlist}{$channel}{$mode} }) {
if($banmask =~ m/^\$a:(.*)/) {
@ -115,7 +117,20 @@ sub get_baninfo {
$banmask =~ s/\\\*/.*?/g;
$banmask =~ s/\\\?/./g;
if((defined $account and $account eq $ban_account) or $mask =~ m/^$banmask$/i) {
my $banned;
$banned = 1 if defined $account and $account eq $ban_account;
$banned = 1 if $mask =~ m/^$banmask$/i;
if ($banmask_key =~ m{\@gateway/web/irccloud.com} and $host =~ m{^gateway/web/irccloud.com}) {
my ($bannick, $banuser, $banhost) = $banmask_key =~ m/([^!]+)!([^@]+)@(.*)/;
if (lc $user eq lc $banuser) {
$banned = 1;
}
}
if ($banned) {
if(not defined $bans) {
$bans = [];
}

View File

@ -308,6 +308,16 @@ sub get_message_account {
my $rows = eval {
my $sth = $self->{dbh}->prepare('SELECT id, hostmask FROM Hostmasks WHERE hostmask LIKE ? ESCAPE "\" ORDER BY last_seen DESC');
if ($host =~ m{^gateway/web/irccloud.com}) {
$sth->bind_param(1, "%!$user\@gateway/web/irccloud.com/%");
$sth->execute();
my $rows = $sth->fetchall_arrayref({});
if (defined $rows->[0]) {
return $rows;
}
}
my $qnick = quotemeta (defined $link_nick ? $link_nick : $nick);
$qnick =~ s/_/\\_/g;
$sth->bind_param(1, "$qnick!%");