#!/usr/bin/perl -w
# eth32 irc spybot.
# 2007 (c) nixCoders.org
# usage: perl $0 server port nick
# make sure you read the /MOTD of the server you will connect. this bot wont do it, cause of size of the MOTD msg.
# use it at your own risk.
use warnings FATAL => 'all';
use Time::HiRes qw(sleep);
use POSIX;
use IO::Socket;
use strict;
$|=1;
my $server = shift || qw/irc.rizon.net/;
my $port = shift || 6667;
my $nick = shift || "eth32spy".int(rand(256));
my @channels = ("#nixcoders", "#eth32");
my $user = $nick;
our $rem = IO::Socket::INET->new(PeerAddr=>$server,PeerPort=>$port,Proto=>'tcp',Timeout=>'120') or die $!;
$rem->send("USER $user $user $user $user\r\n");
$rem->send("NICK $nick\r\n");
while (<$rem>) {
$rem->send("\x50\x4f\x4e\x47 $1\r\n") if /^\x50\x49\x4e\x47 (.*)$/;
$rem->send("PRIVMSG $1 :\001VERSION eth32 irc spybot\001\r\n") if /^:(.+)\!.*@.* PRIVMSG .* :\x01VERSION\x01/;
print POSIX::strftime('%H:%M:%S',localtime)," -!- <$1\@$2> $3\n" if /^:(.+)\!.*@.* PRIVMSG (.+) :(.*)/;
print POSIX::strftime('%H:%M:%S',localtime)," -!- Joined $1\n" if /366 $nick (.+) \:End of \/NAMES/;
print POSIX::strftime('%H:%M:%S',localtime)," -!- $server => $1\n" if /NOTICE AUTH \:\*\*\*(.*)/;
print POSIX::strftime('%H:%M:%S',localtime)," -!- $server => $1\n" if /002 $nick :(.*)/;
print POSIX::strftime('%H:%M:%S',localtime)," -!- $3 kicked from $2 by $1 with reason: $4\n" if /^:(.+)\!.*@.* KICK (.+?) (.+?) \:(.*)$/;
if (/376.*\:End of \/MOTD/) {
my $i;
for (1..scalar(@channels))
{ $rem->send("JOIN $channels[$i++]\r\n") }
}
sleep(0.1);
}