HostAcceptor
From ChekMate Security Group
Contents |
[edit]
Introduction
This is the HostAcceptor bot, which will approve all HostServ requests unless they contain certain substrings.
[edit]
Change History
[edit]
Maintainer
[edit]
License
HostAcceptor.pl - Automatically accepts HostServ requests following certain guidelines Copyright (C) 2006 Daniel De Graaf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
[edit]
Installation
Run forked into the background, or stick "fork and exit" at the top. Run in a cronjob if you're too lazy to start it every reboot.
[edit]
HostAcceptor.pl
#!/usr/bin/perl -w
use strict;
use IO::Socket::INET6;
my $verb = 0;
my %forbidden;
$forbidden{$_} = 1 for qw/@ chekmate netgarage admin cyberarmy smashthestack/;
my $irc;
$irc = IO::Socket::INET6->new(
PeerAddr => '::1',
PeerPort => 6667,
) or die $!;
sub say {
print "==>", @_, "<==\n" if $verb;
print $irc @_, "\n";
}
say 'USER HostAcceptor gamma irc.chekmate.org :HostAcceptor Bot';
say 'NICK HostAcceptor';
say 'OPER HostAcceptor operPassword';
say 'PRIVMSG NickServ :identify servicesPassword';
sleep 1;
say 'MODE HostAcceptor -wghs';
say 'JOIN #services';
sub vhost {
my ($nick, $host) = @_;
my $lchost = lc $host;
for (keys %forbidden) {
if (-1 != index $lchost, $_) {
say "PRIVMSG HostServ :REJECT $nick";
say "PRIVMSG #services :Rejecting vHost $host for nick $nick because it matches \"$_\"";
say "NOTICE $nick :Your vHost was rejected - please choose a different one or ask an oper in #help to add it for you";
return;
}
}
say "PRIVMSG HostServ :ACTIVATE $nick";
say "PRIVMSG #services :Accepting vHost $host for nick $nick";
say "NOTICE $nick :Your vHost was accepted. To activate your vhost ($host), type /msg HostServ ON";
}
while (<$irc>) {
if (/^PING (:\S+)/) {
print $irc "PONG $1\n";
next;
}
print "<==$_" if $verb;
s/\r\n//;
if (s/^:\S+ PRIVMSG #services :vHost\s+//i) {
if (/^help/i) {
say "PRIVMSG #services vHost (refresh|forbid <host>|allow <host>|list)";
} elsif (/^refresh/i) {
say "PRIVMSG HostServ :waiting";
} elsif (/^forbid (\S+)/i) {
my $vh = lc $1;
$forbidden{$vh} = 1;
} elsif (/^allow (\S+)/i) {
my $vh = lc $1;
delete $forbidden{$vh};
} elsif (/^list/i) {
say "PRIVMSG #services :", join ' ', sort keys %forbidden;
} elsif (/^verb/i) {
$verb = !$verb;
}
} elsif (/^:Global!\S+ PRIVMSG #services :new vHost Requested/i) {
say "PRIVMSG HostServ :waiting";
} elsif (/^:HostServ!\S+ NOTICE \S+ :#\d+ Nick:\002(\S+)\002, vhost:\002(\S+)\002 /i) {
vhost($1,$2);
}
}




